/* 22 Kings CRM — navy & gold, matched to the company logo. System fonts only (no downloads). */
:root {
  --navy-950: #0a121f;
  --navy-900: #0f1a2e;
  --navy-800: #16243f;
  --navy-700: #1b2a4a;
  --navy-600: #2a3c63;
  --navy-100: #e6eaf2;
  --gold-600: #a9832f;
  --gold-500: #c9a24b;
  --gold-300: #e9d49a;
  --gold-100: #f6eed9;

  --ink: #18202f;
  --ink-2: #485266;
  --ink-3: #737d90;
  --line: #e2dfd6;
  --line-2: #eeebe4;
  --bg: #f4f2ec;
  --card: #ffffff;
  --hover: #faf8f3;

  --green: #1d7348;
  --green-bg: #e2f2e9;
  --red: #b3352c;
  --red-bg: #fbe8e6;
  --amber: #8f6200;
  --amber-bg: #fbf0d4;
  --blue: #2a5597;
  --blue-bg: #e5edf9;
  --grey: #586174;
  --grey-bg: #eceef2;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 26, 46, 0.06);
  --shadow: 0 1px 2px rgba(15, 26, 46, 0.06), 0 2px 8px rgba(15, 26, 46, 0.06);
  --shadow-lg: 0 12px 40px rgba(10, 18, 31, 0.22);

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --font-display: Bahnschrift, 'DIN Alternate', 'Segoe UI', system-ui, sans-serif;
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--navy-600); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.num, td.r, .money { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--ink-3); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--navy-700);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--card);
}
.auth-brand {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 20% 10%, var(--navy-700) 0%, var(--navy-900) 55%, var(--navy-950) 100%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::after {
  content: ''; position: absolute; inset: auto -20% -35% auto; width: 70%; aspect-ratio: 1;
  border: 1px solid rgba(201, 162, 75, 0.25); border-radius: 50%;
}
.auth-brand .logo-tile {
  width: 132px; height: 132px; border-radius: 22px; background: #fff; padding: 8px;
  box-shadow: 0 0 0 1px rgba(201, 162, 75, 0.5), 0 18px 40px rgba(0, 0, 0, 0.35);
}
.auth-brand .logo-tile img { width: 100%; height: 100%; object-fit: contain; }
.auth-brand h1 { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: 0.01em; margin-top: 28px; }
.auth-brand h1 span { color: var(--gold-500); }
.auth-brand p { color: #c5cddd; max-width: 420px; font-size: 15px; }
.auth-brand ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: #dfe4ee; }
.auth-brand li { display: flex; gap: 10px; align-items: center; }
.auth-brand li::before { content: ''; width: 18px; height: 2px; background: var(--gold-500); }
.auth-brand .fine { font-size: 12px; color: #8f9ab0; position: relative; z-index: 1; }
.auth-install { position: absolute; top: 20px; right: 20px; z-index: 2; }
.auth-install svg { width: 15px; height: 15px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.auth-card .lead { color: var(--ink-3); margin: 6px 0 24px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px 16px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #cfd6e4; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.brand img { width: 44px; height: 44px; border-radius: 10px; background: #fff; padding: 2px; object-fit: contain; }
.brand b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 17px; color: #fff; letter-spacing: 0.02em; }
.brand b span { color: var(--gold-500); }
.brand small { display: block; color: #8d98ad; font-size: 11.5px; }
.nav { padding: 12px 10px; display: grid; gap: 2px; }
.nav .group { margin: 14px 10px 6px; font-size: 11px; color: #75819a; letter-spacing: 0.06em; text-transform: uppercase; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: #cfd6e4; text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: rgba(201, 162, 75, 0.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold-500); }
.nav a.active svg { color: var(--gold-500); opacity: 1; }
.nav .count {
  margin-left: auto; background: var(--gold-500); color: var(--navy-950); font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.side-foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gold-500); color: var(--navy-950);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.me b { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.me small { color: #8d98ad; font-size: 12px; }
.me .icon-btn { margin-left: auto; color: #aab4c7; }
.me .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px; padding: 10px 14px; background: var(--navy-900); color: #fff;
  position: sticky; top: 0; z-index: 30;
}
.topbar img { width: 32px; height: 32px; border-radius: 8px; background: #fff; padding: 1px; }
.topbar b { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.02em; }
.topbar b span { color: var(--gold-500); }
.topbar .icon-btn { color: #fff; }
.content { padding: 26px 30px 48px; max-width: 1360px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: 0.005em; }
.page-head .sub { color: var(--ink-3); margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--navy-700); text-decoration: underline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--hover); border-color: #d4d0c5; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn-primary:hover { background: var(--navy-800); border-color: var(--navy-800); }
.btn-gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-950); }
.btn-gold:hover { background: #bd953e; border-color: #bd953e; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: #efc6c1; }
.btn-danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(15, 26, 46, 0.05); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled], .btn.busy { opacity: 0.6; pointer-events: none; }
.btn.busy::before { content: ''; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.8s linear infinite; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0;
  background: transparent; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: rgba(15, 26, 46, 0.06); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- cards / layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 650; }
.card-head .hint { color: var(--ink-3); font-size: 12.5px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.kpi .value { font-family: var(--font-display); font-size: 25px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.kpi.accent { background: linear-gradient(135deg, var(--navy-700), var(--navy-900)); border-color: var(--navy-800); color: #fff; }
.kpi.accent .label, .kpi.accent .foot { color: #b9c3d6; }
.kpi.accent .value { color: var(--gold-300); }
.kpi a.stretch::after { content: ''; position: absolute; inset: 0; }
.kpi:has(a.stretch):hover { border-color: var(--gold-500); }
.up { color: var(--red); }
.down { color: var(--green); }

/* ---------- charts ---------- */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 10px; height: 180px; padding-top: 10px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar .fill { width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px; background: var(--navy-600); min-height: 2px; transition: height 0.4s ease; }
.bar.current .fill { background: var(--gold-500); }
.bar .v { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar .m { font-size: 12px; color: var(--ink-3); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--navy-600); border-radius: 99px; }
.hbar:first-child .track i { background: var(--gold-500); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .amt { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list a.row-link { color: inherit; text-decoration: none; display: contents; }
.list .main-col { min-width: 0; flex: 1; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--ink-3); font-size: 12.5px; }
.feed li { align-items: flex-start; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-500); margin-top: 7px; flex: none; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search input.input { padding-left: 34px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
  font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.chip:hover { border-color: #cfcabd; }
.chip.on { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.chip .n { font-weight: 700; opacity: 0.7; }
.bulkbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: var(--gold-100);
  border-bottom: 1px solid #ecdcb4; font-weight: 600;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--ink-3); padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfaf7;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--hover); }
.table tbody tr.selected td { background: #fbf6e8; }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table .strong { font-weight: 600; }
.table .sub { display: block; color: var(--ink-3); font-size: 12.5px; }
.table .chk { width: 36px; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line); background: #fbfaf7; }
.cell-trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--navy-700); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line-2); color: var(--ink-3); font-size: 13px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 650; white-space: nowrap; background: var(--grey-bg); color: var(--grey);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft { background: var(--grey-bg); color: var(--grey); }
.badge.sent, .badge.approved { background: var(--blue-bg); color: var(--blue); }
.badge.accepted, .badge.paid { background: var(--green-bg); color: var(--green); }
.badge.rejected { background: var(--red-bg); color: var(--red); }
.badge.expired, .badge.submitted { background: var(--amber-bg); color: var(--amber); }
.badge.plain::before { display: none; }
.tag { display: inline-block; white-space: nowrap; padding: 1px 8px; border-radius: 6px; background: var(--navy-100); color: var(--navy-700); font-size: 12px; font-weight: 600; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > span, .field > label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field .req { color: var(--red); }
.field .help { font-size: 12px; color: var(--ink-3); }
.field .err { font-size: 12px; color: var(--red); font-weight: 600; }
.input, input.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid #d8d4ca; border-radius: var(--radius-sm); background: #fff;
  font-size: 14px; transition: border-color 0.12s, box-shadow 0.12s; min-height: 38px;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: #c7c2b5; }
.input:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(42, 60, 99, 0.14); }
.field.invalid .input { border-color: var(--red); box-shadow: 0 0 0 3px rgba(179, 53, 44, 0.1); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23737d90' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
.input-prefix { position: relative; }
.input-prefix > b { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 500; pointer-events: none; }
.input-prefix > .input { padding-left: 26px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.form-error { background: var(--red-bg); color: var(--red); border: 1px solid #f0c9c4; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 14px; }
.notice { background: var(--amber-bg); color: #6d4b00; border: 1px solid #efdca6; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.notice.info { background: var(--blue-bg); color: #1f4479; border-color: #c9d8f0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.sig-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: 18px; display: grid; place-items: center; min-height: 140px; }
.sig-preview.paper { background: #efece4; }
.sig-preview img { max-width: 100%; max-height: 150px; }

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 64px; }
.pw-wrap input::-ms-reveal, .pw-wrap input::-ms-clear { display: none; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--navy-100); color: var(--navy-700); font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 6px; cursor: pointer; }
.pw-toggle:hover { background: #dbe1ec; }
.pw-choice { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fcfbf8; }
.pw-choice .check { font-weight: 600; }
.login-ids { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }

/* ---------- inline icons ---------- */
.link-btn svg, .sub svg, .notice svg { width: 13px; height: 13px; vertical-align: -2px; }
.drop svg { width: 24px; height: 24px; margin-bottom: 4px; }
.show-sm, .table .show-sm { display: none; }
.filters-toggle { display: none; }
@media (max-width: 1500px) { .hide-md { display: none; } }

/* ---------- quote editor: line items ---------- */
.lines { container-type: inline-size; }
.line { display: grid; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.line-top { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.line-no { width: 26px; height: 26px; border-radius: 50%; background: var(--navy-100); color: var(--navy-700); font-weight: 700; font-size: 12px; display: grid; place-items: center; margin-top: 6px; }
.line-main { display: grid; gap: 6px; min-width: 0; }
.line-main textarea.input { min-height: 36px; height: 36px; font-size: 13px; }
.line-grid { display: grid; grid-template-columns: 92px 72px 128px minmax(120px, 1fr) 70px minmax(110px, auto); gap: 10px; align-items: start; margin-left: 36px; }
.field.mini > span { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.field.mini .input { min-height: 36px; padding: 7px 9px; font-size: 13.5px; }
.line-amt { text-align: right; }
.line-amt b { display: block; font-size: 15px; padding-top: 7px; font-variant-numeric: tabular-nums; }
@container (max-width: 640px) {
  .line-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (max-width: 430px) {
  .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: 0; }
  .line-top { grid-template-columns: 24px minmax(0, 1fr); }
  .line-top .line-tools { grid-column: 1 / -1; justify-content: flex-end; margin-top: -4px; }
}

.items-table th, .items-table td { padding: 8px 6px; vertical-align: top; }
.items-table th:first-child, .items-table td:first-child { padding-left: 14px; }
.items-table th:last-child, .items-table td:last-child { padding-right: 14px; }
.items-table .input { min-height: 36px; padding: 7px 9px; font-size: 13.5px; }
.items-table textarea.input { min-height: 36px; height: 36px; margin-top: 6px; font-size: 12.5px; }
.items-table .w-svc { min-width: 240px; }
.items-table .w-sac { width: 92px; }
.items-table .w-qty { width: 78px; }
.items-table .w-unit { width: 124px; }
.items-table .w-rate { width: 132px; }
.items-table .w-gst { width: 78px; }
.items-table .w-amt { width: 120px; text-align: right; padding-top: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.items-table .w-act { width: 82px; white-space: nowrap; }
.items-table .field.invalid .input { border-color: var(--red); }
.line-tools { display: flex; gap: 2px; }
.line-tools .icon-btn { width: 28px; height: 28px; }
.line-tools .icon-btn svg { width: 15px; height: 15px; }
.rate-cell { display: grid; gap: 4px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--navy-600); font-size: 12px; font-weight: 650; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.totals { width: 100%; border-collapse: collapse; }
.totals td { padding: 7px 0; font-variant-numeric: tabular-nums; }
.totals td:last-child { text-align: right; font-weight: 600; }
.totals tr.grand td { border-top: 2px solid var(--navy-700); padding-top: 12px; font-size: 17px; font-weight: 750; color: var(--navy-900); }
.totals .muted td { color: var(--ink-3); font-weight: 500; }
.sticky-side { position: sticky; top: 18px; }

/* ---------- detail views ---------- */
.detail-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.detail-head h1 { font-family: var(--font-display); font-size: 25px; font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 12px 12px; font-weight: 650; color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.on { color: var(--navy-800); border-bottom-color: var(--gold-500); }
.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 18px; }
.timeline .ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-100); color: var(--navy-700); }
.timeline .ico svg { width: 14px; height: 14px; }
.timeline li.note .ico { background: var(--gold-100); color: var(--gold-600); }
.timeline .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .when { color: var(--ink-3); font-size: 12px; }
.note-form { display: flex; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.note-form textarea { min-height: 40px; height: 40px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 16px 18px; }
.file {
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; position: relative;
  display: flex; flex-direction: column;
}
.file .thumb { aspect-ratio: 4 / 3; background: var(--bg); display: grid; place-items: center; color: var(--ink-3); overflow: hidden; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .thumb svg { width: 34px; height: 34px; }
.file .name { padding: 7px 9px; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .rm { position: absolute; top: 6px; right: 6px; background: rgba(255, 255, 255, 0.92); width: 28px; height: 28px; }
.file a { color: inherit; text-decoration: none; }
.drop {
  border: 1.5px dashed #cfcabd; border-radius: var(--radius-sm); display: grid; place-items: center; text-align: center;
  color: var(--ink-3); font-size: 12.5px; padding: 12px; cursor: pointer; min-height: 120px; background: #fcfbf8;
}
.drop:hover, .drop.over { border-color: var(--gold-500); background: var(--gold-100); color: var(--ink-2); }

/* ---------- modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 31, 0.45); z-index: 80; display: grid; place-items: center; padding: 20px; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop 0.16s ease;
}
.modal.lg { max-width: 760px; }
.modal.sm { max-width: 420px; }
@keyframes pop { from { transform: translateY(8px) scale(0.985); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer {
  background: var(--card); width: min(560px, 100vw); height: 100vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slide 0.18s ease;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer .modal-body { flex: 1; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: grid; gap: 8px; }
.toast {
  background: var(--navy-900); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow-lg);
  font-weight: 600; max-width: 380px; display: flex; gap: 10px; align-items: center; animation: pop 0.16s ease;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #5fd39a; flex: none; }
.toast.error::before { background: #ff7b6e; }
.toast.warn::before { background: var(--gold-500); }

/* ---------- states ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .ico { width: 54px; height: 54px; border-radius: 16px; background: var(--gold-100); color: var(--gold-600); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .ico svg { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 360px; }
.error-state { text-align: center; padding: 40px 20px; }
.error-state h3 { color: var(--red); margin-bottom: 6px; }
.skel { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eeebe4 25%, #f6f4ef 37%, #eeebe4 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel.lg { height: 26px; width: 60%; }

/* ---------- misc ---------- */
.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 10px; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.temp-pass {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 20px; letter-spacing: 0.06em;
  background: var(--gold-100); border: 1px dashed var(--gold-500); padding: 12px 16px; border-radius: 9px; text-align: center; user-select: all;
}
.settings-nav { display: grid; gap: 2px; padding: 8px; }
.settings-nav button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.settings-nav button:hover { background: var(--hover); }
.settings-nav button.on { background: var(--navy-100); color: var(--navy-800); }
.cost-table td { padding: 6px 0; }
.cost-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cost-table tr.total td { border-top: 1px solid var(--line); font-weight: 700; padding-top: 10px; }
.cost-table tr.grand td { font-size: 16px; color: var(--navy-900); font-weight: 750; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.status-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.status-strip a { text-decoration: none; color: inherit; border: 1px solid var(--line-2); border-radius: 9px; padding: 10px 12px; display: grid; gap: 2px; }
.status-strip a:hover { border-color: var(--gold-500); }
.status-strip b { font-size: 18px; font-family: var(--font-display); font-weight: 600; }
.status-strip small { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- app (installed / phone / tablet) ---------- */
.tabbar { display: none; }
.install-side { width: 100%; justify-content: center; margin-bottom: 12px; }
.topbar .install-top { min-height: 34px; padding: 5px 10px; }
.topbar .install-top svg { width: 15px; height: 15px; }
.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px; border-radius: var(--radius); background: linear-gradient(135deg, var(--navy-700), var(--navy-900)); color: #fff; }
.install-banner img { border-radius: 11px; background: #fff; flex: none; }
.install-banner div { flex: 1; min-width: 0; display: grid; }
.install-banner span { color: #c3cbdc; font-size: 12.5px; }
.install-banner .icon-btn { color: #c3cbdc; }
.quick-grid { display: grid; gap: 10px; }
.quick-item { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit; }
.quick-item:hover, .quick-item:active { border-color: var(--gold-500); background: var(--gold-100); }
.quick-item svg { grid-row: span 2; width: 40px; height: 40px; padding: 9px; border-radius: 10px; background: var(--navy-100); color: var(--navy-700); }
.quick-item span { color: var(--ink-3); font-size: 12.5px; }
.steps { padding-left: 20px; margin: 0 0 12px; display: grid; gap: 8px; }
.kbd { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; vertical-align: middle; }
.kbd svg { width: 14px; height: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(15, 26, 46, 0.07);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 60px;
    font-size: 11px; font-weight: 650; color: var(--ink-3); text-decoration: none; border: 0; background: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--navy-900); }
  .tabbar a.active svg { color: var(--gold-600); }
  .tabbar .plus { width: 50px; height: 50px; margin-top: -20px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-500); color: var(--navy-950); box-shadow: 0 6px 18px rgba(169, 131, 47, 0.45); border: 3px solid #fff; }
  .tabbar .plus svg { width: 24px; height: 24px; }
  .tabbar .count { position: absolute; top: 7px; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
  .content { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
  .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .auth-brand { padding-top: calc(28px + env(safe-area-inset-top)); }
  .auth-install { top: calc(16px + env(safe-area-inset-top)); right: 16px; }
  .drawer { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(10, 18, 31, 0.45); z-index: 85; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 40px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-brand .logo-tile { width: 84px; height: 84px; border-radius: 16px; }
  .auth-brand h1 { font-size: 24px; margin-top: 16px; }
  .auth-brand ul, .auth-brand .fine { display: none; }
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
  .hide-sm { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi .value { font-size: 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .search { max-width: none; }
  .modal-body, .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .overlay { padding: 10px; }
  .toasts { left: 12px; right: 12px; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: minmax(90px, 40%) 1fr auto; }
  .show-sm, .table .show-sm { display: block; }
  .row-meta.show-sm, .table .row-meta.show-sm { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 5px; }
  .filters-toggle { display: inline-flex; }
  .toolbar.filters:not(.open) { display: none; }
  .toolbar.filters > * { flex: 1 1 140px; }
  .toolbar.filters input[type='date'] { width: 100% !important; }
}
/* iOS zooms into inputs smaller than 16px — keep phones/tablets at 16px. */
@media (max-width: 900px), (pointer: coarse) {
  .input, input.input, select.input, textarea.input, .field.mini .input, .line-main textarea.input { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
