/* The Creative RoboTech Store: accounting system styles */

:root {
  --primary: #2357c6;
  --primary-600: #1c47a3;
  --primary-50: #eef3fd;
  --primary-100: #dce7fb;
  --accent: #f59e0b;

  --side-bg: #0f1d36;
  --side-bg-2: #13284a;
  --side-text: #aebbd3;
  --side-muted: #6b7fa3;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e3e8f0;
  --border-strong: #cdd5e1;
  --zebra: #f8fafc;

  --rfq: #7c3aed;   --rfq-bg: #f3eefe;
  --inv: #2563eb;   --inv-bg: #e9f0fe;
  --rct: #059669;   --rct-bg: #e5f6ef;
  --dn: #0e7490;    --dn-bg: #e0f3f7;

  --success: #047857; --success-bg: #e6f6ee; --success-border: #b6e3cb;
  --warn: #a16207;    --warn-bg: #fef6dc;    --warn-border: #f5dd94;
  --danger: #c0262d;  --danger-bg: #fdeced;  --danger-border: #f6c4c6;
  --info: #1d4ed8;    --info-bg: #eaf1fe;    --info-border: #c6d8fb;

  --paper-brand: #1f4e79;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --ring: 0 0 0 3px rgba(35, 87, 198, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .9rem; letter-spacing: -.005em; }
h1 .muted { font-weight: 500; font-size: 1.1rem; }
h1 .badge { vertical-align: middle; margin-left: .35rem; }
code { background: var(--zebra); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.req { color: var(--danger); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.center { text-align: center; margin-top: 1rem; }
.hint { display: flex; gap: .4rem; align-items: flex-start; color: var(--muted); font-size: .84rem; font-weight: 400; margin: .3rem 0 .9rem; }
.hint .icon { flex: none; margin-top: .15rem; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }

/* ------------------------------------------------------------------ App shell */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .5rem;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text); padding: 1.1rem .85rem;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: .35rem .5rem 1.1rem; color: #fff; text-decoration: none !important; }
.brand-mark {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.brand-mark img { width: 70%; height: 70%; object-fit: contain; display: block; }
.brand-mark.sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 18px; }
.auth-logo { display: block; width: 210px; max-width: 70%; margin-bottom: 1.75rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .98rem; }
.brand-text small { color: var(--side-muted); font-size: .76rem; margin-top: 2px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--side-muted); font-weight: 700; padding: 1.1rem .75rem .4rem; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem; border-radius: 9px; color: var(--side-text); font-weight: 500;
  text-decoration: none !important; transition: background .15s, color .15s;
}
.nav-link .icon { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: rgba(59, 116, 230, .22); color: #fff; }
.nav-link.active::before {
  content: ""; position: absolute; left: -.85rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-link.active .icon { opacity: 1; color: #8fb2ff; }

.sidebar-user {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .6rem; margin-top: .5rem;
  border-radius: 11px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-user form { margin: 0; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), #f97316); color: #fff; font-weight: 700; font-size: .8rem;
}
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.who strong { color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--side-muted); font-size: .74rem; }
.sidebar .icon-btn { color: var(--side-text); }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--zebra); color: var(--text); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

.main { min-width: 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 2.25rem 3.5rem; }
.mobile-bar { display: none; }
.scrim { display: none; }

/* ------------------------------------------------------------------ Page headers */
.page-title, .page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 1.5rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head h1 + .muted, .page-title h1 + .muted { margin: .3rem 0 0; }
.page-title .muted, .page-head .muted { margin: .3rem 0 0; }
.eyebrow { margin: 0 0 .3rem; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.title-with-icon { display: flex; align-items: center; gap: 1rem; }
.title-icon {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; flex: none;
}
.title-icon .icon { width: 26px; height: 26px; }
.tone-rfq { background: var(--rfq-bg); color: var(--rfq); }
.tone-inv { background: var(--inv-bg); color: var(--inv); }
.tone-rct { background: var(--rct-bg); color: var(--rct); }
.tone-dn { background: var(--dn-bg); color: var(--dn); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm);
}
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; }
.card-head h2 { margin: 0; }
.narrow { max-width: 580px; }
.link-arrow { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .88rem; }
.plain-list { margin: 0; padding-left: 1.1rem; }
.plain-list li { margin: .3rem 0; }

/* ------------------------------------------------------------------ Forms */
label { display: block; font-weight: 600; font-size: .84rem; color: var(--text-2); margin-bottom: 1rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .58rem .75rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff;
  font: inherit; font-weight: 400; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #9aa6b8; }
input:hover, select:hover, textarea:hover { border-color: #b4bfcf; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; padding-bottom: .35rem; }
.filters label { flex: 1 1 150px; }
.filters .search-field, .filters label:first-child { flex: 3 1 260px; }
.filter-actions { display: flex; gap: .5rem; margin-bottom: 1rem; }
.input-icon { position: relative; display: block; }
.input-icon .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-30%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.3rem; }
.inline-form { display: flex; gap: .4rem; margin-top: .45rem; }
.inline-form input { margin: 0; min-width: 180px; }
.stack-form { display: grid; gap: .45rem; margin-top: .45rem; min-width: 230px; }
.stack-form input, .stack-form select { margin: 0; }
.auth-form { margin-top: 1.5rem; }

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: .88rem; line-height: 1.3;
  text-decoration: none !important; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: #aab6c8; background: var(--zebra); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(35, 87, 198, .3); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a31f25; border-color: #a31f25; }
.btn-gmail { color: #c5221f; border-color: #f2c4c1; }
.btn-gmail:hover { background: #fdecea; border-color: #c5221f; }
.email-hint { display: flex; align-items: flex-start; gap: .65rem; padding: .8rem 1rem; margin-bottom: 1.1rem; border-radius: var(--radius-sm);
  background: var(--success-bg); border: 1px solid var(--success-border); color: #065f46; font-size: .9rem; }
.email-hint[hidden] { display: none; }
.email-hint > span { flex: 1; }
.btn-danger-ghost { color: var(--danger); border-color: var(--danger-border); }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); border-color: transparent; }
.btn-small { padding: .32rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.2rem; font-size: .95rem; }
.btn-block { width: 100%; margin-top: .5rem; }
.btn-dashed {
  width: 100%; margin-top: .75rem; border-style: dashed; background: var(--zebra); color: var(--primary); box-shadow: none;
}
.btn-dashed:hover { background: var(--primary-50); border-color: var(--primary); }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }

/* ------------------------------------------------------------------ Messages */
.flash {
  display: flex; align-items: flex-start; gap: .65rem; padding: .8rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1.1rem; border: 1px solid transparent; font-size: .9rem; transition: opacity .25s, transform .25s;
}
.flash > span { flex: 1; }
.flash-icon { width: 18px; height: 18px; margin-top: 1px; }
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: #065f46; }
.flash-error { background: var(--danger-bg); border-color: var(--danger-border); color: #8f1d22; }
.flash-info { background: var(--info-bg); border-color: var(--info-border); color: #1e3a8a; }
.flash-close { border: 0; background: transparent; color: inherit; opacity: .6; cursor: pointer; padding: 2px; display: grid; }
.flash-close:hover { opacity: 1; }
.flash-hide { opacity: 0; transform: translateY(-4px); }

/* ------------------------------------------------------------------ Badges & type pills */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .14rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.5; background: #f1f5f9; color: var(--muted); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-open, .badge-unpaid, .badge-locked { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-invoiced { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge-paid, .badge-issued, .badge-active { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-void, .badge-overdue, .badge-inactive { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-draft { background: #f1f5f9; color: var(--muted); }

.type { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 6px; }
.type-rfq { background: var(--rfq-bg); color: var(--rfq); }
.type-inv { background: var(--inv-bg); color: var(--inv); }
.type-rct { background: var(--rct-bg); color: var(--rct); }
.type-dn { background: var(--dn-bg); color: var(--dn); }

/* ------------------------------------------------------------------ Tables */
.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }
table { border-collapse: collapse; width: 100%; }
.list th, .list td { padding: .7rem .75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.list th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: var(--zebra); border-top: 1px solid var(--border); }
.list th:first-child { border-top-left-radius: 8px; }
.list th:last-child { border-top-right-radius: 8px; }
.list tbody tr { transition: background .12s; }
.list tbody tr:hover { background: #f8faff; }
.list tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem !important; }
.row-actions { display: flex; gap: .4rem; align-items: flex-start; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.1rem; }

.doc-link { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none !important; }
.doc-link strong { display: block; color: var(--text); white-space: nowrap; }
.doc-link small { display: block; color: var(--muted); font-size: .76rem; }
.doc-link:hover strong { color: var(--primary); }
.doc-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.doc-icon .icon { width: 17px; height: 17px; }
.doc-icon-rfq { background: var(--rfq-bg); color: var(--rfq); }
.doc-icon-inv { background: var(--inv-bg); color: var(--inv); }
.doc-icon-rct { background: var(--rct-bg); color: var(--rct); }
.doc-icon-dn { background: var(--dn-bg); color: var(--dn); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state strong { color: var(--text); margin-top: .7rem; }
.empty-state p { margin: .25rem 0 0; font-size: .88rem; }
.empty-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--primary-50); color: var(--primary); }
.empty-icon .icon { width: 22px; height: 22px; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .95rem; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { font-size: .72rem; font-weight: 700; padding: 0 .45rem; border-radius: 999px; background: #eef1f6; color: var(--muted); }
.tab.active .tab-count { background: var(--primary-50); color: var(--primary); }
.badge-line { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.badge-line::before { display: none; }
.price-rule { display: flex; gap: 1rem; align-items: flex-start; }
.upload-card { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.upload-card .upload-text { flex: 1 1 280px; }
.upload-card .upload-text p { margin: .2rem 0 0; }
.upload-card input[type=file] { width: auto; flex: 0 1 300px; margin: 0; padding: .4rem; }
.price-rule p { margin: .2rem 0 0; }
.price-rule-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--rct-bg); color: var(--rct); flex: none; }
details.card summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
details.card[open] summary { margin-bottom: .75rem; }

/* ------------------------------------------------------------------ Dashboard */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.quick {
  position: relative; display: flex; align-items: center; gap: .9rem; padding: 1.1rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none !important; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.quick:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-icon { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; flex: none; }
.quick-icon .icon { width: 22px; height: 22px; }
.quick-text { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
.quick-text small { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.quick-arrow { color: var(--muted); transition: transform .15s, color .15s; }
.quick:hover .quick-arrow { transform: translateX(3px); }
.quick-rfq .quick-icon { background: var(--rfq-bg); color: var(--rfq); }
.quick-rfq:hover { border-color: #d6c6fb; } .quick-rfq:hover .quick-arrow { color: var(--rfq); }
.quick-inv .quick-icon { background: var(--inv-bg); color: var(--inv); }
.quick-inv:hover { border-color: #bcd0fb; } .quick-inv:hover .quick-arrow { color: var(--inv); }
.quick-rct .quick-icon { background: var(--rct-bg); color: var(--rct); }
.quick-rct:hover { border-color: #ade0c9; } .quick-rct:hover .quick-arrow { color: var(--rct); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon label" "value value" "note note";
  align-items: center; column-gap: .65rem; padding: 1.1rem 1.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none !important; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s;
}
.kpi:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.kpi-icon { grid-area: icon; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; }
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-label { grid-area: label; font-size: .8rem; font-weight: 600; color: var(--muted); }
.kpi-value { grid-area: value; font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; margin-top: .7rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-value small { font-size: .85rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-note { grid-area: note; font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.kpi-alert { border-color: var(--danger-border); background: linear-gradient(180deg, #fff, #fff8f8); }
.kpi-alert .kpi-value { color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.dash-grid > .card, .dash-side > .card { margin-bottom: 0; }
.dash-side { display: grid; gap: 1.25rem; }
.attention, .glance { list-style: none; margin: 0; padding: 0; }
.attention li + li, .glance li + li { border-top: 1px solid var(--border); }
.attention a { display: flex; align-items: center; gap: .7rem; padding: .65rem 0; color: var(--text); text-decoration: none !important; }
.attention a:hover strong { color: var(--primary); }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); flex: none; }
.attention-main, .attention-side { display: flex; flex-direction: column; line-height: 1.3; }
.attention-main { flex: 1; min-width: 0; }
.attention-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attention-side { text-align: right; font-variant-numeric: tabular-nums; }
.attention small, .attention-side small { font-size: .78rem; }
.glance a { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; color: var(--text-2); text-decoration: none !important; }
.glance a .icon { color: var(--muted); }
.glance a span { flex: 1; }
.glance a strong { font-variant-numeric: tabular-nums; }
.glance a:hover, .glance a:hover .icon { color: var(--primary); }

/* ------------------------------------------------------------------ Analytics (admin) */
.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.analytics-grid > .card { margin-bottom: 1.25rem; }
.period-picker { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.segmented { display: inline-flex; background: #eef1f6; border-radius: 9px; padding: 3px; }
.segmented a { padding: .35rem .85rem; border-radius: 7px; font-weight: 600; font-size: .85rem; color: var(--muted); text-decoration: none !important; }
.segmented a.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.period-nav { display: flex; align-items: center; gap: .35rem; }
.period-nav strong { min-width: 88px; text-align: center; }
.icon-btn.is-disabled { opacity: .35; }
.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.insight { display: flex; gap: .8rem; align-items: flex-start; padding: .65rem .8rem; border-radius: 8px; background: var(--zebra); border: 1px solid var(--border); }
.insight-tag { display: inline-flex; align-items: center; gap: .3rem; flex: none; min-width: 92px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: .1rem; }
.insight-critical .insight-tag { color: #d03b3b; }
.insight-warning .insight-tag { color: #a16207; }
.insight-good .insight-tag { color: #006300; }
.insight-info .insight-tag { color: var(--primary); }
.kpis-6 { grid-template-columns: repeat(3, 1fr); }
.kpi-static { display: flex; flex-direction: column; gap: .1rem; }
.kpi-static:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.kpi-static .kpi-value { margin: .35rem 0 .3rem; }
.delta { font-size: .8rem; font-weight: 600; }
.delta .muted { font-weight: 400; }
.delta-good { color: #006300; }
.delta-bad { color: #d03b3b; }
.delta-flat { color: var(--muted); font-weight: 400; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.mini-stats > div { display: flex; flex-direction: column; padding: .7rem .8rem; background: var(--zebra); border-radius: 8px; }
.mini-stats strong { font-size: 1.15rem; margin-top: .15rem; }
.mini-stats small { font-size: .78rem; }
.sub-head { font-size: .85rem; margin: 1.1rem 0 .5rem; color: var(--text-2); }
.list.compact th, .list.compact td { padding: .45rem .55rem; font-size: .86rem; }
.chart-sub { margin: .2rem 0 0; font-size: .85rem; }

/* Charts: colours from the validated reference palette (slot 1 blue, slot 2 orange); text uses ink tokens. */
.chart { display: block; width: 100%; height: auto; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.chart .s1, .chart-legend .s1 { fill: #2a78d6; background: #2a78d6; }
.chart .s2, .chart-legend .s2 { fill: #eb6834; background: #eb6834; }
.chart .grid { stroke: #e1e0d9; stroke-width: 1; }
.chart .axis { stroke: #c3c2b7; stroke-width: 1; }
.chart .tick, .chart .xlabel { fill: #898781; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .is-current .xlabel { fill: #0b0b0b; font-weight: 700; }
.chart .rowlabel { fill: #52514e; font-size: 12px; }
.chart .value { fill: #0b0b0b; font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .band:hover .hit { fill: rgba(11, 11, 11, .04); }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: #52514e; }
.chart-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend .key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.table-toggle { margin-top: .75rem; }
.table-toggle summary { cursor: pointer; font-size: .85rem; color: var(--primary); font-weight: 600; }
.table-toggle table { margin-top: .5rem; }
.meter { display: block; width: 100%; height: 14px; }
.meter-track { fill: #cde2fb; }
.meter-fill { fill: #2a78d6; }
.meter-caption { margin: .45rem 0 0; font-size: .9rem; }
@media (max-width: 1100px) { .analytics-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .kpis-6 { grid-template-columns: 1fr 1fr; } .mini-stats { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ Document form */
.step { display: flex; align-items: center; gap: .65rem; font-size: 1.05rem; }
.step .muted { font-weight: 400; font-size: .9rem; }
.step-no {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: .8rem; font-weight: 700; flex: none;
}
.from-rfq { display: flex; align-items: flex-end; gap: 1rem; background: linear-gradient(90deg, var(--primary-50), #fff 60%); border-color: var(--primary-100); }
.from-rfq label { flex: 1; margin-bottom: 0; }
.from-rfq-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: #fff; color: var(--primary); border: 1px solid var(--primary-100); flex: none; }

.items th, .items td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
.items th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.items input { margin: 0; }
.items .icon-btn { margin-top: 4px; }
.col-code { width: 160px; }
.col-qty { width: 96px; }
.item-info { min-width: 220px; }
.item-name { display: block; font-weight: 600; padding-top: .5rem; }
.item-desc { display: block; color: var(--muted); font-size: .82rem; }
.item-price, .item-total { padding-top: 1rem !important; white-space: nowrap; }
.item-total { font-weight: 600; }
.item-row:not(.not-found) .item-name:empty::before { content: "Enter an SQ code"; color: #a3aec0; font-weight: 400; }
.not-found .item-name { color: var(--danger); font-weight: 500; }
.not-found [name=sq_code] { border-color: var(--danger); background: var(--danger-bg); }

.totals-box { display: flex; justify-content: flex-end; margin-top: 1.25rem; }
.totals { width: auto; min-width: 300px; }
.totals th, .totals td { padding: .35rem .5rem; text-align: right; font-variant-numeric: tabular-nums; }
.totals th { font-weight: 500; color: var(--muted); }
.totals .grand th, .totals .grand td { border-top: 2px solid var(--text); font-size: 1.15rem; font-weight: 700; color: var(--text); padding-top: .6rem; }

.action-bar {
  position: sticky; bottom: 1rem; z-index: 5; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .8rem 1rem; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.action-bar-total { margin-left: auto; margin-right: .5rem; color: var(--muted); font-size: .9rem; }
.action-bar-total strong { color: var(--text); font-size: 1.15rem; font-variant-numeric: tabular-nums; margin: 0 .15rem; }

/* ------------------------------------------------------------------ Document view */
.tracker { display: flex; list-style: none; margin: 0 0 1.25rem; padding: 1rem 1.25rem; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tracker-step { flex: 1; display: flex; align-items: center; gap: .7rem; position: relative; min-width: 0; }
.tracker-step:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 .5rem; border-radius: 2px; }
.tracker-step.is-done:not(:last-child)::after, .tracker-step.is-current:not(:last-child)::after { background: linear-gradient(90deg, var(--rct), var(--border)); }
.tracker-dot {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: #f1f5f9; color: var(--muted); font-weight: 700; font-size: .82rem; border: 2px solid var(--border);
}
.tracker-dot .icon { width: 15px; height: 15px; }
.is-done .tracker-dot { background: var(--rct); border-color: var(--rct); color: #fff; }
.is-current .tracker-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.tracker-text { display: flex; flex-direction: column; line-height: 1.3; white-space: nowrap; }
.tracker-text small { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.tracker-text .badge { align-self: flex-start; margin-top: 2px; font-size: .68rem; }

.desk { background: linear-gradient(180deg, #e9edf4, #f1f4f9); border-radius: var(--radius-lg); padding: 2rem; margin-bottom: 1.25rem; }
.desk .paper { max-width: 860px; margin: 0 auto; box-shadow: 0 2px 6px rgba(15, 23, 42, .06), 0 18px 40px rgba(15, 23, 42, .1); border: 0; }

.danger-zone { border-color: var(--danger-border); }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.danger-zone form { margin-top: .5rem; max-width: 440px; }

/* ------------------------------------------------------------------ Sign-in screens */
.auth-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 3rem;
  color: #fff; background:
    radial-gradient(circle at 20% 20%, rgba(59, 116, 230, .55), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(245, 158, 11, .25), transparent 40%),
    linear-gradient(160deg, #0f1d36 0%, #163463 100%);
}
.auth-brand::before {  /* subtle circuit-board grid */
  content: ""; position: absolute; inset: 0; opacity: .14;
  background-image:
    linear-gradient(rgba(255, 255, 255, .5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .5) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 75%);
}
.auth-brand-inner { position: relative; max-width: 420px; }
.auth-brand h2 { font-size: 2rem; line-height: 1.2; margin: 1.5rem 0 .6rem; letter-spacing: -.02em; }
.auth-tagline { font-size: 1.08rem; color: #c3d0e8; margin: 0 0 2rem; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.auth-points li { display: flex; align-items: center; gap: .7rem; color: #dbe4f3; }
.auth-points .icon { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: rgba(16, 185, 129, .2); color: #6ee7b7; }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.75rem; }
.auth-card > .muted { margin: .4rem 0 0; }
.auth-foot { margin-top: 2.5rem; font-size: .78rem; color: var(--muted); }
.error-page { text-align: center; }
.error-page .error-code { display: block; font-size: 4rem; font-weight: 800; line-height: 1; color: var(--primary-100); letter-spacing: -.04em; }
.error-page h1 { margin: .5rem 0; }
.error-page p { margin: 0 0 1.5rem; }
.in-app .error-page { padding: 4rem 1rem; }

/* ------------------------------------------------------------------ The printed company document */
.paper {
  position: relative; overflow: hidden; background: #fff; color: #1c2430;
  border: 1px solid var(--border); border-radius: 6px; padding: 3rem; margin-bottom: 1.25rem; font-size: 14px;
}
.paper-head { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 3px solid var(--paper-brand); padding-bottom: 1.25rem; margin-bottom: 1.5rem; }
.paper-company { color: #5b6573; font-size: .85rem; line-height: 1.45; }
.paper-logo { max-height: 64px; max-width: 220px; display: block; margin-bottom: .5rem; }
.paper-company-name { color: var(--paper-brand); font-weight: 700; font-size: 1.35rem; margin-bottom: .2rem; }
.paper-title { text-align: right; }
.paper-title h1 { color: var(--paper-brand); text-transform: uppercase; letter-spacing: .04em; font-size: 1.5rem; margin-bottom: .5rem; }
.paper-meta { width: auto; margin-left: auto; }
.paper-meta.left { margin-left: 0; }
.paper-meta th { font-weight: 400; color: #5b6573; padding: .1rem 1rem .1rem 0; text-align: left; }
.paper-meta td { font-weight: 600; padding: .1rem 0; text-align: right; }
.paper-meta.left td { text-align: left; }
.paper-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #5b6573; font-weight: 700; margin-bottom: .25rem; }
.paper-party { margin-bottom: 1.5rem; }
.paper-items th { background: var(--paper-brand); color: #fff; font-size: .78rem; padding: .5rem; text-align: left; }
.paper-items td { padding: .5rem; border-bottom: 1px solid #d5dbe3; vertical-align: top; }
.paper-items tbody tr:nth-child(even) { background: #f4f7fa; }
.paper-items .muted { font-size: .82rem; }
.paper .totals { margin: 1rem 0 1.25rem auto; }
.paper .totals .grand th, .paper .totals .grand td { border-top-color: var(--paper-brand); color: var(--paper-brand); }
.paper-box { background: #f4f7fa; border: 1px solid #d5dbe3; border-radius: 6px; padding: .75rem 1rem; margin-top: 1rem; }
.paper-notes { margin-top: 1.25rem; }
.paper-terms { margin-top: 2rem; padding-top: .75rem; border-top: 1px solid #d5dbe3; color: #5b6573; font-size: .8rem; }
.stamp {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 6rem; font-weight: 800; letter-spacing: .1em; opacity: .1; pointer-events: none; text-transform: uppercase;
}
.stamp-paid { color: var(--success); }
.stamp-void { color: var(--danger); }
.stamp-draft { color: var(--muted); }
.preview-bar { position: sticky; top: 1rem; z-index: 5; align-items: center; box-shadow: var(--shadow-lg); }

/* Receipt in the Word design (matches word.py / the company's RCP receipt) */
.paper-receipt { --rc-red: #c8102e; --rc-grey: #e7e6e6; --rc-muted: #595959;
  font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 13.5px; color: #000; display: flex; flex-direction: column; min-height: 1180px; }
.rc-logo { width: 205px; display: block; margin-bottom: 14px; }
.rc-hatch { height: 7px; margin: 6px 0; background: repeating-linear-gradient(-45deg, #bfbfbf 0 1px, transparent 1px 3px); }
.rc-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 6px 0; line-height: 1.6; }
.rc-info strong { display: block; }
.rc-title { display: grid; grid-template-columns: 65% 35%; margin: 18px 0 30px; }
.rc-word { font-size: 50px; font-weight: 300; line-height: 1.15; margin-bottom: 6px; }
.rc-sub { color: var(--rc-muted); font-size: 15px; line-height: 1.6; }
.rc-amount { border-left: 8px solid var(--rc-red); display: flex; align-items: center; gap: 1.5rem; padding-left: 20px; font-size: 34px; font-weight: 300; white-space: nowrap; }
.rc-items { width: 100%; border-collapse: collapse; }
.rc-items th { font-size: 15px; font-weight: 400; text-align: left; padding: 22px 8px 6px; border-bottom: 1.5px solid var(--rc-red); vertical-align: bottom; }
.rc-items td { padding: 8px; vertical-align: top; }
.rc-line td { border-bottom: 1px solid #808080; }
.rc-items .rc-c { text-align: center; }
.rc-items .rc-grey { background: var(--rc-grey); }
.rc-sku { color: var(--rc-muted); font-size: 12px; }
.rc-desc { color: var(--rc-muted); font-size: 11.5px; margin-top: 2px; }
.rc-muted { color: var(--rc-muted); }
.rc-total td.rc-grey { border-bottom: 1px solid #808080; color: var(--rc-muted); }
.rc-total.rc-bold td.rc-grey { font-weight: 700; color: #000; }
.rc-sign { text-align: center; vertical-align: middle !important; border: 0 !important; }
.rc-stamp { width: 185px; mix-blend-mode: multiply; vertical-align: middle; }
.rc-signature { width: 150px; mix-blend-mode: multiply; vertical-align: middle; margin-left: 12px; }
.rc-pay { color: var(--rc-muted); font-size: 12.5px; margin: 18px 0 0; }
.rc-footer { margin-top: auto; padding-top: 48px; line-height: 1.7; }
.rc-brand { color: var(--rc-red); font-size: 22px; font-weight: 700; border-bottom: 1.5px solid var(--rc-red); padding-bottom: 4px; margin: 10px 0 6px; }
.rc-red { color: var(--rc-red); font-size: 13px; }
@media (max-width: 700px) {
  .paper-receipt { min-height: 0; }
  .rc-info, .rc-title { grid-template-columns: 1fr; }
  .rc-amount { font-size: 26px; margin-top: 12px; }
  .rc-word { font-size: 38px; }
  .rc-items { font-size: 12px; }
}
@media print { .paper-receipt { min-height: 255mm; } .rc-hatch, .rc-grey, .rc-amount { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Company stamp and authorised signature (all documents) */
.paper-parties { display: flex; gap: 2rem; margin-bottom: 1.5rem; }
.paper-parties .paper-party { flex: 1; margin-bottom: 0; }
.paper-sign { display: flex; justify-content: flex-end; align-items: flex-end; gap: 1.5rem; margin-top: 1.75rem; break-inside: avoid; }
.paper-stamp { width: 170px; mix-blend-mode: multiply; }
.paper-signature { display: flex; flex-direction: column; align-items: center; width: 200px; }
.paper-signature img { width: 160px; mix-blend-mode: multiply; margin-bottom: -.4rem; }
/* Delivery note sign-off */
.paper-delivery { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; margin-top: 1.75rem; break-inside: avoid; }
.delivery-box { border: 1px solid #d5dbe3; border-radius: 6px; padding: .9rem 1rem 1rem; }
.delivery-received { display: flex; gap: 1rem; align-items: stretch; }
.delivery-fields { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 1.6rem; padding-top: 1.2rem; }
.sign-line { border-bottom: 1px solid #5b6573; height: 1.6rem; position: relative; }
.sign-line span { position: absolute; left: 0; bottom: -1.15rem; font-size: .72rem; color: #5b6573; }
.stamp-box { width: 130px; min-height: 120px; border: 1.5px dashed #b6c0cd; border-radius: 6px; display: grid; place-items: center; color: #94a0b0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.delivery-box .paper-sign { margin-top: .5rem; justify-content: center; }
.delivery-box .paper-stamp { width: 140px; }
.delivery-box .paper-signature { width: 170px; }
.delivery-box .paper-signature img { width: 140px; }
.paper-signature span { display: block; width: 100%; border-top: 1px solid #5b6573; padding-top: .3rem; text-align: center; color: #5b6573; font-size: .8rem; }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45); }
  .mobile-bar {
    display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 30;
    padding: .6rem 1rem; background: var(--side-bg); color: #fff;
  }
  .mobile-bar .icon-btn { color: #fff; }
  .mobile-bar .icon-btn:hover { background: rgba(255, 255, 255, .1); }
  .container { padding: 1.25rem 1rem 3rem; }
  .quick-actions { grid-template-columns: 1fr; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem 1.5rem; }
  .auth-brand h2 { font-size: 1.5rem; margin-top: 1rem; }
  .auth-points, .auth-tagline { display: none; }
}
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .kpi-value { font-size: 1.3rem; }
  .card { padding: 1.1rem 1rem; }
  .table-wrap { margin: 0 -1rem; padding: 0 1rem; }
  .desk { padding: .5rem; margin: 0 -1rem 1.25rem; border-radius: 0; }
  .paper { padding: 1.25rem; }
  .paper-head { flex-direction: column; gap: 1rem; }
  .paper-delivery { grid-template-columns: 1fr; }
  .delivery-received { flex-direction: column; }
  .stamp-box { width: 100%; }
  .paper-title { text-align: left; }
  .paper-meta { margin-left: 0; }
  .tracker { flex-direction: column; align-items: stretch; }
  .tracker-step:not(:last-child)::after { display: none; }
  .from-rfq { flex-direction: column; align-items: stretch; }
  .from-rfq-icon { display: none; }
  .action-bar-total { order: -1; width: 100%; margin: 0 0 .25rem; }
  .title-icon { width: 42px; height: 42px; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .no-print, .flash, .sidebar, .mobile-bar, .scrim, .action-bar { display: none !important; }
  .app { display: block; }
  .container { max-width: none; padding: 0; }
  .desk { background: none; padding: 0; margin: 0; }
  .desk .paper, .paper { border: 0; padding: 0; margin: 0; box-shadow: none; }
  .paper-items th, .paper-items tbody tr:nth-child(even), .paper-box { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
