:root {
  --background: #f6f8fc;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --ink: #1f2740;
  --muted: #79839a;
  --line: #dfe5f0;
  --brand: #3b5bdb;
  --brand-strong: #1f2a4f;
  --brand-soft: #ebf0ff;
  --warn: #c97a18;
  --warn-soft: #fff4df;
  --danger: #d64545;
  --danger-soft: #feecec;
  --shadow: 0 10px 30px rgba(31, 39, 64, 0.08);
  --shadow-tight: 0 4px 14px rgba(31, 39, 64, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  background: #ffffff;
  color: var(--ink);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 0 20px;
  margin-bottom: 0;
  text-align: left;
}

.eyebrow {
  display: none;
}

.sidebar h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.sidebar p {
  display: none;
}

.nav {
  display: grid;
  gap: 8px;
  width: 100%;
}

.nav a {
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  background: transparent;
  color: #4a5568;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav a:hover {
  background: #f7fafc;
  color: #2d3748;
}

.nav a.active {
  background: linear-gradient(135deg, #4c6fff, #5b7cff);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(76, 111, 255, 0.25);
}

.sidebar-footnote {
  display: none;
}

.content {
  padding: 0;
  min-width: 0;
}

.content-inner {
  max-width: none;
  margin: 0;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 34px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title p {
  margin: 0;
}

.topbar-title p {
  color: var(--ink);
  font-size: 1.82rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero {
  background:
    linear-gradient(135deg, #0f1630, #1a2142);
  color: white;
  border-radius: 30px;
  padding: 30px 34px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  margin: 24px 34px 0;
}

.hero::after {
  display: none;
}

.hero h2,
.hero p {
  margin: 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto;
  gap: 36px;
  position: relative;
  z-index: 1;
  align-items: center;
}

.hero h2 {
  font-family: inherit;
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
  line-height: 1.08;
  letter-spacing: -0.05em;
}

.hero p {
  margin-top: 12px;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.45;
  font-size: 0.92rem;
}

.section {
  margin-top: 18px;
  padding: 0 34px;
  padding-bottom: 34px;
}

.upload-workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.upload-grid {
  padding: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.section-header h3,
.section-header p {
  margin: 0;
}

.section-header h3 {
  font-size: 0.98rem;
  letter-spacing: -0.03em;
}

.section-header p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.84rem;
}

.grid {
  display: grid;
  gap: 18px;
}

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

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-tight);
  min-width: 0;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title h3,
.card-title p {
  margin: 0;
}

.card-title p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.82rem;
}

.metric {
  display: grid;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  display: none;
}

.metric .label {
  color: var(--muted);
  font-size: 0.84rem;
}

.metric .value {
  font-size: 1.65rem;
  letter-spacing: -0.05em;
}

.metric-foot {
  color: var(--muted);
  font-size: 0.8rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.table th,
.table td {
  border-top: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge.ok {
  color: var(--brand);
  background: var(--brand-soft);
}

.badge.warn {
  color: var(--warn);
  background: var(--warn-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.stack {
  display: grid;
  gap: 12px;
}

.cta-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: white;
  box-shadow: none;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.button.secondary {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #f7f9fc;
  color: #5e6981;
  font-size: 0.8rem;
}

.hero-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  align-self: center;
  border-radius: 999px;
  padding: 10px;
  background: transparent;
  border: 0;
}

.hero-panel strong {
  display: none;
}

.hero-panel span {
  display: none;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.list-card {
  display: grid;
  gap: 12px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.list-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.list-row strong,
.list-row span {
  display: block;
}

.list-row span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.82rem;
}

.upload-dropzone {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 24px;
  border: 1.5px dashed #cbd5e6;
  background: #f8faff;
  color: var(--muted);
  padding: 20px;
}

.upload-dropzone strong {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
  margin-bottom: 8px;
}

.upload-picker-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.hidden-input {
  display: none;
}

.selected-file {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #f9fbff;
}

.selected-file-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selected-file strong {
  font-size: 0.92rem;
}

.selected-file-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.key-value-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.key-value {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.key-value span,
.key-value strong {
  display: block;
}

.key-value span {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.key-value strong {
  font-size: 0.9rem;
}

.premium-note {
  padding: 18px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-tight);
}

.premium-note h4,
.premium-note p {
  margin: 0;
}

.premium-note p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.84rem;
}

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

  .sidebar {
    height: auto;
    position: static;
  }

  .hero-grid,
  .panel-grid,
  .key-value-grid,
  .topbar {
    grid-template-columns: 1fr;
  }

  .grid-4,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

/* ── Generate PDF page ──────────────────────────────────────────────────── */

.gen-pdf-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 1024px) {
  .gen-pdf-layout {
    grid-template-columns: 1fr;
  }
}

.select-step {
  display: grid;
  gap: 10px;
}

.step-locked {
  opacity: 0.45;
  pointer-events: none;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.premium-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #f9fbff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 40px 12px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  outline: none;
}

.premium-select:hover {
  border-color: #b8c4e0;
}

.premium-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
}

.premium-select option {
  background: #ffffff;
  color: var(--ink);
}

.select-chevron {
  position: absolute;
  right: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
  user-select: none;
}

.batch-list {
  display: grid;
  gap: 8px;
}

.batch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #f9fbff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.batch-row:hover {
  border-color: #b8c4e0;
  background: #f4f7fd;
}

.batch-row-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.batch-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  flex-shrink: 0;
  cursor: pointer;
}

.batch-info {
  flex: 1;
  display: grid;
  gap: 2px;
}

.batch-info strong {
  font-size: 0.9rem;
  color: var(--ink);
}

.batch-info span {
  font-size: 0.8rem;
  color: var(--muted);
}

.download-success {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--brand-soft);
  border: 1px solid rgba(59, 91, 219, 0.18);
}

.download-success p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink);
}

.batch-summary-list {
  display: grid;
  gap: 6px;
}

.batch-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f4f7fd;
  font-size: 0.86rem;
  color: var(--ink);
}

.muted-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-preview {
  padding: 24px;
  text-align: center;
  border-radius: 14px;
  border: 1.5px dashed var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-preview p {
  margin: 0;
}

.info-note {
  padding: 14px 16px;
  border-radius: 14px;
  background: #f9fbff;
  border: 1px solid var(--line);
}

.info-note strong {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 6px;
  color: var(--ink);
}

.info-note p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.info-note a {
  color: var(--brand);
  font-weight: 600;
}

/* ── Documents page — view button ───────────────────────────────────────── */

.view-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  transition: background 160ms ease;
}

.view-link:hover {
  background: #d8e2ff;
}

/* ── Expiry page ─────────────────────────────────────────────────────────── */

.expiry-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.expiry-urgent {
  color: var(--danger);
  background: var(--danger-soft);
}

.expiry-soon {
  color: var(--warn);
  background: var(--warn-soft);
}

.expiry-ok {
  color: var(--brand);
  background: var(--brand-soft);
}

/* ── Document viewer modal ──────────────────────────────────────────────── */

.doc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 48, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.doc-modal {
  background: var(--panel);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(15, 22, 48, 0.28);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.doc-modal-title {
  display: block;
  font-size: 0.96rem;
  color: var(--ink);
}

.doc-modal-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

.doc-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
  flex-shrink: 0;
}

.doc-modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.doc-modal-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.doc-modal-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 320px;
  color: var(--muted);
  font-size: 0.9rem;
}

.doc-modal-iframe {
  width: 100%;
  height: 70vh;
  border: none;
  display: block;
}

.doc-modal-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f4f7fd;
  min-height: 320px;
}

.doc-modal-img {
  max-width: 100%;
  max-height: 65vh;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* ── Upload page — saved history list ───────────────────────────────────── */

.saved-history-list {
  display: grid;
  gap: 8px;
}

.saved-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f4f7fd;
  border: 1px solid var(--line);
}

.saved-history-info {
  display: grid;
  gap: 2px;
}

.saved-history-info strong {
  font-size: 0.88rem;
  color: var(--ink);
}

.saved-history-info span {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Upload page grid wrapper ───────────────────────────────────────────── */

.upload-grid-wrap {
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.upload-grid-wrap > * {
  min-width: 0;
}

/* The saved-history card spans both columns */
.upload-grid-wrap > .card:last-child:not(:first-child):not(:nth-child(2)) {
  grid-column: 1 / -1;
}

@media (max-width: 1024px) {
  .upload-grid-wrap {
    grid-template-columns: 1fr;
  }
}

.upload-form-card {
  width: 100%;
}

.stock-table-card {
  grid-column: 1 / -1;
  width: 100%;
}

.stock-table-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stock-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stock-table-head strong {
  font-size: 0.94rem;
}

.stock-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.stock-table {
  min-width: 1180px;
}

.stock-table-nowrap {
  white-space: nowrap;
}

.stock-table-item {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-table-item-code {
  color: var(--muted);
  margin-left: 4px;
  font-size: 0.76rem;
}

.stock-table-num {
  text-align: right !important;
}

.stock-table-strong {
  font-weight: 700;
}

.stock-table-brand {
  color: var(--brand);
}

.stock-table-total-row {
  border-top: 2px solid var(--line);
}

.stock-table-total-label {
  font-weight: 700;
  font-size: 0.84rem;
}

/* ── Premium form inputs ────────────────────────────────────────────────── */

/*
 * Global baseline — any bare input/select/textarea gets premium styling
 * automatically. Components that need overrides use .form-input,
 * .premium-select, etc. on top of this.
 */
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
textarea,
select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #f9fbff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  outline: none;
  box-sizing: border-box;
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"])::placeholder,
textarea::placeholder {
  color: #b8c4e0;
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover,
textarea:hover,
select:hover {
  border-color: #b8c4e0;
  background: #ffffff;
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
  background: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}

/* Checkbox & radio — accent brand colour */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.form-required {
  color: var(--danger);
  font-size: 0.9rem;
}

.form-optional {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: lowercase;
}

.form-input {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #f9fbff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  outline: none;
}

.form-input::placeholder {
  color: #b8c4e0;
}

.form-input:hover {
  border-color: #b8c4e0;
  background: #ffffff;
}

.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
  background: #ffffff;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ── Toggle switch ──────────────────────────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e6;
  transition: background 200ms ease;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-track:hover {
  background: #b8c4e0;
}

.toggle-on {
  background: var(--brand);
}

.toggle-on:hover {
  background: #2f4bc9;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 22, 48, 0.18);
  transition: transform 200ms ease;
}

.toggle-on .toggle-thumb {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 500;
}

/* ── Upload tabs ────────────────────────────────────────────────────────── */

.upload-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f4f7fd;
  border-radius: 18px;
  padding: 6px;
}

.upload-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.upload-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.upload-tab-active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(31, 39, 64, 0.1);
}

.upload-tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.upload-tab-desc {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-tab-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Dropzone interactive ───────────────────────────────────────────────── */

.upload-dropzone-interactive {
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.upload-dropzone-interactive:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-dropzone-interactive:hover strong {
  color: var(--brand);
}

.upload-dropzone-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-dropzone span {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.upload-file-chosen {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.upload-file-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.upload-file-chosen strong {
  display: block;
  font-size: 0.9rem;
  color: var(--brand);
  word-break: break-all;
}

.upload-file-chosen span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── File slot labels ───────────────────────────────────────────────────── */

.file-slot-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.file-slot-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Compact dropzone for invoice tab slots ─────────────────────────────── */

.upload-dropzone-compact {
  min-height: 72px;
  padding: 12px 16px;
}

.upload-dropzone-compact strong {
  font-size: 0.86rem;
}

.upload-dropzone-compact span {
  font-size: 0.76rem;
}

.upload-dropzone-compact .upload-file-icon {
  font-size: 1.4rem;
}

.upload-dropzone-compact .upload-file-chosen strong {
  font-size: 0.84rem;
}

/* ── Snackbar ───────────────────────────────────────────────────────────── */

.snackbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.snackbar-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(214, 69, 69, 0.2);
}

.snackbar-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.82rem;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.7;
  flex-shrink: 0;
}

.snackbar-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

/* ── Login page ─────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1630, #1a2142);
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border-radius: 28px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 20px;
}

.login-brand {
  text-align: center;
}

.login-brand h1 {
  margin: 8px 0 6px;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.3;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.login-hint {
  padding: 14px 16px;
  border-radius: 14px;
  background: #f4f7fd;
  border: 1px solid var(--line);
}

.login-hint p {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-hint-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  font-size: 0.78rem;
}

.login-hint-grid span:nth-child(odd) {
  color: var(--ink);
  font-weight: 600;
}

.login-hint-grid span:nth-child(even) {
  color: var(--muted);
  font-family: monospace;
}

/* ── Sidebar user block ──────────────────────────────────────────────────── */

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  width: 100%;
}

.sidebar-user-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-user-info strong {
  font-size: 0.88rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.sidebar-user-info span {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
}

.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms ease, color 160ms ease;
}

.sidebar-logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* Make sidebar a flex column so user block sticks to bottom */
.sidebar {
  display: flex;
  flex-direction: column;
}

.nav {
  flex: 0 0 auto;
}

/* ── Document page tabs ─────────────────────────────────────────────────── */

.doc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

.doc-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 160ms ease, border-color 160ms ease;
}

.doc-tab:hover {
  color: var(--ink);
}

.doc-tab-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.doc-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}

/* ── Notification bell ──────────────────────────────────────────────────── */

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 160ms ease;
}

.notif-bell:hover {
  background: #f4f7fd;
}

.notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(15, 22, 48, 0.16);
  z-index: 100;
  overflow: hidden;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.notif-header strong {
  font-size: 0.9rem;
  color: var(--ink);
}

.notif-clear {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.notif-list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-empty {
  padding: 20px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
  margin: 0;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 160ms ease;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: #f4f7fd;
}

.notif-unread {
  background: var(--brand-soft);
}

.notif-unread:hover {
  background: #d8e2ff;
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.notif-dot-ok { background: var(--brand); }
.notif-dot-warn { background: var(--warn); }
.notif-dot-danger { background: var(--danger); }

.notif-body {
  flex: 1;
  min-width: 0;
}

.notif-body p {
  margin: 0 0 3px;
  font-size: 0.84rem;
  color: var(--ink);
  line-height: 1.4;
}

.notif-body span {
  font-size: 0.74rem;
  color: var(--muted);
}

/* ── Nav badge ──────────────────────────────────────────────────────────── */

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: auto;
}

/* ── Danger badge ───────────────────────────────────────────────────────── */

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ── Multi-select dropdown ──────────────────────────────────────────────── */

.multi-select-wrapper {
  position: relative;
  display: inline-block;
}

.multi-select-trigger {
  position: relative;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  background: #f9fbff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 160ms ease;
}

.multi-select-trigger:hover {
  border-color: #b8c4e0;
}

.multi-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 22, 48, 0.12);
  z-index: 50;
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.multi-select-wrapper:focus-within .multi-select-dropdown,
.multi-select-wrapper:hover .multi-select-dropdown {
  display: block;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease;
}

.multi-select-option:hover {
  background: #f4f7fd;
}

/* ── Checkbox group ─────────────────────────────────────────────────────── */

.checkbox-group {
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #f9fbff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease;
}

.checkbox-option:hover {
  background: #f0f4fd;
}

/* ── Royal AI Modal ─────────────────────────────────────────────────────── */

.royal-ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 48, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.royal-ai-modal {
  background: var(--panel);
  border-radius: 28px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 480px;
  padding: 32px 28px;
  display: grid;
  gap: 18px;
  text-align: center;
  animation: slideUp 300ms ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.royal-ai-video-container {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(59, 91, 219, 0.24);
}

.royal-ai-video {
  width: 100%;
  height: auto;
  display: block;
}

.royal-ai-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b5bdb, #4968e8);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 auto;
  box-shadow: 0 8px 20px rgba(59, 91, 219, 0.3);
}

.royal-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

.royal-ai-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}

.royal-ai-progress-track {
  width: 100%;
  height: 8px;
  background: #e8ecf4;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.royal-ai-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b5bdb, #4968e8, #5a7aff);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 400ms ease;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.royal-ai-messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  text-align: left;
  max-height: 120px;
  overflow-y: auto;
}

.royal-ai-messages li {
  font-size: 0.86rem;
  color: var(--ink);
  padding: 8px 12px;
  background: #f4f7fd;
  border-radius: 10px;
  line-height: 1.4;
}

.royal-ai-footer {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Rotation Tabs ──────────────────────────────────────────────────────── */

.rotation-tabs {
  display: inline-flex;
  gap: 6px;
  background: #f4f7fd;
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 18px;
}

.rotation-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
  white-space: nowrap;
}

.rotation-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.rotation-tab.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(31, 39, 64, 0.1);
}

.rotation-tab-content {
  display: none;
}

.rotation-tab-content.active {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
