:root, [data-theme="dark"] {
  --void: #070a0f;
  --panel: #10161f;
  --panel-2: #161e29;
  --border: rgba(255,255,255,0.09);
  --text: #eef1f5;
  --muted: #8b94a3;
  --accent: #c9a87c;
  --accent-dim: rgba(201,168,124,0.14);
  --danger: #e07a7a;
  --ok: #7dcea0;
  --info: #7aa7e0;
  --radius: 14px;
  --font: 'Jost', system-ui, sans-serif;
  --display: 'Marcellus', Georgia, serif;
  --shadow: 0 8px 28px rgba(0,0,0,0.35);
  --input-bg: #161e29;
}
[data-theme="light"] {
  --void: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: rgba(15,23,42,0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #9a7b4f;
  --accent-dim: rgba(154,123,79,0.12);
  --danger: #c44;
  --ok: #2a9d6a;
  --info: #3b7dd8;
  --shadow: 0 8px 24px rgba(15,23,42,0.08);
  --input-bg: #f8fafc;
}
* { box-sizing: border-box; }

/* The hidden attribute has to win. A class such as .stack or .search-overlay
   sets display, and any author rule outranks the browser's own
   [hidden]{display:none} — which is why hiding a settings tab or closing the
   search panel appeared to do nothing at all. */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--void); color: var(--text); font-family: var(--font); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.7rem 0.85rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(201,168,124,0.45); }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); }
h1,h2,h3 { font-family: var(--display); font-weight: 400; margin: 0; }
.eyebrow { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 0 0 0.35rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.85rem; }
.ok-msg { color: var(--ok); font-size: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.row { display: flex; align-items: center; }
.row.gap { gap: 0.75rem; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.flex { flex: 1; }
.mt { margin-top: 1rem; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.65rem 1.15rem; border-radius: 999px; font-size: 0.88rem; font-weight: 500;
  transition: 0.2s ease; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: #12100c; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: rgba(201,168,124,0.4); color: var(--accent); }
.btn.sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn.danger { color: var(--danger); border: 1px solid rgba(224,122,122,0.35); border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* Auth pages */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem;
  background: radial-gradient(ellipse at 20% 10%, rgba(201,168,124,0.1), transparent 45%), var(--void);
}
.auth-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 22px; padding: 2rem 2rem 1.5rem;
}
.auth-card h1 { font-size: 1.75rem; margin-bottom: 0.35rem; }
.auth-links { margin-top: 1.25rem; font-size: 0.9rem; color: var(--muted); text-align: center; }
.auth-foot { margin-top: 1.5rem; text-align: center; font-size: 0.78rem; color: var(--muted); }

/* Shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand .mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, #c9a87c, #a88b5c); color: #12100c;
  display: grid; place-items: center; font-family: var(--display); font-size: 0.8rem; font-weight: 400;
}
.brand strong { display: block; font-size: 0.92rem; }
.brand small { color: var(--muted); font-size: 0.72rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav-link {
  text-align: left; padding: 0.7rem 0.9rem; border-radius: 10px;
  color: var(--muted); font-weight: 500; display: block;
}
.nav-link:hover, .nav-link.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-foot { display: flex; flex-direction: column; gap: 0.45rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.sidebar-foot .by { font-size: 0.72rem; color: var(--muted); }

.main { padding: 1.75rem 2rem 4rem; overflow: auto; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.page-head h2 { font-size: 1.85rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.stat strong { display: block; font-family: var(--display); font-size: 1.5rem; margin-bottom: 0.2rem; }
.stat span { color: var(--muted); font-size: 0.8rem; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; margin-bottom: 1rem;
}
.panel h3 { margin-bottom: 0.85rem; font-size: 1.15rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.toolbar { margin-bottom: 1rem; display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { max-width: 280px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.75rem 0.55rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--accent-dim); color: var(--accent);
}
.badge.sent { background: rgba(122,167,224,0.18); color: var(--info); }
.badge.accepted { background: rgba(125,206,160,0.2); color: var(--ok); }
.badge.rejected { background: rgba(224,122,122,0.18); color: var(--danger); }
.badge.low { background: rgba(224,122,122,0.18); color: var(--danger); }

.quote-grid { display: grid; grid-template-columns: 300px 1fr; gap: 1.15rem; align-items: start; }
.line-row {
  display: grid; grid-template-columns: 1.5fr 90px 110px 36px; gap: 0.5rem; align-items: end;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem;
}
.totals { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); display: grid; gap: 0.35rem; }
.totals div { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.92rem; }
.totals .grand { color: var(--text); font-size: 1.1rem; font-weight: 600; }

dialog {
  border: 1px solid var(--border); border-radius: 18px; background: var(--panel); color: var(--text);
  padding: 1.5rem; width: min(500px, 94vw);
}
dialog::backdrop { background: rgba(0,0,0,0.65); }

.app-footer {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--muted); text-align: center;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .quote-grid { grid-template-columns: 1fr; }
  .line-row { grid-template-columns: 1fr 1fr; }
}

/* Print quote */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #111; }
  .print-sheet { box-shadow: none !important; border: none !important; }
}
.print-sheet {
  max-width: 800px; margin: 2rem auto; background: #fff; color: #111;
  padding: 2rem; border-radius: 8px;
}
.print-sheet h1 { color: #111; }
.print-sheet table th, .print-sheet table td { border-bottom: 1px solid #ddd; color: #222; }
.print-sheet .muted { color: #555; }

td .row.gap { flex-wrap: wrap; }
td .btn.sm { padding: 0.35rem 0.65rem; }
.page-head .row.gap { align-items: center; }

.welcome-line {
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 2.85rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text);
  margin: 0;
  background: linear-gradient(120deg, #f0e6d4 0%, var(--accent) 45%, #e8d5b5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Refined sidebar (Claude-style structure) */
.sidebar {
  background: linear-gradient(180deg, #0e141c 0%, #0a0e14 100%);
  width: 260px;
}
.side-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; overflow: auto; }
.nav-section {
  margin: 1rem 0 0.35rem; padding: 0 0.9rem;
  font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.35); font-weight: 500;
}
.nav-section:first-child { margin-top: 0.25rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.62rem 0.9rem; border-radius: 10px;
  color: rgba(255,255,255,0.55); font-weight: 500; font-size: 0.9rem;
  transition: 0.15s ease;
}
.nav-link .nav-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.2); flex-shrink: 0;
}
.nav-link:hover { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.85); }
.nav-link.active {
  background: var(--accent-dim); color: var(--accent);
}
.nav-link.active .nav-dot { background: var(--accent); }
.user-chip {
  display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.55rem;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 600;
}
.user-chip strong { display: block; font-size: 0.85rem; }
.user-chip small { color: var(--muted); font-size: 0.7rem; }
.shell { grid-template-columns: 260px 1fr; }
.main { background: radial-gradient(ellipse at 80% 0%, rgba(201,168,124,0.04), transparent 45%); }
.panel { box-shadow: 0 1px 0 rgba(255,255,255,0.03); }
.stat { transition: border-color 0.2s; }
.stat:hover { border-color: rgba(201,168,124,0.25); }


/* Desktop: section labels + stacked links */
.nav-group { display: flex; flex-direction: column; gap: 0.12rem; }
.nav-drop-btn {
  display: none;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.85rem 0.9rem 0.3rem;
  font-weight: 500;
  cursor: pointer;
}
.nav-drop { display: flex; flex-direction: column; gap: 0.12rem; }
.nav-toggle { display: none; }
/* display:contents keeps the desktop sidebar laid out exactly as before —
   the wrapper only becomes a real panel inside the mobile media query. */
.nav-drawer { display: contents; }
.nav-backdrop { display: none; }

/* Mobile: top bar + dropdown menus */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }
  .sidebar {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: #0c1118;
  }
  /* .sidebar prefix so this beats the later ".sidebar-top { display: block }" */
  .sidebar .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  .sidebar .brand { min-width: 0; }
  .sidebar .brand strong { white-space: nowrap; }
  /* Hamburger: three bars that fold into a cross when the panel is open */
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 0 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    flex-shrink: 0;
  }
  .nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    border-radius: 2px;
    background: var(--text);
    transition: transform 0.25s ease, opacity 0.2s ease;
    transform-origin: center;
  }
  .nav-toggle.open {
    border-color: rgba(201,168,124,0.45);
    background: var(--accent-dim);
  }
  .nav-toggle.open span { background: var(--accent); }
  .nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { opacity: 0; }
  .nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* The panel itself */
  .nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 70;
    background: linear-gradient(180deg, #0e141c 0%, #0a0e14 100%);
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 40px rgba(0,0,0,0.45);
    padding: 1.1rem 0.9rem 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
  }
  .nav-drawer.open {
    transform: translateX(0);
    visibility: visible;
  }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s;
  }
  .nav-backdrop.open { opacity: 1; visibility: visible; }

  /* Every link is visible inside the panel — the headings are just labels.
     Scoped to .nav-drawer so it outranks the older ".sidebar nav" rule that
     turns the nav into a wrapping row below 960px. */
  .nav-drawer .side-nav {
    display: flex !important;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.1rem;
    flex: 1 0 auto;
    overflow: visible;
  }
  .nav-drawer .nav-group { display: flex; flex-direction: column; width: 100%; }
  .nav-drop { display: flex !important; flex-direction: column; gap: 0.12rem; }
  .nav-drop-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: default;
    pointer-events: none;
    color: rgba(255,255,255,0.4);
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 1rem 0.9rem 0.35rem;
  }
  .nav-link {
    padding: 0.72rem 0.9rem;
    font-size: 0.95rem;
    border-radius: 10px;
  }
  .sidebar-foot {
    display: flex;
    margin-top: 1rem;
  }
  .main { padding: 1rem 1rem 3rem; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .page-head h2 { font-size: 1.4rem; }
  .welcome-line { font-size: 1.55rem !important; }
  .stats { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .stat strong { font-size: 1.15rem; }
  .grid-2, .quote-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select { max-width: none; width: 100%; }
  table { font-size: 0.82rem; }
  th, td { padding: 0.5rem 0.3rem; }
  .line-row { grid-template-columns: 1fr 1fr !important; }
  dialog { width: min(96vw, 500px); }
  .btn { min-height: 40px; }
  .auth-page { grid-template-columns: 1fr !important; }
  .auth-visual { display: none !important; }
  .page-head .row.gap { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .page-head .btn { width: 100%; justify-content: center; }
}

/* Desktop brand row */
.sidebar-top { display: block; }
@media (min-width: 901px) {
  .sidebar-top { padding: 0; }
  .nav-toggle { display: none !important; }
  .nav-drawer { display: contents !important; }
  .nav-backdrop { display: none !important; }
  .side-nav { display: flex !important; }
  .nav-drop { display: flex !important; }
  .nav-drop-btn {
    display: block;
    pointer-events: none;
    cursor: default;
  }
}

/* ===== Theme tokens ===== */
:root, [data-theme="dark"] {
  --void: #070a0f;
  --panel: #10161f;
  --panel-2: #161e29;
  --border: rgba(255,255,255,0.09);
  --text: #eef1f5;
  --muted: #8b94a3;
  --accent: #c9a87c;
  --accent-dim: rgba(201,168,124,0.14);
  --danger: #e07a7a;
  --ok: #7dcea0;
  --info: #7aa7e0;
  --shadow: 0 8px 28px rgba(0,0,0,0.35);
  --input-bg: #161e29;
}
[data-theme="light"] {
  --void: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: rgba(15,23,42,0.1);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #9a7b4f;
  --accent-dim: rgba(154,123,79,0.12);
  --danger: #c44;
  --ok: #2a9d6a;
  --info: #3b7dd8;
  --shadow: 0 8px 24px rgba(15,23,42,0.08);
  --input-bg: #f8fafc;
}
html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  background: var(--void);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
input, select, textarea {
  background: var(--input-bg) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
.panel, .stat, .auth-card, dialog {
  background: var(--panel);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.sidebar {
  background: var(--panel) !important;
  border-color: var(--border);
}
[data-theme="light"] .sidebar {
  background: #fff !important;
}
[data-theme="light"] .nav-link { color: #64748b; }
[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active { color: var(--accent); background: var(--accent-dim); }
[data-theme="light"] .nav-drop-btn { color: #94a3b8; }
[data-theme="light"] .brand strong { color: #0f172a; }
[data-theme="light"] .user-chip strong { color: #0f172a; }
[data-theme="light"] .welcome-line {
  background: linear-gradient(120deg, #5c4a32, #9a7b4f, #c4a574);
  -webkit-background-clip: text;
  background-clip: text;
}
.btn.primary { box-shadow: 0 2px 8px rgba(201,168,124,0.25); }
.btn.ghost:hover { background: var(--accent-dim); }
.table-wrap table tr:hover td { background: var(--accent-dim); }
.main {
  background: radial-gradient(ellipse at 80% 0%, rgba(201,168,124,0.05), transparent 42%), var(--void);
}
[data-theme="light"] .main {
  background: radial-gradient(ellipse at 80% 0%, rgba(154,123,79,0.06), transparent 42%), var(--void);
}
.page-head h2 { letter-spacing: -0.01em; }
.stat { border-radius: 16px; }
.panel { border-radius: 16px; }
.badge { font-weight: 500; }
.app-footer { opacity: 0.85; }

/* ---------- What's new panel ---------- */
.wn-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 1.25rem;
  background: rgba(4, 7, 11, 0.66);
  opacity: 0; transition: opacity 0.18s ease;
  overflow-y: auto;
}
.wn-overlay.show { opacity: 1; }
.wn-card {
  position: relative;
  width: min(640px, 100%);
  max-height: min(86vh, 780px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  transform: translateY(10px) scale(0.99);
  transition: transform 0.18s ease;
  overflow: hidden;
}
.wn-overlay.show .wn-card { transform: none; }
.wn-close {
  position: absolute; top: 0.75rem; right: 0.9rem;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(255,255,255,0.04);
  color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.wn-close:hover { color: var(--text); }
.wn-head { padding: 1.5rem 1.6rem 0.9rem; border-bottom: 1px solid var(--border); }
.wn-eyebrow {
  margin: 0 0 0.35rem; font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.wn-head h2 { margin: 0; font-size: 1.35rem; }
.wn-intro { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.wn-body { padding: 0.4rem 1.6rem 1rem; overflow-y: auto; }
.wn-item {
  display: grid; grid-template-columns: 1fr; gap: 0.75rem;
  padding: 1.1rem 0; border-bottom: 1px solid var(--border);
}
.wn-item:last-child { border-bottom: none; }
.wn-item img {
  width: 100%; border-radius: 12px; border: 1px solid var(--border);
  background: #0a0e14; display: block;
}
.wn-item h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.wn-item p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.6; }
.wn-foot {
  padding: 0.9rem 1.6rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
@media (max-width: 900px) {
  .wn-overlay { padding: 0.75rem; }
  .wn-card { max-height: 92vh; border-radius: 14px; }
  .wn-head { padding: 1.25rem 1.1rem 0.8rem; }
  .wn-head h2 { font-size: 1.15rem; }
  .wn-body { padding: 0.3rem 1.1rem 0.8rem; }
  .wn-foot { padding: 0.8rem 1.1rem 1rem; }
  .wn-foot .btn { width: 100%; justify-content: center; }
}

/* Per-line "include data sheet link" tick on quotations and invoices */
.ds-toggle {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--muted);
}
.ds-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.ds-toggle .ds-label { user-select: none; }
.ds-toggle:hover { color: var(--text); }

/* ===========================================================================
   Toasts — a short message in the corner instead of the browser's alert box.
   =========================================================================== */
.toast-host {
  position: fixed; z-index: 200; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  max-width: min(380px, calc(100vw - 36px));
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border); border-left: 3px solid var(--ok);
  border-radius: 10px; background: var(--panel); color: var(--text);
  box-shadow: var(--shadow); font-size: 0.9rem; line-height: 1.4;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }
@media (max-width: 640px) {
  .toast-host { right: 12px; left: 12px; bottom: 12px; align-items: stretch; }
}

/* ===========================================================================
   Global search (Ctrl+K)
   =========================================================================== */
.side-search {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  margin: 0 0 0.75rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); color: var(--muted);
  font: inherit; font-size: 0.86rem; cursor: pointer; text-align: left;
}
.side-search:hover { border-color: rgba(201,168,124,0.4); color: var(--accent); }
.side-search-icon { font-size: 1.05rem; line-height: 1; }
.side-search kbd {
  margin-left: auto; font: inherit; font-size: 0.68rem; letter-spacing: 0.04em;
  padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted);
}
body.search-open { overflow: hidden; }
.search-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4,7,11,0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
}
.search-panel {
  width: min(680px, 100%); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.search-bar {
  display: flex; align-items: center; gap: 0.4rem;
  border-bottom: 1px solid var(--border); padding-right: 0.5rem;
}
.search-panel input {
  flex: 1; min-width: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--text);
  padding: 1rem 0.4rem 1rem 1.15rem; font: inherit; font-size: 1.02rem; outline: none;
}
/* Always visible, so there is a way out on a phone too. */
.search-close {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
  font: inherit; font-size: 1.35rem; line-height: 1; cursor: pointer;
}
.search-close:hover { color: var(--text); border-color: rgba(201,168,124,0.4); }
.search-panel input::placeholder { color: var(--muted); }
.search-results { overflow-y: auto; padding: 0.4rem; }
.search-empty { margin: 0; padding: 1.4rem 1rem; color: var(--muted); text-align: center; font-size: 0.9rem; }
.search-hit {
  display: flex; gap: 0.75rem; align-items: baseline;
  padding: 0.55rem 0.75rem; border-radius: 9px;
  color: var(--text); text-decoration: none;
}
.search-hit.on { background: var(--accent-dim); }
.hit-kind {
  flex: 0 0 auto; min-width: 92px;
  font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.hit-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hit-main strong { font-weight: 600; font-size: 0.94rem; }
.hit-main small { color: var(--muted); font-size: 0.78rem; }
.search-hint {
  border-top: 1px solid var(--border); padding: 0.5rem 1rem;
  color: var(--muted); font-size: 0.72rem; letter-spacing: 0.03em;
}
@media (max-width: 640px) {
  .search-overlay { padding: 6vh 10px 10px; }
  .hit-kind { min-width: 0; }
  .search-hit { flex-direction: column; gap: 2px; }
  .search-hint { display: none; }
}

/* A button that is doing something says so, and cannot be pressed twice. */
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--text); animation: hms-spin 0.7s linear infinite;
}
.btn.primary.busy::after { color: #12100c; }
@keyframes hms-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.busy::after { animation-duration: 2s; }
  .toast { transition: none; }
}

/* Whether a document is following the standard note or has wording of its own */
.note-state {
  margin: -0.35rem 0 0.2rem; font-size: 0.75rem; line-height: 1.45; color: var(--muted);
}
.note-state.custom { color: var(--accent); }
.note-state a { text-decoration: underline; }

/* ===========================================================================
   Tabs and sections — used by Settings
   =========================================================================== */
.tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 1rem; padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}
.tabs .tab {
  font: inherit; font-size: 0.88rem;
  padding: 0.45rem 0.9rem; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.on { background: var(--accent-dim); border-color: rgba(201,168,124,0.35); color: var(--accent); }

/* A titled group inside a panel. */
.sec { margin: 0.5rem 0 0.1rem; }
.sec:first-child { margin-top: 0; }
.sec h3 { margin: 0; font-size: 1rem; }
.sec-note { margin: 0.2rem 0 0; font-size: 0.78rem; line-height: 1.5; color: var(--muted); }
.sm-note { font-size: 0.76rem; margin: -0.3rem 0 0; }

.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  margin-top: 1rem; padding: 0.85rem 0;
  background: linear-gradient(to top, var(--void) 62%, transparent);
}
.save-bar .ok-msg, .save-bar .error { margin: 0; }

/* Money columns line up digit for digit and read right-aligned, as on paper. */
td.num, th.num {
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   Loading, empty states, and the Undo button on a toast
   =========================================================================== */

/* Grey bars in the shape of the table that is coming, so the page has its
   layout from the first moment instead of jumping when the data lands. */
.skeleton { padding: 0.35rem 0; }
.sk-row {
  display: flex; gap: 1.2rem; align-items: center;
  padding: 0.85rem 0.2rem; border-bottom: 1px solid var(--border);
}
.sk-row:last-child { border-bottom: 0; }
.sk-bar {
  flex: 1; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg,
    var(--panel-2) 25%, rgba(201,168,124,0.13) 50%, var(--panel-2) 75%);
  background-size: 300% 100%;
  animation: sk-sweep 1.4s ease-in-out infinite;
}
@keyframes sk-sweep {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk-bar { animation: none; background: var(--panel-2); }
}

/* A page with nothing on it yet should say so properly. */
.empty { padding: 2.4rem 1.2rem; text-align: center; }
.empty-title { margin: 0 0 0.4rem; font-family: var(--display); font-size: 1.15rem; color: var(--text); }
.empty .muted { margin: 0 auto; max-width: 48ch; font-size: 0.88rem; line-height: 1.55; }
.empty .btn { margin-top: 1rem; }

.toast { display: flex; align-items: center; gap: 0.85rem; }
.toast-action {
  flex: 0 0 auto; font: inherit; font-size: 0.82rem; font-weight: 600;
  padding: 0.3rem 0.7rem; border-radius: 7px; cursor: pointer;
  border: 1px solid rgba(201,168,124,0.4); background: var(--accent-dim); color: var(--accent);
}
.toast-action:hover { background: var(--accent); color: #12100c; }
.sk-stat { display: flex; flex-direction: column; gap: 0.6rem; justify-content: center; }
.sk-stat .sk-bar { height: 20px; width: 62%; flex: 0 0 auto; }
.sk-stat .sk-bar.short { height: 10px; width: 40%; }
