:root {
  --canvas: #f7fcff;
  --canvas-deep: #d9f4ff;
  --ink: #11384a;
  --ink-soft: #56717d;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(17, 56, 74, 0.1);
  --accent: #00b0f0;
  --accent-deep: #007db3;
  --accent-soft: rgba(0, 176, 240, 0.12);
  --success: #13856c;
  --warning: #a66b0a;
  --shadow: 0 24px 60px rgba(17, 56, 74, 0.12);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(0, 176, 240, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(17, 56, 74, 0.08), transparent 28%),
    linear-gradient(135deg, #ffffff, var(--canvas) 48%, var(--canvas-deep));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)),
    repeating-linear-gradient(
      120deg,
      transparent 0,
      transparent 22px,
      rgba(17, 56, 74, 0.014) 22px,
      rgba(17, 56, 74, 0.014) 23px
    );
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

#app {
  position: relative;
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(620px, 100%);
  display: grid;
  gap: 22px;
  padding: 26px;
  border: 1px solid rgba(17, 56, 74, 0.1);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 252, 255, 0.94)),
    radial-gradient(circle at top right, rgba(0, 176, 240, 0.16), transparent 34%);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.auth-brand img {
  width: 84px;
  max-height: 84px;
  object-fit: contain;
}

.auth-brand h1 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: 2rem;
}

.auth-brand p {
  margin: 4px 0 0;
  color: var(--ink-soft);
}

.setup-key {
  display: block;
  margin: 10px 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(17, 56, 74, 0.08);
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: 0.08em;
  word-break: break-all;
}

.auth-qr-code {
  display: block;
  width: min(280px, 100%);
  height: auto;
  margin: 12px auto 0;
  padding: 12px;
  border: 1px solid rgba(17, 56, 74, 0.1);
  border-radius: 18px;
  background: #ffffff;
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 28px 22px;
  background:
    linear-gradient(180deg, rgba(5, 74, 103, 0.96), rgba(8, 105, 146, 0.92)),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 22%);
  color: #ffffff;
}

.brand {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.brand-logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 118px;
}

.brand-title-card h1 {
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand p,
.rail-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
}

.brand-logo {
  display: block;
  max-width: 168px;
  max-height: 54px;
  object-fit: contain;
}

.brand-logo-card .brand-logo {
  max-width: 100%;
  max-height: 88px;
}

.brand-logo-card .brand-mark-fallback {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  font-size: 1.1rem;
}

.brand-mark,
.brand-mark-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #58d4ff, #00b0f0);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand-mark-fallback.is-hidden {
  display: none;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.nav button:hover,
.nav button.is-active {
  transform: translateX(3px);
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

.nav-label {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.8rem;
}

.workspace {
  padding: 28px;
}

.workspace-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.workspace-header h2 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1.05;
}

.workspace-header p {
  margin: 10px 0 0;
  max-width: 720px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn,
.ghost-btn,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(0, 176, 240, 0.26);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid var(--line);
}

.link-btn {
  padding: 0;
  background: none;
  color: var(--accent-deep);
}

.link-btn.is-danger {
  color: #a43131;
}

.btn:hover,
.ghost-btn:hover,
.link-btn:hover {
  transform: translateY(-1px);
}

.message {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.message.is-success {
  border-color: rgba(35, 90, 78, 0.24);
  color: var(--success);
}

.message.is-error {
  border-color: rgba(182, 61, 42, 0.2);
  color: #8b2e27;
}

.dashboard-grid,
.split-grid,
.triple-grid,
.form-grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
}

.split-grid {
  grid-template-columns: 1.35fr 1fr;
  align-items: start;
}

.triple-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 22px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-strong {
  background: var(--panel-strong);
}

.hero {
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -45% auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 176, 240, 0.18), transparent 70%);
}

.panel-header,
.stack-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h3,
.panel h4,
.metric-value,
.section-title {
  margin: 0;
}

.section-title {
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  font-size: 1.28rem;
}

.muted {
  color: var(--ink-soft);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 140px;
  padding: 20px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.58)),
    linear-gradient(135deg, rgba(0, 176, 240, 0.06), transparent 60%);
  border: 1px solid rgba(23, 32, 51, 0.07);
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metric-note {
  color: var(--ink-soft);
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.list-controls {
  margin-bottom: 14px;
  align-items: end;
}

.control-field {
  min-width: 220px;
  flex: 1 1 220px;
}

.mini-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(23, 32, 51, 0.08);
}

.mini-card strong,
.mini-card b {
  display: block;
  margin-bottom: 6px;
}

button.mini-card {
  width: 100%;
  border: 1px solid rgba(23, 32, 51, 0.08);
  text-align: left;
  cursor: pointer;
}

.attachment-card.is-selected {
  border-color: rgba(0, 176, 240, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 176, 240, 0.12);
}

.attachment-browser {
  gap: 14px;
}

.attachment-preview-toolbar {
  justify-content: space-between;
  align-items: center;
}

.attachment-image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(17, 56, 74, 0.08);
}

.attachment-pdf-frame {
  width: 100%;
  min-height: 720px;
  border: 1px solid rgba(17, 56, 74, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  background: rgba(255, 255, 255, 0.58);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(23, 32, 51, 0.07);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: rgba(244, 252, 255, 0.98);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sort-arrows {
  display: inline-flex;
  gap: 4px;
}

.sort-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(17, 56, 74, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.sort-arrow:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 176, 240, 0.25);
  color: var(--accent-deep);
}

.sort-arrow.is-active {
  background: rgba(0, 176, 240, 0.14);
  border-color: rgba(0, 176, 240, 0.35);
  color: var(--accent-deep);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr.is-selected {
  background: rgba(0, 176, 240, 0.08);
}

.auth-reset-row td {
  background: rgba(0, 176, 240, 0.06);
}

.auth-reset-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(180px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.group-row td {
  padding: 10px 14px;
  background: rgba(0, 176, 240, 0.09);
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.is-success {
  background: rgba(35, 90, 78, 0.12);
  color: var(--success);
}

.pill.is-muted {
  background: rgba(23, 32, 51, 0.08);
  color: var(--ink-soft);
}

.panel form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field-hint {
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.line-editor,
.preview-card,
.supplier-group {
  display: grid;
  gap: 12px;
}

.line-editor {
  padding: 16px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.line-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.6fr 0.9fr;
  gap: 10px;
  align-items: end;
}

.supplier-line-grid {
  grid-template-columns: 1fr 1fr 0.8fr 0.45fr auto;
}

.bom-add-card {
  gap: 14px;
}

.bom-add-grid {
  grid-template-columns: 1.1fr 1.1fr 0.55fr 0.9fr;
}

.bom-line-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1.4fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.bom-line-main {
  min-width: 0;
}

.bom-line-main strong,
.bom-line-main .muted {
  display: block;
}

.bom-line-main .muted {
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bom-line-qty,
.bom-line-actions {
  display: flex;
  align-items: center;
}

.bom-line-actions {
  justify-content: flex-end;
}

.drag-handle {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 4px;
  cursor: grab;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-bar {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: rgba(17, 56, 74, 0.55);
}

.bom-line-row.is-dragging {
  opacity: 0.72;
}

.bom-line-row.is-drag-over {
  border-color: rgba(0, 176, 240, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 176, 240, 0.12);
}

.supplier-group {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  background: rgba(255, 255, 255, 0.66);
}

.shipment-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(0, 176, 240, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 252, 255, 0.88)),
    linear-gradient(135deg, rgba(0, 176, 240, 0.08), transparent 55%);
}

.shipment-editor .toolbar {
  justify-content: flex-end;
}

.shipment-line-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shipment-line-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 176, 240, 0.12);
  color: var(--accent-deep);
  font-size: 0.9rem;
}

.shipment-line-pill strong {
  margin: 0;
}

.shipment-preview-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(17, 56, 74, 0.08);
  background: rgba(255, 255, 255, 0.82);
}

.shipment-history-card {
  display: grid;
  gap: 10px;
}

.order-card-summary {
  align-items: center;
}

.supplier-group header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.preview-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(244, 252, 255, 0.94);
  border: 1px solid rgba(23, 32, 51, 0.08);
}

.preview-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-family: inherit;
}

.spreadsheet-sheet {
  gap: 10px;
}

.spreadsheet-table {
  min-width: 100%;
}

.spreadsheet-table th,
.spreadsheet-table td {
  border-right: 1px solid rgba(23, 32, 51, 0.07);
}

.spreadsheet-table th:last-child,
.spreadsheet-table td:last-child {
  border-right: none;
}

.sheet-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.sheet-media-card {
  margin: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(17, 56, 74, 0.08);
  background: rgba(255, 255, 255, 0.78);
}

.sheet-media-card img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(17, 56, 74, 0.08);
}

.sheet-media-card figcaption {
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}

.empty-state {
  padding: 28px;
  border: 1px dashed rgba(23, 32, 51, 0.18);
  border-radius: 22px;
  color: var(--ink-soft);
  text-align: center;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.history-stat {
  display: grid;
  gap: 7px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(17, 56, 74, 0.08);
}

.chart-shell {
  padding: 18px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(241, 251, 255, 0.92)),
    linear-gradient(135deg, rgba(0, 176, 240, 0.08), transparent 55%);
  border: 1px solid rgba(17, 56, 74, 0.08);
}

.history-chart {
  display: block;
  width: 100%;
  height: auto;
}

.history-axis-label {
  fill: rgba(17, 56, 74, 0.62);
  font-size: 0.8rem;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

.chart-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 12px;
  margin-top: 10px;
}

.chart-meta-center {
  text-align: center;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 10px rgba(35, 90, 78, 0.08);
}

.dim {
  color: var(--ink-soft);
}

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.footer-note {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    min-height: auto;
  }

  .dashboard-grid,
  .triple-grid,
  .split-grid,
  .form-grid,
  .history-grid,
  .auth-reset-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .workspace {
    padding: 22px 16px 28px;
  }

  .rail {
    padding: 18px 16px;
  }

  .dashboard-grid,
  .triple-grid,
  .split-grid,
  .form-grid,
  .line-grid,
  .history-grid,
  .chart-meta,
  .auth-reset-form {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    flex-direction: column;
  }

  .bom-line-row {
    grid-template-columns: auto 1fr;
  }

  .bom-line-qty,
  .bom-line-actions {
    grid-column: 2;
  }

  table {
    min-width: 520px;
  }
}
