:root {
  --navy: #0b1f3a;
  --navy-2: #132846;
  --ink: #142033;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6e8ee;
  --bg: #f4f6f9;
  --card: #fff;
  --soft: #f6f7f9;
  --blue: #1d4e89;
  --blue-soft: #e8f1fc;
  --green: #17803d;
  --green-soft: #e8f6ee;
  --red: #dc2626;
  --amber: #b45309;
  --shadow: 0 12px 40px rgba(16, 24, 40, .12);
  --font: "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); background: var(--bg); }
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--navy); color: #fff; display: flex; align-items: center;
  padding: 0 18px; gap: 16px; position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: #2f6fed; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-weight: 700; letter-spacing: -.02em; }
.company-pill { background: var(--navy-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: #d7e2f2; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-search { flex: 1; max-width: 420px; }
.top-search input { width: 100%; background: #163055; border: 1px solid #27456e; color: #fff; border-radius: 999px; padding: 8px 14px; }
.top-search input::placeholder { color: #93a4bd; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.top-right a, .top-right button.linkish { color: #fff; background: none; border: 0; font-size: 14px; text-decoration: none; }
.signout { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; border-radius: 8px; padding: 6px 12px; }
.body { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 232px; background: #fbfcfe; border-right: 1px solid var(--line); padding: 18px 12px; flex-shrink: 0; }
.nav-sec { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8b95a5; padding: 12px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #344054; text-decoration: none; font-size: 14px; margin-bottom: 2px;
}
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-item.active { background: var(--blue-soft); color: #163e72; font-weight: 600; }
.nav-item .count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }
.main { flex: 1; padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; font-size: 13px; }
.btn:hover { background: var(--soft); }
.btn-primary { background: #111827; color: #fff; border-color: #111827; border-radius: 999px; padding: 10px 16px; font-weight: 600; }
.btn-primary:hover { background: #000; }
.btn-danger { color: var(--red); border-color: #f3c0c0; background: #fff; }
.btn-sm { padding: 4px 8px; font-size: 12px; border-radius: 7px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.card h2, .card-h { margin: 0; padding: 16px 18px 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; white-space: nowrap; }
td .who, td .muted { white-space: normal; }
tr:last-child td { border-bottom: 0; }
tr.click:hover td { background: #f8fafc; }
.who { display: flex; flex-direction: column; }
.who small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.badge-dark { background: #111827; color: #fff; }
.badge-green { color: var(--green); background: #f3fbf6; border: 1px solid #b7e4c7; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.metric span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.metric strong { font-size: 26px; letter-spacing: -.03em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select, .field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; width: 100%;
}
.filters input, .filters select { width: auto; }
.subrow td:first-child { padding-left: 28px; }
.banner { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 100%); background: #fff; z-index: 50;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease;
}
.drawer.open { transform: none; }
.drawer.wide { width: min(780px, 100%); }
.drawer-h { display: flex; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { margin: 0; font-size: 20px; }
.drawer-h p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.drawer-b { padding: 16px 18px 24px; overflow: auto; flex: 1; }
.drawer-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); }
.group { background: var(--soft); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.group h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label, .lbl { font-size: 12px; color: #475467; font-weight: 600; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; background: #fff; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; background: transparent; padding: 8px 10px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #0b1f3a, #163055 42%, #f4f6f9 42%); padding: 24px; }
.auth-card { width: min(460px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 8px 0 4px; }
.auth-card .muted { color: var(--muted); margin-bottom: 16px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: #111827; color: #fff; padding: 12px 14px; border-radius: 10px; z-index: 80; max-width: 360px; }
.toast.err { background: #991b1b; }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.right { text-align: right; }
.child-mark { color: var(--faint); margin-right: 6px; }
.print { background: #fff; color: #111; max-width: 800px; margin: 0 auto; }
.lines td input, .lines td select { width: 100%; }
.suggest { border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 4px; }
.suggest div { padding: 8px 10px; cursor: pointer; }
.suggest div:hover { background: var(--soft); }
.viewas { background: #fef3c7; color: #92400e; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.board-group { border-left: 6px solid #00c875; background: #fff; border-radius: 2px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.board-scroll { overflow: auto; max-height: calc(100vh - 280px); }
.sheet { border-collapse: separate; border-spacing: 0; min-width: 1680px; background: #fff; }
.sheet th, .sheet td { height: 34px; padding: 0; border-right: 1px solid #e6e9ef; border-bottom: 1px solid #e6e9ef; font-size: 13px; white-space: nowrap; background: #fff; text-align: center; vertical-align: middle; }
.sheet th { position: sticky; top: 0; z-index: 4; background: #fff; color: #676879; font-size: 12px; font-weight: 500; }
.sheet th[data-sticky], .sheet td[data-sticky] { position: sticky; z-index: 5; background: #fff; }
.sheet th[data-sticky] { z-index: 6; }
.sheet .text-cell { width: 100%; height: 34px; border: 0; background: transparent; padding: 0 8px; font: inherit; text-align: left; }
.sheet .name-cell { text-align: left; position: relative; }
.sheet .name-cell .text-cell { padding-right: 36px; }
.sheet .text-cell:focus, .sheet .date-input:focus { outline: 2px solid #579bfc; outline-offset: -2px; background: #fff; }
.sheet .fill { padding: 0; }
.sheet .label-btn, .sheet .date-face, .sheet .user-btn { width: 100%; height: 34px; border: 0; background: transparent; color: #fff; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.sheet .date-face, .sheet .user-btn { color: #323338; font-weight: 400; }
.sheet .date-input { width: 100%; height: 34px; border: 0; text-align: center; font: inherit; }
.subcount { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; margin-left: 6px; padding: 0 4px; border-radius: 8px; background: #e6e9ef; color: #323338; font-size: 11px; font-weight: 600; vertical-align: middle; }
.chev-btn, .icon-btn { width: 28px; height: 28px; border: 0; background: transparent; color: #676879; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; position: relative; }
.icon-btn svg, .chev-btn { }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.note-dot { position: absolute; top: 2px; right: 2px; background: #579bfc; color: #fff; border-radius: 8px; font-size: 9px; min-width: 12px; line-height: 12px; padding: 0 2px; }
.row-open { display: none; position: absolute; right: 6px; top: 5px; width: 22px; height: 22px; border-radius: 4px; background: #fff; border: 1px solid #e6e9ef; color: #323338; text-decoration: none; font-size: 13px; line-height: 20px; text-align: center; }
.sheet tr:hover .row-open { display: block; }
.sheet tr.subrow td[data-sticky="2"] .text-cell { padding-left: 18px; }
.tick { color: #00c875; font-size: 18px; font-weight: 700; }
.unit-btn { border: 0; background: transparent; font: inherit; color: #323338; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.empty-board { text-align: center; color: #676879; height: 48px; }
.col-resizer { position: absolute; right: 0; top: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 2; }
.col-resizer:hover { background: rgba(87, 155, 252, .35); }
.label-pop { position: fixed; z-index: 80; background: #fff; border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 8px; min-width: 220px; max-height: 420px; overflow: auto; }
.label-opt { display: block; width: 100%; margin: 4px 0; border: 0; border-radius: 4px; min-height: 30px; color: #fff; font-weight: 600; font-size: 13px; }
.label-opt.on { outline: 2px solid #323338; }
.note-pop { width: 240px; }
.note-line { font-size: 12px; padding: 4px 0; border-bottom: 1px solid #e6e9ef; text-align: left; }
.color-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.color-row input[type="color"] { width: 36px; height: 24px; border: 0; background: transparent; padding: 0; }
.bulk-bar { display: flex; gap: 8px; align-items: center; background: #e8f1fc; border: 1px solid #bfdbfe; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.bulk-bar[hidden] { display: none; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.doc-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-decoration: none; color: inherit; }
.doc-card:hover { border-color: #bfd4ee; }
.doc-client { font-weight: 650; font-size: 16px; margin: 4px 0; }
.doc-amt { font-size: 22px; font-weight: 700; letter-spacing: -.03em; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 24px; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.bar { display: block; height: 8px; background: #1d4e89; border-radius: 99px; }
.subrow td:first-child { box-shadow: inset 3px 0 #1d4e89; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .day { background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 88px; padding: 6px; font-size: 12px; }
.cal .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; min-height: 0; background: transparent; border: 0; }
.cal .evt { display: block; background: var(--blue-soft); color: #163e72; border-radius: 4px; padding: 2px 4px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
.set-nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; }
.set-nav button.on { background: var(--blue-soft); color: #163e72; font-weight: 600; }
.int-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.int { padding: 16px; }
.int h3 { margin: 0 0 6px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); padding: 0; }
.off { color: var(--amber); font-weight: 600; }
.on-ok { color: var(--green); font-weight: 600; }
@media (max-width: 960px) {
  .sidebar { display: none; }
  .metrics, .int-grid, .settings-layout, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}
@media print {
  .topbar, .sidebar, .page-actions, .no-print { display: none !important; }
  .main { padding: 0; }
  .body { display: block; }
}
