:root {
  --primary: #9f1239;
  --primary-dark: #7a0e2c;
  --primary-light: #fdf2f6;
  --accent: #c2410c;
  --accent-light: #fff7ed;
  --bg: #fbf8f4;
  --surface: #ffffff;
  --border: #ede4d8;
  --text: #1f1b16;
  --muted: #6b6258;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(31, 27, 22, 0.04), 0 4px 12px rgba(31, 27, 22, 0.05);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Horizontal top navigation bar with dropdown group menus. */
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: visible;
  min-height: 40px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0;
  flex-shrink: 0;
}
.logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.brand-name { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.brand-tag { display: none; }

.nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow: visible;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-link.active { background: var(--primary); color: white; }

/* Top-level group menus */
.nav-group { margin: 0; position: relative; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  white-space: nowrap;
}
.nav-group-header:hover { color: var(--primary); background: var(--primary-light); }
.nav-group-header .chevron { font-size: 9px; opacity: 0.6; transition: transform .15s ease; }
.nav-group.has-active > .nav-group-header {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-light);
  box-shadow: inset 0 -2px 0 var(--primary);
  border-radius: 8px 8px 0 0;
}
.nav-group.open .chevron { transform: rotate(180deg); }

/* Dropdown panel */
.nav-group-items {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-width: 215px;
  flex-direction: column;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.16);
  padding: 6px;
  z-index: 60;
}
.nav-group.open .nav-group-items { display: flex; }
.nav-sub {
  padding: 8px 12px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border-radius: 6px;
  white-space: nowrap;
}
.nav-sub:hover { background: var(--primary-light); color: var(--primary) !important; }
.nav-sub.active { background: var(--primary); color: white !important; }
.nav-sub:not(.active) { color: var(--text); }

.topbar-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.topbar-actions .user-chip { width: auto; justify-content: flex-start; }
.topbar-actions .btn {
  width: auto;
  justify-content: center;
  padding: 7px 10px;
  font-size: 12.5px;
}

/* Tab strip (open pages) — sticks just below the top nav (offset = nav height) */
.tab-bar {
  position: sticky; top: var(--topbar-h, 56px); z-index: 45;
  display: flex; align-items: stretch; gap: 4px;
  padding: 6px 12px 0; background: #f3ece8;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
}
.tab-bar::-webkit-scrollbar { height: 6px; }
.tab-bar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 3px; }
.tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 9px; max-width: 210px;
  background: #fbf8f6; border: 1px solid var(--border); border-bottom: none;
  border-radius: 8px 8px 0 0; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  flex: 0 0 auto;
}
.tab:hover { background: #fff; color: var(--text); }
.tab.active { background: #fff; color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }
.tab.pinned { background: #fff; border-color: var(--primary-light); }
.tab .tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .tab-pin {
  border: none; background: none; cursor: pointer; font-size: 11px; line-height: 1;
  padding: 0; flex: 0 0 auto; opacity: 0.3; filter: grayscale(1);
  transition: opacity .12s, filter .12s;
}
.tab:hover .tab-pin { opacity: 0.7; }
.tab.pinned .tab-pin { opacity: 1; filter: none; }
.tab .tab-close {
  border: none; background: none; cursor: pointer; font-size: 15px; line-height: 1;
  color: var(--muted); padding: 0 2px; border-radius: 4px; flex: 0 0 auto;
}
.tab .tab-close:hover { background: rgba(0,0,0,0.08); color: var(--danger, #b91c1c); }
.tab-clear {
  position: sticky; right: 0; margin-left: auto; align-self: center; flex: 0 0 auto;
  margin-bottom: 6px; padding: 5px 10px;
  border: 1px solid var(--border); background: #f3ece8; color: var(--muted);
  border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: -8px 0 8px -6px rgba(0,0,0,0.12);
}
.tab-clear:hover { background: #fff; color: var(--primary); border-color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--primary);
  color: white;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 6px 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Container */
.container { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }
body.with-nav .footer { margin-left: 0; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }
.page-subtitle { color: var(--muted); margin: 2px 0 0; font-size: 13px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 6px; font-family: 'Playfair Display', serif; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-accent { color: var(--primary); }

/* Filter row */
.toolbar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar .search {
  flex: 1; min-width: 220px;
}

/* Forms */
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.12);
}
.textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }

/* Searchable dropdown (wraps native <select>) */
.ss-trigger {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s;
}
.ss-trigger:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.12); }
.ss-trigger .ss-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-trigger .ss-ph { color: var(--muted, #998); }
.ss-trigger .ss-caret { color: var(--muted, #998); font-size: 11px; flex: 0 0 auto; }
.ss-pop {
  position: fixed; z-index: 100000;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  overflow: hidden;
}
.ss-pop .ss-search {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; border: 0; border-bottom: 1px solid var(--border);
  font-size: 14px; font-family: inherit; outline: none; background: var(--surface, #fff); color: var(--text);
}
.ss-pop .ss-list { max-height: 260px; overflow-y: auto; }
.ss-pop .ss-item { padding: 8px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-pop .ss-item:hover { background: var(--primary-light, #fdf2f6); }
.ss-pop .ss-item.ss-active { background: var(--primary); color: #fff; }
.ss-pop .ss-item.ss-add { color: var(--primary); font-weight: 600; border-top: 1px solid var(--border); }
.ss-pop .ss-item.ss-add.ss-active { color: #fff; }
.ss-pop .ss-empty { padding: 10px 12px; color: var(--muted, #998); font-size: 13px; }
.field label, .label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text); text-transform: uppercase; letter-spacing: 0.4px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.help-text { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fcfaf6; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 0 0 6px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #eef2ff;
  color: #4338ca;
}
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-dispatched { background: #e0e7ff; color: #4338ca; }
.badge-delivered  { background: #dcfce7; color: #166534; }
.badge-completed  { background: #dcfce7; color: #166534; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }
.badge-low        { background: #fee2e2; color: #991b1b; }
.badge-ok         { background: #dcfce7; color: #166534; }

/* Catalog chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 14px;
  background: #fff5f7; border: 1px solid var(--border);
  border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--text);
}
.chip-btn {
  border: none; background: transparent; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; line-height: 1;
}
.chip-btn:hover { background: rgba(159,18,57,0.1); color: var(--primary); }

/* Hide certain UI in the printable order view */
@media print {
  .no-print { display: none !important; }
}

/* Status filter pills (Orders page) */
.status-pill {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
  font-family: inherit;
  line-height: 1.4;
}
.status-pill:hover { border-color: var(--primary); color: var(--primary); }
.status-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.status-pill-clear {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  font-family: inherit;
}
.status-pill-clear:hover { color: var(--primary); }

/* Auth screens (login / setup) */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}

/* ── Setup screen (simple centered card) ── */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  max-width: 420px;
  width: 100%;
}
.auth-card h2 {
  margin: 0 0 6px;
  font-family: 'Playfair Display', serif;
  color: var(--primary);
}
.auth-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-error {
  color: #991b1b; font-size: 13px; min-height: 0; margin: 0;
  padding: 9px 12px; background: #fef2f2;
  border-radius: 8px; border-left: 3px solid #ef4444;
  display: none;
}
.auth-error:not(:empty) { display: block; margin: 4px 0 8px; }

/* ── Login screen (split layout) ── */
.auth-shell--login {
  padding: 0;
  background: #1a0810;
}
.auth-split {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Left brand panel */
.auth-brand-panel {
  flex: 1.1;
  background: linear-gradient(145deg, #9f1239 0%, #7a0e2c 45%, #3d0616 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 52px;
  position: relative;
  overflow: hidden;
}
.auth-brand-panel::before {
  content: '';
  position: absolute; top: -120px; right: -120px;
  width: 380px; height: 380px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.auth-brand-panel::after {
  content: '';
  position: absolute; bottom: -80px; left: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.auth-brand-deco {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
}
.auth-brand-deco--3 { width: 180px; height: 180px; top: 40%; right: -40px; }
.auth-brand-deco--4 { width: 100px; height: 100px; top: 20%; left: 20px; }

.auth-brand-inner { position: relative; z-index: 1; }

.auth-logo-box {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  font-family: 'Playfair Display', serif;
  margin-bottom: 28px;
  backdrop-filter: blur(10px);
}
.auth-brand-title {
  font-size: 34px; font-weight: 700;
  color: #fff;
  font-family: 'Playfair Display', serif;
  margin: 0 0 8px; line-height: 1.2;
}
.auth-brand-tagline {
  font-size: 15px; color: rgba(255,255,255,0.65);
  margin: 0 0 44px; font-weight: 400;
}
.auth-feature-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.auth-feature-list li {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,0.85); font-size: 14.5px;
}
.auth-feature-list li svg {
  width: 18px; height: 18px; min-width: 18px;
  color: rgba(255,255,255,0.6);
}
.auth-brand-footer {
  position: absolute; bottom: 32px; left: 52px; right: 52px;
  font-size: 12px; color: rgba(255,255,255,0.35);
  z-index: 1;
}

/* Right form panel */
.auth-form-panel {
  flex: 0.9;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 52px;
}
.auth-form-inner { width: 100%; max-width: 360px; }

.auth-form-header { margin-bottom: 32px; }
.auth-form-header h2 {
  font-size: 28px; font-weight: 700;
  color: #111827;
  font-family: 'Playfair Display', serif;
  margin: 0 0 6px;
}
.auth-form-header .auth-sub {
  font-size: 14px; color: #6b7280; margin: 0;
}

/* Fields */
.auth-field { margin-bottom: 18px; }
.auth-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #374151; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.auth-field-hint {
  font-size: 11.5px; color: #9ca3af; margin: 5px 0 0;
}
.auth-input-group {
  position: relative;
}
.auth-input-group .input {
  width: 100%; box-sizing: border-box;
  padding: 11px 16px 11px 42px;
  border: 1.5px solid #e5e7eb; border-radius: 10px;
  font-size: 14.5px; color: #111827;
  background: #f9fafb;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-input-group .input:focus {
  outline: none; border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(159,18,57,0.1);
}
.auth-input-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: #9ca3af; pointer-events: none;
}
.auth-pwd-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; cursor: pointer;
  color: #9ca3af; display: flex; align-items: center;
  transition: color 0.15s;
}
.auth-pwd-toggle:hover { color: var(--primary); }

/* Submit button */
.auth-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #9f1239 0%, #7a0e2c 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin-top: 6px; letter-spacing: 0.2px;
}
.auth-btn:hover {
  background: linear-gradient(135deg, #be1144 0%, #9f1239 100%);
  box-shadow: 0 6px 20px rgba(159,18,57,0.35);
  transform: translateY(-1px);
}
.auth-btn:active { transform: translateY(0); box-shadow: none; }
.auth-btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

/* Divider */
.auth-divider {
  text-align: center; font-size: 12px; color: #9ca3af;
  margin: 20px 0 0; padding-top: 20px;
  border-top: 1px solid #f3f4f6;
}

/* Responsive */
@media (max-width: 800px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 40px 28px; }
  .auth-shell--login { background: #fff; }
}
@media (max-width: 400px) {
  .auth-form-panel { padding: 28px 20px; }

/* Top-bar user chip (now the profile-menu trigger button) */
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: #fff5f7;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; cursor: pointer; font-family: inherit;
}
.user-chip:hover { border-color: var(--primary); }
.user-chip .chevron { font-size: 11px; color: var(--muted); transition: transform 0.15s; }
.profile-menu.open .user-chip .chevron { transform: rotate(180deg); }
.user-chip .user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.user-chip .user-icon { font-size: 14px; }
.user-chip .user-role {
  background: var(--primary); color: white;
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
}

/* Color swatch — used in resolved order lines */
.color-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.color-swatch-lg { width: 24px; height: 24px; }

/* Chart tabs — picker for switching between charts */
.chart-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Dropdown picker — replaces the pill row when the list could get long */
.chart-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 6px 10px 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.chart-picker-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: var(--muted);
}
.chart-picker-select {
  min-width: 220px;
  max-width: 360px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 4px 28px 4px 6px;
  cursor: pointer;
}
.chart-picker-select:focus { outline: none; box-shadow: none; }
.chart-tab {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: all .15s;
}
.chart-tab:hover { border-color: var(--primary); color: var(--primary); }
.chart-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.chart-tab-count {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.chart-tab.active .chart-tab-count { background: rgba(255, 255, 255, 0.25); }

/* Catalog-style color chart display (Charts page) */
.color-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.color-catalog-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.color-catalog-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.color-catalog-swatch {
  position: relative;
  height: 90px;
  width: 100%;
}
.color-catalog-number {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  min-width: 28px;
  text-align: center;
}
.color-catalog-name {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  border-top: 1px solid var(--border);
  background: #fafafa;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-catalog-stock {
  padding: 5px 10px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
  color: #166534;
  background: #f0fdf4;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.color-catalog-stock:hover { background: #dcfce7; }
.color-catalog-stock.low  { color: #92400e; background: #fef3c7; }
.color-catalog-stock.low:hover  { background: #fde68a; }
.color-catalog-stock.zero { color: #991b1b; background: #fee2e2; }
.color-catalog-stock.zero:hover { background: #fecaca; }
.color-catalog-stock.over { color: #fff; background: #6c0518; font-weight: 700; }
.color-catalog-stock.over:hover { background: #4a0410; }

/* Activity log badge */
.badge.activity-action {
  background: #f3f4f6; color: #374151;
  font-family: monospace; font-size: 11px;
  text-transform: none; letter-spacing: 0;
}

/* Product card grid */
.product-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(31,27,22,0.08); }
.product-img {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #fef3c7 0%, #fce7f3 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  overflow: hidden;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.product-code { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.product-name { font-weight: 600; margin: 4px 0; }
.product-meta { font-size: 12px; color: var(--muted); }
.product-price { font-size: 16px; font-weight: 700; color: var(--primary); margin-top: 6px; }
.product-actions { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); }
.product-actions .btn { flex: 1; justify-content: center; }

/* Modal */
.modal-layer { position: relative; z-index: 100; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(31, 27, 22, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: inherit;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-lg { max-width: 880px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: #fcfaf6;
  position: sticky; bottom: 0;
}
.modal-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; color: var(--muted); padding: 0 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--text);
  color: white;
  border-radius: 8px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Order items table inside modal */
.order-items-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.order-items-table th, .order-items-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.order-items-table th { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; text-align: left; }
.order-items-table input, .order-items-table select { padding: 6px 8px; font-size: 13px; }
.order-items-table .num { text-align: right; }

.summary {
  margin-top: 12px;
  border-top: 2px solid var(--border);
  padding-top: 10px;
}
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.summary-row.total { font-size: 17px; font-weight: 700; color: var(--primary); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* Reports */
.chart-card { padding: 18px; }
.chart-card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.charts-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); margin-top: 16px; }

/* Role view restriction */
body[data-role="party"] [data-role-staff] { display: none !important; }

/* Pipeline cards (clickable) */
.pipe-card { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.pipe-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 6px 16px rgba(159,18,57,0.12); }

/* Financial-year picker + chip */
.year-picker { max-width: 480px; }
.year-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; text-align: left; }
.year-card {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%; padding: 14px 16px; border: 1px solid var(--border, #e6ddd2);
  border-radius: 10px; background: #fff; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.year-card:hover { border-color: var(--primary, #9a3b2e); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.year-card:focus, .year-card:focus-within { border-color: var(--primary, #9a3b2e); box-shadow: 0 0 0 3px rgba(154,59,46,.18); outline: none; }
.firm-open:focus { outline: none; }
.year-card-active { border-color: var(--primary, #9a3b2e); background: #faf6f3; }
.year-card-fy { font-weight: 700; font-size: 16px; }
.year-card-sub { font-size: 12px; color: var(--muted, #8a7f72); margin-top: 2px; }
.year-card-side { text-align: right; }
.year-card-out { font-weight: 700; color: #991b1b; }
.year-card-out-lbl { font-size: 11px; color: var(--muted, #8a7f72); }
.year-card-badge {
  position: absolute; top: -8px; right: 12px; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; background: var(--primary, #9a3b2e); color: #fff; padding: 2px 8px; border-radius: 999px;
}
/* Profile dropdown — company / year / backup / restore / logout, all under the user chip */
.profile-menu { position: relative; }
.profile-dropdown {
  display: none;
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  min-width: 240px; z-index: 1200;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
  padding: 6px; flex-direction: column; gap: 2px;
}
.profile-menu.open .profile-dropdown { display: flex; }
.profile-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 12px; border: none; background: none; border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; white-space: nowrap;
}
.profile-item:hover { background: var(--primary-light); color: var(--primary); }
.profile-item b { font-weight: 700; }
.profile-chip-row b { color: var(--primary, #9a3b2e); }
.profile-item-danger { color: var(--danger, #b91c1c); }
.profile-item-danger:hover { background: #fee2e2; color: var(--danger, #b91c1c); }
.profile-divider { height: 1px; background: var(--border); margin: 4px 6px; }
.firm-chip, .year-chip { width: 100%; }

/* In-tab print preview overlay (printPreview) */
.print-preview-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: #525659; display: flex; flex-direction: column;
}
.print-preview-overlay .pp-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: #323639; color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3); flex: 0 0 auto;
}
.print-preview-overlay .pp-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.print-preview-overlay .pp-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.print-preview-overlay .pp-body { flex: 1 1 auto; overflow: auto; padding: 18px; display: flex; justify-content: center; }
.print-preview-overlay .pp-frame {
  width: 210mm; max-width: 100%; min-height: 100%; border: none;
  background: #fff; box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

/* Responsive */
@media (max-width: 900px) {
  /* Let the top bar scroll away with the page on small screens (avoids a tall
     wrapped fixed header eating vertical space) and wrap the menu items. */
  .topbar { position: static; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .nav { order: 3; width: 100%; }
  .topbar-actions { order: 2; margin-left: auto; }
  /* Top bar scrolls away on small screens, so the tab bar shouldn't stay pinned. */
  .tab-bar { position: static; top: auto; }
  .container { padding: 16px 14px 40px; }
  .stat-value { font-size: 22px; }
  .print-preview-overlay .pp-bar { flex-wrap: wrap; }
  .print-preview-overlay .pp-body { padding: 0; }
  .print-preview-overlay .pp-frame { width: 100%; }
}
