:root {
  --font-heading: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  --font-body: "Noto Sans Thai", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "IBM Plex Sans Thai", Consolas, monospace;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --navy: #0b1e38;
  --brand-blue: #1d4ed8;
  --brand-red: #dc2626;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-hover: #047857;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --sidebar-w: 264px;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .kpi-value, .btn, .nav-item, th {
  font-family: var(--font-heading);
}

.font-mono { font-family: var(--font-mono) !important; }
.hidden { display: none !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.muted { color: var(--muted); }

/* ================= LOGIN PAGE ================= */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0b1e38 0%, #153666 55%, #1e3a8a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-shell {
  width: 980px;
  max-width: 100%;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(3, 12, 30, 0.45);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
}

.login-brand-panel {
  background:
    radial-gradient(circle at 15% 15%, rgba(220, 38, 38, 0.16), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(59, 130, 246, 0.25), transparent 55%),
    linear-gradient(160deg, #0b1e38 0%, #102a4e 100%);
  color: #fff;
  padding: 44px 40px 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-logo-box {
  width: 92px;
  height: 92px;
  background: #ffffff;
  border-radius: 20px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  margin-bottom: 22px;
}

.login-logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-brand-panel h2 {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-brand-desc {
  margin: 0 0 28px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.65;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.9);
}

.lf-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #60a5fa, #f87171);
  flex-shrink: 0;
}

.login-brand-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.login-brand-footer code {
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.85);
}

.login-form-panel {
  padding: 48px 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.login-form-card {
  width: 100%;
  max-width: 360px;
}

.login-mobile-logo {
  display: none;
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
}
.login-mobile-logo img { width: 100%; height: 100%; object-fit: contain; }

.login-form-card h1 {
  margin: 0;
  font-size: 24px;
  color: var(--navy);
}

.login-sub {
  margin: 4px 0 24px;
  font-size: 13.5px;
  color: var(--muted);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .input { padding-right: 42px; }

.pwd-toggle {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.pwd-toggle:hover { color: var(--navy); background: var(--surface-soft); }

.btn-login {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  margin-top: 6px;
}

.login-hint {
  margin-top: 22px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.login-hint code {
  font-family: var(--font-mono);
  background: #fff;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  color: var(--primary);
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-soft); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: #065f46; border: 1px solid #a7f3d0; }

/* ================= APP SHELL & SIDEBAR ================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b1e38 0%, #0f2747 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  box-shadow: 4px 0 20px rgba(11, 30, 56, 0.14);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-tile {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.24);
  flex-shrink: 0;
}

.sidebar-logo-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.44);
  padding: 4px 10px 6px;
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.14);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #ef4444);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.btn-sidebar-sub,
.btn-sidebar-logout {
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  transition: background 0.15s ease;
}
.btn-sidebar-sub:hover { background: rgba(255, 255, 255, 0.16); }
.btn-sidebar-logout {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}
.btn-sidebar-logout:hover { background: rgba(220, 38, 38, 0.45); color: #fff; }

/* Main Content Shell */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 25;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-only { display: none !important; }

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.page-subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

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

.workspace-content {
  padding: 24px 28px 56px;
  max-width: 1440px;
  width: 100%;
}

.view-section { display: none; }
.view-section.active { display: block; animation: fadeInView 0.18s ease; }

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

/* ================= BUTTONS & INPUTS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%); transform: translateY(-1px); }

.btn-success {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.24);
}
.btn-success:hover { background: linear-gradient(180deg, #059669 0%, #047857 100%); transform: translateY(-1px); }

.btn-ghost {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-soft); border-color: var(--border-strong); color: var(--ink); }

.btn-danger-outline {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger-outline:hover { background: #fee2e2; }

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon:hover { background: var(--surface-soft); border-color: var(--border); color: var(--ink); }

.input, .select {
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* ================= DASHBOARD ================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-card-accent {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  border-color: #bfdbfe;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-label {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kpi-icon-blue { background: #eff6ff; color: #2563eb; }
.kpi-icon-indigo { background: #eef2ff; color: #4f46e5; }
.kpi-icon-emerald { background: #ecfdf5; color: #059669; }
.kpi-icon-amber { background: #fffbeb; color: #d97706; }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi-card-accent .kpi-value { color: #1d4ed8; }

.kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.dash-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
  align-items: stretch;
}

.dash-grid-balanced {
  align-items: stretch;
}

.dash-col-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
}

.dash-card-fill {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Scalable Top-5 + Others Vendor Ranking (replaces Donut) */
.vendor-rank-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vendor-stacked-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  display: flex;
  gap: 2px;
}

.vendor-stacked-seg {
  height: 100%;
  transition: width 0.35s ease;
}

.vendor-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vendor-rank-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid #eef2f7;
  transition: all 0.15s ease;
}

.vendor-rank-row.clickable {
  cursor: pointer;
}

.vendor-rank-row.clickable:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.vendor-rank-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vendor-rank-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.vendor-rank-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.vendor-rank-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vendor-po-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.vendor-rank-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.vendor-rank-pct {
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}

.vendor-rank-bar-bg {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.vendor-rank-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Dedicated Import Page */
.import-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pipe-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
}

.pipe-step strong {
  display: block;
  font-family: var(--font-heading);
  color: var(--navy);
  margin-bottom: 2px;
}

.pipe-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dash-card {
  padding: 20px 22px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h3 {
  margin: 0;
  font-size: 15.5px;
  color: var(--navy);
}

.card-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.pill-soft {
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

/* Monthly Bar Chart */
.chart-area {
  min-height: 215px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 16px 8px 4px;
}

.bar-col {
  flex: 1;
  min-width: 58px;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--navy);
}

.bar-track {
  width: 100%;
  height: 140px;
  background: #f1f5f9;
  border-radius: 10px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  padding: 4px;
}

.bar-fill {
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  transition: height 0.4s ease;
  min-height: 10px;
}

.bar-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.bar-po-sub {
  font-size: 11px;
  color: var(--muted);
}

/* Vendor Share Donut + Legend */
.vendor-share-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 215px;
  flex-wrap: wrap;
}

.donut-box {
  position: relative;
  width: 168px;
  height: 168px;
  flex-shrink: 0;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-label { font-size: 11px; color: var(--muted); }
.donut-center-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.vendor-legend {
  flex: 1;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.legend-name {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

/* Top Items Ranked Bars */
.top-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-item-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid #eef2f7;
}

.top-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.top-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--navy);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.top-item-row:nth-child(1) .rank-num { background: #dbeafe; color: #1d4ed8; }
.top-item-row:nth-child(2) .rank-num { background: #e0e7ff; color: #4338ca; }
.top-item-row:nth-child(3) .rank-num { background: #fef3c7; color: #b45309; }

.top-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-item-amount {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.top-item-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-item-bar-bg {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.top-item-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}

.top-item-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Due Tracker & Mini Activity */
.due-list, .activity-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.due-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.due-row:hover { background: #eff6ff; border-color: #bfdbfe; }

.due-po {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  font-size: 13.5px;
}

.due-vendor { font-size: 12.5px; color: var(--ink-2); }

.due-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.due-date-pill {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.due-ok { background: #eff6ff; color: #1d4ed8; }
.due-soon { background: #fffbeb; color: #b45309; }
.due-over { background: #fef2f2; color: #dc2626; }
.due-paid { background: #ecfdf5; color: #059669; }

.activity-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
  font-size: 12.5px;
}

.act-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--navy);
  white-space: nowrap;
}

.act-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ================= TABLES & STATUS ================= */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-box { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: #94a3b8; pointer-events: none; }
.search-input { padding-left: 36px; width: 340px; max-width: 100%; }

.result-count { font-size: 12.5px; font-weight: 500; color: var(--muted); }

.hint-bar {
  padding: 9px 20px;
  background: #f8fbff;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: #475569;
}

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }

.po-table tbody tr { cursor: pointer; transition: background 0.14s ease; }
.po-table tbody tr:hover { background: #f4f8ff; }

.po-number { font-family: var(--font-mono); font-weight: 600; font-size: 14px; color: var(--primary); }
.po-date-sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.vendor-name-cell { font-weight: 600; color: var(--ink); }

.ref-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ref-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
}
.status-ISSUED { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-RECEIVED { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.status-PAID { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.status-CANCELLED { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.status-select {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--navy);
  cursor: pointer;
}

.items-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 4px 11px;
  border-radius: 999px;
  transition: all 0.15s ease;
}
.po-table tbody tr:hover .items-pill { background: #2563eb; border-color: #2563eb; color: #fff; }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.num-strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--navy); }

.code-chip {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--navy);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  display: inline-block;
}

.empty-cell { text-align: center; padding: 48px 20px !important; color: var(--muted); }
.actions-cell { display: flex; gap: 6px; justify-content: center; align-items: center; }

/* ================= DRAWER & MODALS ================= */
.drawer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.44); backdrop-filter: blur(3px); }
.drawer-panel {
  position: relative;
  width: min(960px, 95vw);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideInRight { from { transform: translateX(32px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.drawer-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drawer-tag {
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  padding: 2px 9px;
  border-radius: 999px;
}
.drawer-header h2 { margin: 0; font-family: var(--font-mono); font-size: 20px; color: var(--navy); }
.drawer-vendor { margin: 4px 0 0; font-size: 14px; font-weight: 500; color: var(--ink-2); }

.drawer-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.meta-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-chip { font-size: 12px; color: var(--ink-2); background: #fff; border: 1px solid var(--border); padding: 4px 10px; border-radius: 8px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.drawer-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.mini-stat { padding: 10px 12px; border-radius: 10px; background: var(--surface-soft); border: 1px solid var(--border); }
.mini-stat-total { background: #eff6ff; border-color: #bfdbfe; }
.mini-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.mini-stat strong { font-family: var(--font-mono); font-size: 15px; color: var(--navy); }
.mini-stat-total strong { color: #1d4ed8; }

.drawer-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.export-cols-hint { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.col-pill { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; padding: 2px 7px; border-radius: 6px; font-weight: 600; font-size: 11px; }

.drawer-body { flex: 1; overflow-y: auto; }
.drawer-table th { position: sticky; top: 0; z-index: 5; background: #f8fafc; }
.drawer-table td { padding: 10px 14px; }

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal-top { z-index: 70; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px); }
.modal-box {
  position: relative;
  width: 480px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-box-lg { width: 580px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 17px; color: var(--navy); }
.modal-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-family: var(--font-heading); font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--ink-2); }
.form-group .input { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.drop-zone {
  padding: 36px 24px;
  border: 2px dashed #93c5fd;
  border-radius: 14px;
  background: #f8fbff;
  text-align: center;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: #eff6ff; }
.drop-zone-icon { color: var(--primary); margin-bottom: 10px; }
.drop-zone-title { font-family: var(--font-heading); font-size: 15px; font-weight: 600; color: var(--navy); }
.link-like { color: var(--primary); text-decoration: underline; }
.drop-zone-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.upload-status {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  max-height: 220px;
  overflow-y: auto;
}
.upload-status.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.upload-status.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.upload-status.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.global-drop-card {
  background: #fff;
  border: 2px dashed var(--primary);
  border-radius: 20px;
  padding: 44px 56px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.global-drop-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.global-drop-title { font-family: var(--font-heading); font-size: 19px; font-weight: 700; color: var(--navy); }
.global-drop-sub { margin-top: 6px; font-size: 13.5px; color: var(--muted); }

.toast-container { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  font-family: var(--font-heading);
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 11px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
  font-size: 13.5px;
  font-weight: 500;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 35; }

/* Responsive */
@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .mobile-only { display: inline-flex !important; }
  .app-topbar { padding: 14px 18px; }
  .workspace-content { padding: 18px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-mobile-logo { display: block; }
  .login-form-panel { padding: 36px 24px; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .drawer-summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-input { width: 100%; }
}

/* ================= GOODS RECEIPT (ใบรับสินค้า) ================= */
.gr-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.gr-subnav {
  margin-bottom: 14px;
}

.segmented-tabs {
  display: inline-flex;
  background: #e6ecf5;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.seg-tab {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 8px 16px;
  border-radius: 9px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.seg-tab.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.seg-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 1px 7px;
  border-radius: 999px;
}

.gr-tab-pane { display: none; }
.gr-tab-pane.active { display: block; }

.gr-progress-panel {
  padding: 16px 20px;
  background: #f8fbff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gr-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.gr-progress-bar-bg {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.gr-progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb 0%, #10b981 100%);
  transition: width 0.35s ease;
}

.gr-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.gr-status-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.14s ease;
}

.filter-chip span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f1f5f9;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-chip.active span { background: rgba(255, 255, 255, 0.2); color: #fff; }

.gr-entry-bar {
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.gr-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.gr-entry-grid label {
  display: block;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.gr-entry-grid .input { width: 100%; }

.gr-entry-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.gr-entry-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recv-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.recv-PENDING { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.recv-PARTIAL { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.recv-COMPLETE { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

.qty-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.qty-input {
  width: 92px;
  padding: 6px 8px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
}

.btn-fill-one {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-fill-one:hover { background: #10b981; color: #fff; border-color: #10b981; }

.remark-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12.5px;
}

.modal-box-xl { width: min(860px, calc(100vw - 32px)); }

/* Dashboard Receiving Mini Progress */
.dash-recv-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.dash-recv-row:hover { background: #eff6ff; border-color: #bfdbfe; }
.dash-recv-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dash-recv-bar-bg { width: 100%; height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.dash-recv-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #10b981); }

@media (max-width: 900px) {
  .gr-kpi-grid { grid-template-columns: 1fr; }
  .gr-entry-grid { grid-template-columns: 1fr; }
}

/* ================= WIDE GR DRAWER & RBAC MATRIX ================= */
.drawer-panel-wide {
  width: min(1160px, 96vw);
}

.rbac-tab-pane { display: none; }
.rbac-tab-pane.active { display: block; }

.rbac-matrix-table th,
.rbac-matrix-table td {
  border-right: 1px solid #f1f5f9;
}

.rbac-matrix-table th:first-child,
.rbac-matrix-table td:first-child {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 3;
  min-width: 280px;
  border-right: 1px solid var(--border);
}

.rbac-matrix-table thead th:first-child {
  background: #f8fafc;
  z-index: 6;
}

.rbac-group-row td {
  background: #f1f5f9 !important;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  padding: 9px 16px !important;
  text-transform: none;
}

.rbac-role-head {
  text-align: center !important;
  min-width: 132px;
  vertical-align: top;
}

.rbac-role-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
}

.rbac-role-code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.rbac-role-del {
  margin-top: 4px;
  font-size: 11px;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 4px;
}
.rbac-role-del:hover { background: var(--danger-soft); }

.perm-label {
  font-weight: 500;
  color: var(--ink);
  font-size: 13.5px;
}

.perm-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Modern Toggle Switch for RBAC Matrix */
.rbac-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.rbac-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.rbac-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.18s;
  border-radius: 999px;
}

.rbac-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.18s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}

.rbac-switch input:checked + .rbac-slider {
  background-color: #2563eb;
}

.rbac-switch input:checked + .rbac-slider::before {
  transform: translateX(18px);
}

.rbac-switch input:disabled + .rbac-slider {
  background-color: #059669;
  opacity: 0.72;
  cursor: not-allowed;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.role-pill.role-ADMIN { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.role-pill.role-WAREHOUSE { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.role-pill.role-ACCOUNTING { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
.role-pill.role-VIEWER { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

.po-recv-mini-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 4px;
}

.po-recv-mini-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #10b981);
}

/* ================= EXPORT SELECTOR MODAL ================= */
.export-option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.export-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.export-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
}

.export-option strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 13.5px;
  color: var(--navy);
}

.export-option .muted {
  font-size: 12px;
  margin-top: 2px;
}

.export-option:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.export-option.active {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* ================= PRICE HISTORY DRAWER & DELTA ================= */
.price-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.delta-up { background: #fef2f2; color: #dc2626; }
.delta-down { background: #ecfdf5; color: #059669; }
.delta-same { background: #f1f5f9; color: #64748b; }

.ph-chart-wrap {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: #fbfdff;
}

.ph-chart-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ================= GOOGLE SHEET RECEIVING SYNC ================= */
.sheet-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 180px;
  overflow-y: auto;
}

.sheet-link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.sheet-link-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--navy);
}

.sheet-link-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.sheet-csv-fallback {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* ================= LICENSE ACTIVATION PAGE ================= */
.license-card {
  width: 680px;
  max-width: 100%;
  background: var(--surface);
  border-radius: 22px;
  padding: 32px 34px;
  box-shadow: 0 32px 80px rgba(3, 12, 30, 0.42);
}

.license-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.hwid-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #bfdbfe;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hwid-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.lic-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lic-info-item {
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.lic-info-item span {
  display: block;
  font-size: 11.5px;
  margin-bottom: 2px;
}

.lic-info-item strong {
  font-size: 13.5px;
  color: var(--navy);
}

@media (max-width: 600px) {
  .lic-info-grid { grid-template-columns: 1fr; }
  .license-card { padding: 24px 20px; }
}
