:root {
  --bg: #f4f6fa; --panel: #fff; --ink: #172033; --muted: #64708a; --line: #e3e7ef; --soft: #f0f3f8;
  --brand: #1d4ed8; --brand-ink: #fff; --brand-soft: #e7eefe;
  --ok: #157f3d; --ok-bg: #e5f6eb; --warn: #a35b00; --warn-bg: #fff3dc; --bad: #c0262d; --bad-bg: #fde8e8; --info-bg: #e9f0ff;
  --side: #0f172a; --side-ink: #cbd5e1; --side-active: #1e293b;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.pre { white-space: pre-wrap; }

/* layout */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.logo b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); font-size: 13px; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; margin: 16px 8px 6px; }
.side a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 7px 10px; border-radius: 7px; }
.side a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.side a.on { background: var(--brand); color: #fff; }
.side .cnt { margin-left: auto; background: #334155; color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top form.search { flex: 1; max-width: 420px; }
.top .search input { width: 100%; }
.top .me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.menu-btn { display: none; }
.content { padding: 22px 24px 48px; max-width: 1400px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.card.flush .card-h { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi .l { color: var(--muted); font-size: 12px; }
a.kpi:hover { text-decoration: none; border-color: var(--brand); }
a.kpi { color: inherit; display: block; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--soft); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; text-transform: capitalize; }
.b-ok, .b-active, .b-paid, .b-won, .b-accepted, .b-received, .b-installed, .b-completed { background: var(--ok-bg); color: var(--ok); }
.b-warn, .b-partial, .b-on_hold, .b-ordered, .b-proposal, .b-negotiation, .b-demo, .b-sent { background: var(--warn-bg); color: var(--warn); }
.b-bad, .b-cancelled, .b-lost, .b-rejected, .b-required { background: var(--bad-bg); color: var(--bad); }
.b-new, .b-planning, .b-qualified, .b-contacted, .b-invoiced, .b-poc { background: var(--info-bg); color: var(--brand); }
.b-closed, .b-returned, .b-draft, .b-internal, .b-client { background: var(--soft); color: var(--muted); }
.b-urgent { background: var(--bad); color: #fff; }
.b-high, .b-blocked { background: var(--bad-bg); color: var(--bad); }
.b-medium, .b-in_progress { background: var(--warn-bg); color: var(--warn); }
.b-low, .b-todo { background: var(--soft); color: var(--muted); }
.b-done { background: var(--ok-bg); color: var(--ok); }
.b-idea-new, .b-idea-under_review { background: var(--info-bg); color: var(--brand); }
.b-idea-approved, .b-idea-in_progress { background: var(--warn-bg); color: var(--warn); }
.b-idea-implemented { background: var(--ok-bg); color: var(--ok); }
.b-idea-parked, .b-idea-rejected { background: var(--soft); color: var(--muted); }
.progress { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress span { display: block; height: 100%; background: var(--brand); }
.idea { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin-bottom: 10px; }
.vote-btn { display: flex; flex-direction: column; align-items: center; width: 52px; padding: 6px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; }
.vote-btn b { font-size: 16px; color: var(--ink); }
.vote-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.vote-btn:hover { border-color: var(--brand); }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); } .t-muted { color: var(--muted); }

/* forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 8px 10px; border: 1px solid #cfd6e3; border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; margin-right: 6px; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--ink); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfd6e3; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #f2c4c6; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
form.inline { display: inline; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters input[type=checkbox] { min-width: 0; }
.subform { margin-top: 14px; padding: 14px; background: var(--soft); border: 1px dashed #c9d2e3; border-radius: 8px; }
.file-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); font-size: 10px; font-weight: 700; text-transform: uppercase; flex: none; }
.filters .check { margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .cnt { font-size: 11px; background: var(--soft); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--info-bg); color: #1e3a8a; }
.alert.err { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* detail */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.big-stat { font-size: 26px; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline .next { margin-top: 4px; font-size: 13px; background: var(--warn-bg); color: var(--warn); display: inline-block; padding: 2px 8px; border-radius: 6px; }
.fu-text { margin-top: 3px; white-space: pre-wrap; }
.last-fu { font-size: 13px; }
.last-fu .when { font-size: 12px; color: var(--muted); }

/* doc items editor */
.items td { padding: 6px; }
.items input, .items select { padding: 6px 8px; }
.items .c-desc { min-width: 220px; }
.items .c-sm { width: 90px; }
.items .c-xs { width: 70px; }
.totals { margin-left: auto; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }

/* printable document */
.paper { background: #fff; max-width: 900px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: #111; }
.paper h1.doc-title { font-size: 20px; text-transform: uppercase; letter-spacing: .06em; text-align: right; }
.paper .ph { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid #111; padding-bottom: 16px; margin-bottom: 16px; }
.paper .co-name { font-size: 20px; font-weight: 800; }
.paper .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.paper .box { border: 1px solid #d5d9e0; border-radius: 6px; padding: 10px 12px; }
.paper .box .t { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #666; margin-bottom: 4px; }
.paper table th { background: #f2f4f7; color: #333; }
.paper table td, .paper table th { padding: 7px 8px; border: 1px solid #d5d9e0; font-size: 13px; }
.paper .foot { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-top: 16px; }
.paper .sign { text-align: right; margin-top: 40px; }
.paper .words { font-style: italic; margin-top: 8px; }
.stamp { display: inline-block; border: 2px solid currentColor; padding: 2px 10px; border-radius: 6px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; transform: rotate(-4deg); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, #dbe6ff, transparent), var(--bg); padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(15, 23, 42, .08); text-align: center; }
.login-card .logo { justify-content: center; color: var(--ink); font-size: 20px; }
.zoho-btn { display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; padding: 12px; border-radius: 10px; background: #e42527; color: #fff; font-weight: 700; font-size: 15px; border: 0; cursor: pointer; }
.zoho-btn:hover { filter: brightness(1.06); text-decoration: none; }

@media (max-width: 1000px) {
  .g-main, .g2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .top { padding: 10px 16px; }
  .top .me .name { display: none; }
  .content { padding: 16px 16px 40px; }
  .dl { grid-template-columns: 110px 1fr; }
  .paper { padding: 20px 16px; }
  .paper .ph, .paper .meta-grid, .paper .foot { grid-template-columns: 1fr; display: grid; }
  .paper h1.doc-title { text-align: left; }
}

@media print {
  body { background: #fff; }
  .side, .top, .no-print, .alert { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
  @page { size: A4; margin: 12mm; }
}
.stack { display: flex; flex-direction: column; min-width: 0; }
.stack > .card { width: 100%; }

/* v6: notifications, pager, diffs, boards */
.bell { position: relative; font-size: 18px; text-decoration: none; padding: 2px 6px; }
.bell:hover { text-decoration: none; }
.bell-cnt { position: absolute; top: -4px; right: -6px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 700; padding: 0 5px; line-height: 16px; }
.pager { justify-content: center; margin: 14px 0; }
.unread td { background: #f5f8ff; font-weight: 600; }
.diff { font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; margin: 0; }
.diff .add { background: var(--ok-bg); color: var(--ok); display: block; }
.diff .del { background: var(--bad-bg); color: var(--bad); display: block; text-decoration: line-through; }
.diff .same { display: block; color: var(--muted); }
.kb-body h2, .kb-body h3, .kb-body h4, .kb-body h5 { margin: 18px 0 8px; }
.kb-body pre { background: var(--soft); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.kb-body code { background: var(--soft); padding: 1px 4px; border-radius: 4px; font-size: 13px; }
.kb-body blockquote { border-left: 3px solid var(--line); margin: 8px 0; padding: 4px 12px; color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; }
.board .col { background: var(--soft); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.board .col h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.board .item { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.state-submitted, .b-pass, .b-matched, .b-approved, .b-auto_approved, .b-available, .b-ordered_po { background: var(--ok-bg); color: var(--ok); }
.state-missing, .b-fail, .b-missing_in_books, .b-missing_in_2b, .b-critical, .b-reopened { background: var(--bad-bg); color: var(--bad); }
.state-not_submitted, .b-amount_mismatch, .b-pending, .b-pending_review, .b-retest, .b-fixed, .b-major, .b-review, .b-returned, .b-repair, .b-calibration, .b-submitted { background: var(--warn-bg); color: var(--warn); }
.state-on_leave, .state-holiday, .state-off_day, .state-excused, .b-not_run, .b-minor, .b-trivial, .b-triaged, .b-not_started, .b-obsolete, .b-archived, .b-retired { background: var(--soft); color: var(--muted); }
.b-published, .b-in_progress { background: var(--info-bg); color: var(--brand); }
.over { color: var(--bad); font-weight: 700; }
.cap-cell { min-width: 110px; }
.cap-bar { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; margin-top: 3px; }
.cap-bar span { display: block; height: 100%; background: var(--ok); }
.cap-bar span.warn { background: var(--warn); }
.cap-bar span.bad { background: var(--bad); }
.mod-links { display: flex; flex-wrap: wrap; gap: 8px; }
.mod-links a { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 600; font-size: 13px; }
.mod-links a:hover { border-color: var(--brand); text-decoration: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid .d { border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 64px; font-size: 12px; background: #fff; }
.cal-grid .d.off { background: var(--soft); color: var(--muted); }
.cal-grid .d.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 760px) { .board { grid-template-columns: repeat(5, 75vw); } .cal-grid { grid-template-columns: repeat(7, minmax(36px, 1fr)); } .cal-grid .d { min-height: 48px; padding: 3px; } }

/* v7 — role panels */
.today-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.today-row > b:first-child { width: 110px; color: var(--muted); font-weight: 600; font-size: 13px; }
.today-row form { margin-left: auto; }
.today-row > a.btn { margin-left: auto; }
