/* CCTV Janitor CRM — single stylesheet, no external dependencies */
:root {
  --ink: #14213D; --ink-2: #1D2D52; --ink-3: #2A3D6B;
  --paper: #F6F5F1; --card: #FFFFFF; --line: #E4E1D8; --line-2: #EFEDE6;
  --text: #22252B; --muted: #6B6E76;
  --teal: #1F7A5C; --teal-2: #186349; --teal-soft: #E4F1EC;
  --amber: #B86E1E; --amber-soft: #FBEEDF;
  --rust: #B3432B; --rust-soft: #F7E7E2;
  --slate: #4F6290; --slate-soft: #E9EDF5;
  --violet: #6A4FA3; --violet-soft: #EFEAF8;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 1px 0 rgba(20,33,61,.03);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--slate); text-decoration: none; }
a:hover { color: var(--ink); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 20px; } h3 { font-size: 15px; font-weight: 650; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); } .red { color: var(--rust) !important; } .amber { color: var(--amber) !important; }
.mono { font-family: var(--mono); font-size: .92em; }
.center { text-align: center; } .nowrap { white-space: nowrap; } .mt { margin-top: 18px; } .pad-top { padding-top: 24px; }
.ic { width: 18px; height: 18px; flex: none; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #D9DEEA; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 18px; }
.brand img { max-height: 34px; max-width: 120px; border-radius: 6px; background: #fff; padding: 2px; }
.brand b { display: block; font-size: 15.5px; } .brand small { display: block; color: #8E9AB8; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(135deg, var(--teal), #2C9C77); color: #fff; }
.brand.big { color: var(--ink); padding: 0 0 18px; } .brand.big small { color: var(--muted); }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6F7C9C; padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #C9D0E0; font-weight: 500; }
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 #3FC59A; }
.sidebar-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--ink-3); padding-top: 12px; margin-top: 12px; }
.me { display: flex; align-items: center; gap: 9px; flex: 1; color: #fff; min-width: 0; }
.me b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .me small { color: #8E9AB8; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #3FC59A; color: var(--ink); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; vertical-align: middle; background: var(--slate-soft); color: var(--slate); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: inherit; background: transparent; border: 0; cursor: pointer; position: relative; }
.icon-btn:hover { background: rgba(127,127,127,.12); }
.sidebar .icon-btn { color: #9AA6C2; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 26px; background: rgba(246,245,241,.9); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--muted); }
.search input { border: 0; outline: 0; padding: 9px 0; flex: 1; background: transparent; font: inherit; }
.bell { margin-left: auto; color: var(--ink); }
.bell i { position: absolute; top: 3px; right: 2px; background: var(--rust); color: #fff; font-style: normal; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 0 5px; line-height: 16px; }
.content { padding: 24px 26px 60px; max-width: 1440px; width: 100%; }
.only-mobile { display: none; }
.nav-scrim { display: none; }

/* ---------- Page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #CBC7BA; background: #FBFAF7; color: var(--ink); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; } .btn.primary:hover { background: var(--teal-2); }
.btn.success { background: #2E8B57; border-color: #2E8B57; color: #fff; }
.btn.danger { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn.danger-ghost { color: var(--rust); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--slate); cursor: pointer; font: inherit; }
.linkbtn.red { color: var(--rust); }
form.inline { display: inline; }
.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 12px; color: var(--muted); font-weight: 600; font-size: 13px; } .seg a.on { background: var(--ink); color: #fff; }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-h a { font-size: 13px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
.grid2 .span2 { grid-column: 1 / -1; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0 18px; align-items: start; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }
.note { background: #FBFAF6; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: normal; }
.note.ok { background: var(--teal-soft); border-color: #BFDDCF; }
.desc { white-space: normal; margin: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--slate); }
.kpi span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 24px; color: var(--ink); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi.ok { border-top-color: var(--teal); } .kpi.warn { border-top-color: var(--amber); } .kpi.danger { border-top-color: var(--rust); } .kpi.danger b { color: var(--rust); }

/* Lists (rows of links) */
.list { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line-2); color: var(--text); border-radius: 6px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #FAF9F5; color: var(--text); }
.row small { display: block; color: var(--muted); margin-top: 2px; }
.row .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: none; }
.row.unread b { color: var(--ink); } .row.unread { background: #F5F9F7; }
.dim { opacity: .55; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 34px 110px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row b { text-align: right; } .bar-row small { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--slate); }

/* Stage colours (shared by bars, dots, badges) */
.s-new { background: #8C95A8 !important; } .s-contacted { background: #4F6290 !important; } .s-site_survey { background: #6A4FA3 !important; }
.s-proposal { background: #2F7FB8 !important; } .s-negotiation { background: #B86E1E !important; } .s-won { background: #1F7A5C !important; } .s-lost { background: #B3432B !important; }

/* Badges & tags */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--slate-soft); color: var(--slate); white-space: nowrap; line-height: 18px; }
.b-new, .b-open, .b-draft { background: #EEF0F4; color: #555F75; }
.b-contacted, .b-assigned, .b-sent { background: var(--slate-soft); color: var(--slate); }
.b-site_survey { background: var(--violet-soft); color: var(--violet); }
.b-proposal, .b-in_progress { background: #E3F0FA; color: #2F6E9E; }
.b-negotiation, .b-on_hold, .b-medium { background: var(--amber-soft); color: var(--amber); }
.b-won, .b-resolved, .b-accepted, .b-active, .b-renewed, .b-low { background: var(--teal-soft); color: var(--teal); }
.b-lost, .b-rejected, .b-critical, .b-cancelled, .b-expired { background: var(--rust-soft); color: var(--rust); }
.b-high { background: #FCE6D6; color: #B4511A; }
.b-closed { background: #ECEBE6; color: #6B6E76; }
.b-r-admin { background: var(--ink); color: #fff; } .b-r-manager { background: var(--violet-soft); color: var(--violet); }
.b-r-sales { background: var(--slate-soft); color: var(--slate); } .b-r-technician { background: var(--teal-soft); color: var(--teal); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .02em; border: 1px solid; }
.t-cctv { color: #2F6E9E; border-color: #BBD5EA; background: #F2F8FD; }
.t-janitorial { color: #7A5A12; border-color: #E8D6AE; background: #FFF9EC; }
.t-both { color: var(--violet); border-color: #D8CEEE; background: #F8F5FD; }
.sla { display: inline-block; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.sla.late { color: var(--rust); } .sla.soon { color: var(--amber); } .sla.ok { color: var(--muted); } .sla.done { color: var(--teal); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FBFAF7; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td, .tbl.compact th { padding: 7px 10px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #FAF9F5; }
.tbl tr.sub td { background: #FBFAF7; }
.tbl .chk { width: 34px; }
.tickets tr.pr-critical td:first-child { box-shadow: inset 3px 0 0 var(--rust); }
.tickets tr.pr-high td:first-child { box-shadow: inset 3px 0 0 #E07B3B; }
.card .tbl-wrap .tbl th:first-child, .card .tbl-wrap .tbl td:first-child { padding-left: 16px; }

/* ---------- Forms ---------- */
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #4A4E57; margin-bottom: 12px; }
input, select, textarea { font: 14px var(--font); color: var(--text); padding: 8px 10px; border: 1px solid #D9D5CA; border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,122,92,.25); border-color: var(--teal); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--teal); }
input[type=file] { padding: 6px; background: #FBFAF7; }
textarea { resize: vertical; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.fgrid.four { grid-template-columns: repeat(4, 1fr); }
.fgrid .span2 { grid-column: 1 / -1; }
.fgrid .checks { display: flex; flex-direction: column; justify-content: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-actions.end { align-items: flex-end; grid-column: 2; margin-bottom: 12px; }
.form.narrow, .card.narrow { max-width: 520px; }
.row-form { display: flex; gap: 8px; margin-bottom: 12px; }
.form .btn.block + .dl, form + .dl { margin-top: 16px; }
fieldset.toggle-set { border: 1px solid var(--line); border-radius: 10px; padding: 6px 16px 4px; margin: 6px 0 16px; }
fieldset.toggle-set legend { padding: 0 6px; }
fieldset.toggle-set legend label { margin: 0; font-size: 14px; font-weight: 650; color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; padding: 7px 10px; }
.filters input[name=s] { min-width: 260px; flex: 1; max-width: 380px; }
.inline-l { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.hp { position: absolute; left: -9999px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.flash-ok { background: var(--teal-soft); border-color: #BFDDCF; color: #165A44; }
.flash-err { background: var(--rust-soft); border-color: #EBC5BB; color: #8A2E1B; }
.flash-info { background: var(--slate-soft); border-color: #CBD4E6; color: var(--ink); }
.flash a { font-weight: 650; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs.scroll { overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--teal); }
.tabs a.alert { color: var(--rust); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px; }
.kcol { background: #EEECE5; border-radius: 10px; display: flex; flex-direction: column; min-height: 320px; }
.kcol header { display: flex; align-items: center; gap: 7px; padding: 10px 12px 6px; font-size: 13px; flex-wrap: wrap; }
.kcol header em { font-style: normal; background: #fff; border-radius: 9px; padding: 0 7px; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.kcol header small { width: 100%; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kdrop { padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; border-radius: 0 0 10px 10px; transition: background .15s; }
.kdrop.over { background: #E2EEE8; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; color: var(--text); display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow); cursor: grab; }
.kcard:hover { border-color: #C7C2B4; color: var(--text); }
.kcard.dragging { opacity: .45; }
.kcard b { font-size: 13.5px; color: var(--ink); }
.kcard small { color: var(--muted); } .kcard .req { color: #4A4E57; }
.kmeta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; margin-top: 3px; }

/* Stepper */
.stepper { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.step { flex: 1; text-align: center; padding: 7px 8px; background: #ECEAE3; color: var(--muted); font-size: 12.5px; font-weight: 650; border-radius: 6px; min-width: 90px; }
.step.done { background: var(--teal-soft); color: var(--teal); }
.step.cur { background: var(--ink); color: #fff; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line-2); }
.timeline li { position: relative; padding: 0 0 16px 12px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--slate); }
.timeline li.k-stage::before, .timeline li.k-status::before { border-color: var(--violet); }
.timeline li.k-assign::before { border-color: var(--amber); }
.timeline li.k-ticket::before, .timeline li.k-created::before { border-color: var(--teal); background: var(--teal); }
.timeline li.k-email::before { border-color: #2F7FB8; }
.timeline p { margin: 3px 0 0; white-space: normal; overflow-wrap: anywhere; }
.timeline li.empty::before { display: none; }

/* Definition lists */
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.mini { list-style: none; padding: 0; margin: 0; }
.mini li { padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.mini li small { display: block; color: var(--muted); }
.mini li.hl { background: var(--amber-soft); margin: 0 -8px; padding: 7px 8px; border-radius: 6px; }
ul.plain { padding-left: 18px; margin: 8px 0 0; } ul.plain li { margin-bottom: 6px; }

/* Files */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 14px; }
.file { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; color: var(--text); background: #FBFAF7; }
.file img { width: 100%; height: 86px; object-fit: cover; display: block; }
.file .ext { height: 86px; display: grid; place-items: center; font-weight: 800; color: var(--slate); font-size: 18px; }
.file small { padding: 5px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* Quotation editor */
.tbl.items td { padding: 6px; } .tbl.items input, .tbl.items select { padding: 6px 7px; }
.tbl.items input.n { width: 90px; text-align: right; }
.tbl.items .amt { padding-top: 13px; }
.totals { margin: 14px 0 16px auto; max-width: 340px; display: flex; flex-direction: column; gap: 6px; }
.totals div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals input { width: 130px; text-align: right; }
.totals b { font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); padding-top: 8px; font-size: 17px; color: var(--ink); }
.totals.static { margin-top: 14px; }
.bulk-bar { display: flex; gap: 8px; align-items: center; margin-top: -4px; }
.bulk-bar select { width: auto; }
details.add-box summary, details.inline-edit summary { cursor: pointer; font-weight: 650; color: var(--teal); list-style: none; }
details.add-box[open] summary { margin-bottom: 12px; }
details.inline-edit { margin-top: 10px; } details.inline-edit[open] summary { margin-bottom: 10px; }

/* ---------- Auth / public ---------- */
body.auth { background: radial-gradient(1200px 600px at 10% -10%, #DDEBE5, transparent), var(--paper); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--ink); color: #D9DEEA; padding: 60px 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-side .brand { color: #fff; } .auth-side .brand small { color: #8E9AB8; }
.auth-side h2 { color: #fff; font-size: 30px; line-height: 1.2; margin: 26px 0 18px; max-width: 460px; }
.auth-side ul { padding-left: 18px; max-width: 440px; } .auth-side li { margin-bottom: 10px; color: #B9C2D6; }
.auth-card { align-self: center; justify-self: center; width: min(400px, 92vw); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: 0 10px 30px rgba(20,33,61,.08); }
.auth-card h1 { margin-bottom: 18px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 12.5px; margin-bottom: 14px; }
.support-wrap { max-width: 720px; margin: 0 auto; padding: 40px 18px; }
.support-wrap h1 { margin-bottom: 6px; }
.ticket-big { font-size: 30px; font-weight: 800; color: var(--teal); margin: 6px 0 14px; }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; } .checklist li { padding: 3px 0; } .checklist .ok { color: var(--teal); } .checklist .bad { color: var(--rust); font-weight: 600; }

/* ---------- Printable quotation ---------- */
body.print-doc { background: #E9E7E1; }
.print-bar { text-align: center; padding: 14px; }
.doc { background: #fff; max-width: 820px; margin: 0 auto 40px; padding: 40px 44px; box-shadow: 0 2px 12px rgba(0,0,0,.08); font-size: 13px; color: #1E2228; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--ink); padding-bottom: 16px; }
.doc-head p { margin: 2px 0; color: #4A4E57; }
.doc-head h1 { font-size: 26px; letter-spacing: .08em; color: var(--ink); } .doc-head .right { text-align: right; }
.doc-logo { max-height: 56px; max-width: 180px; margin-bottom: 6px; }
.meta { margin-left: auto; margin-top: 8px; border-collapse: collapse; } .meta td { padding: 2px 0 2px 14px; text-align: right; }
.doc-party { margin: 18px 0; padding: 12px 14px; background: #F7F6F2; border-radius: 6px; }
.doc-party small { display: block; margin-bottom: 3px; }
.doc-party small, .doc small { color: #6B6E76; font-weight: 700; letter-spacing: .06em; font-size: 10.5px; }
.doc-items { width: 100%; border-collapse: collapse; }
.doc-items th { background: var(--ink); color: #fff; text-align: left; padding: 8px; font-size: 11.5px; }
.doc-items td { padding: 8px; border-bottom: 1px solid #E7E4DC; }
.doc-items .num, .doc-items th:nth-last-child(-n+3) { text-align: right; }
.doc-foot { display: flex; justify-content: space-between; gap: 30px; margin-top: 16px; }
.doc-foot .words { flex: 1; }
.sum { border-collapse: collapse; min-width: 260px; } .sum td { padding: 4px 0; } .sum td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sum .grand td { border-top: 2px solid var(--ink); font-weight: 800; font-size: 15px; padding-top: 8px; }
.doc-terms { margin-top: 22px; font-size: 12px; color: #4A4E57; }
.doc-sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 40px; font-size: 12px; }
.doc-sign .sig { text-align: right; }
@media print {
  body.print-doc { background: #fff; } .no-print { display: none !important; }
  .doc { box-shadow: none; margin: 0; max-width: none; padding: 0; }
  @page { margin: 14mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-side { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(10,16,32,.4); z-index: 35; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .content { padding: 16px 12px 60px; }
  .grid2, .fgrid, .fgrid.four { grid-template-columns: 1fr; }
  .form-actions.end { grid-column: auto; }
  .kpis, .kpis.three { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi b { font-size: 19px; }
  .bar-row { grid-template-columns: 100px 1fr 26px; } .bar-row small { display: none; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } .auth-card { margin: 40px auto; }
  .filters input, .filters select, .filters input[name=s] { min-width: 0; flex: 1 1 140px; max-width: none; }
  .row { flex-direction: column; } .row .right { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .page-head h1 { font-size: 20px; }
  .doc { padding: 20px; } .doc-head, .doc-foot { flex-direction: column; }
}

/* ---------- v1.1: service reports, portal, automation ---------- */
.fgrid.three { grid-template-columns: repeat(3, 1fr); }
.sign-box legend { font-weight: 650; color: var(--ink); padding: 0 6px; }
.sigpad { border: 1px dashed #BFB9A8; border-radius: 10px; background: #fff; margin: 6px 0 12px; overflow: hidden; }
.sigpad canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.sigpad-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line-2); background: #FBFAF7; }
.rating { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 2px; margin-bottom: 8px; }
.rating span { order: 10; margin-right: 8px; font-size: 13px; font-weight: 600; color: #4A4E57; }
.rating input { display: none; }
.rating label { font-size: 28px; color: #D6D2C6; cursor: pointer; line-height: 1; margin: 0 !important; display: inline !important; }
.rating label:hover, .rating label:hover ~ label, .rating input:checked ~ label { color: #E3A008; }
.stars { color: #E3A008; letter-spacing: 1px; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.doc-block { margin: 14px 0 0; } .doc-block p { margin: 4px 0 0; }
.doc-sign.two { align-items: flex-start; border-top: 1px solid #E7E4DC; padding-top: 16px; }
.sig-img { display: block; max-width: 240px; max-height: 110px; margin: 6px 0 4px auto; }
.sig-blank { width: 220px; height: 70px; border-bottom: 1px solid #999; margin: 6px 0 6px auto; }
.doc-flash { max-width: 820px; margin: 12px auto 0; }
.print-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.timeline li.k-report::before { border-color: #2E8B57; background: #2E8B57; }
.timeline li.k-customer::before { border-color: #E3A008; background: #FFF4D6; }
.timeline li.k-escalation::before { border-color: var(--rust); background: var(--rust); }
.portal-top { background: var(--ink); color: #fff; }
.portal-top .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 18px; flex-wrap: wrap; }
.portal-top .brand { padding: 0; } .portal-top nav { flex-direction: row; gap: 4px; flex: 1; flex-wrap: wrap; }
.portal-top nav a { color: #C9D0E0; padding: 7px 11px; border-radius: 7px; font-weight: 600; }
.portal-top nav a.on, .portal-top nav a:hover { background: var(--ink-3); color: #fff; }
.portal-top .who { color: #9AA6C2; font-size: 13px; } .portal-top .who a { color: #fff; margin-left: 8px; }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; }
.code-box { background: var(--ink); color: #D9F2E7; font-family: var(--mono); font-size: 12.5px; padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre; }
@media (max-width: 860px) {
  .fgrid.three, .doc-grid { grid-template-columns: 1fr; }
  .portal-top nav { order: 3; width: 100%; }
}
label.check input[type=checkbox] { flex: none; }
.portal-top nav { flex-wrap: nowrap; } .portal-top nav a { white-space: nowrap; }
@media (max-width: 1000px) { .portal-top nav { flex-wrap: wrap; order: 3; width: 100%; } }

/* ---------- v2.0: inventory, documents, renewals, tasks, chat, analytics ---------- */
.green { color: var(--teal) !important; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.mb { margin-bottom: 14px; }
.pad { padding: 14px 16px; } .card-h.pad { margin: 0; border-bottom: 1px solid var(--line-2); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; align-items: start; }
.grid3 .bar-row { grid-template-columns: 120px 1fr 0 84px; }
a.kpi { display: block; color: inherit; transition: transform .1s, box-shadow .1s; }
a.kpi:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20,33,61,.08); color: inherit; }
.kpis.inline { margin: 4px 0 10px; } .kpis.inline .kpi { box-shadow: none; padding: 10px 12px; } .kpis.inline .kpi b { font-size: 19px; }
.nav-link { position: relative; }
.nav-badge { margin-left: auto; background: #3FC59A; color: var(--ink); font-style: normal; font-size: 11px; font-weight: 800; border-radius: 9px; padding: 0 7px; line-height: 18px; }
.nav-badge.amber { background: #F2B661; }
.gst-row { display: flex; gap: 6px; } .gst-row input { flex: 1; }
.gst-msg { display: block; font-weight: 500; margin-top: 2px; }
.code-area { width: 100%; font-size: 11.5px; background: #FBFAF7; margin-top: 8px; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; } .pager a { padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; } .pager a.on { background: var(--ink); color: #fff; }
.tbl.perm td.c, .tbl.perm th.c { text-align: center; width: 110px; }
.totals.wide { max-width: none; margin-left: 0; }
.sortable { list-style: none; padding: 0; margin: 6px 0; }
.sortable li { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; margin-bottom: 5px; cursor: grab; font-size: 13px; }
.sortable li.dragging { opacity: .5; }
.qr { background: #fff; display: inline-block; padding: 6px; border: 1px solid var(--line); border-radius: 8px; } .qr svg { display: block; width: 210px; height: 210px; }
/* statuses */
.b-received, .b-ts-won, .b-ts-verbal_yes { background: var(--teal-soft); color: var(--teal); }
.b-paused, .b-ts-on_hold, .b-ts-negotiating { background: var(--amber-soft); color: var(--amber); }
.b-returned, .b-ts-lost { background: #ECEBE6; color: #6B6E76; }
.b-ts-to_contact { background: #EEF0F4; color: #555F75; } .b-ts-awaiting_reply, .b-ts-in_discussion { background: var(--slate-soft); color: var(--slate); }
.b-rc-subscription { background: #E3F0FA; color: #2F6E9E; } .b-rc-rental { background: var(--violet-soft); color: var(--violet); } .b-rc-license { background: var(--amber-soft); color: var(--amber); }
.b-al-create { background: var(--teal-soft); color: var(--teal); } .b-al-update { background: var(--slate-soft); color: var(--slate); } .b-al-delete { background: var(--rust-soft); color: var(--rust); } .b-al-event { background: var(--violet-soft); color: var(--violet); }
/* recognition marquee */
.marquee { overflow: hidden; background: linear-gradient(90deg, #FFF6DD, #FDEBD3); border: 1px solid #F0D9A8; border-radius: 10px; margin-bottom: 14px; white-space: nowrap; }
.marquee-track { display: inline-block; padding: 9px 0; animation: marq 40s linear infinite; }
.marquee-track span { margin: 0 34px; color: #6B4A0F; }
@keyframes marq { from { transform: translateX(0); } to { transform: translateX(-50%); } }
/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .ylab { font-size: 10px; fill: var(--muted); text-anchor: end; } .chart .xlab { font-size: 10px; fill: var(--muted); }
.chart .line { fill: none; stroke: var(--teal); stroke-width: 2.4; stroke-linejoin: round; } .chart .area { fill: rgba(31,122,92,.10); }
.chart .dot { fill: #fff; stroke: var(--teal); stroke-width: 2; }
/* chat */
.chat { display: grid; grid-template-columns: 280px 1fr; gap: 16px; height: calc(100vh - 130px); min-height: 460px; }
.chat .card { margin: 0; }
.chat-side { display: flex; flex-direction: column; overflow: hidden; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: flex; align-items: center; gap: 9px; padding: 9px 14px; color: var(--text); border-bottom: 1px solid var(--line-2); }
.chat-item:hover { background: #FAF9F5; color: var(--text); } .chat-item.on { background: var(--teal-soft); }
.chat-item .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chat-item .unread { font-style: normal; background: var(--rust); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 700; padding: 0 6px; }
.chat-side select[multiple] { min-height: 120px; }
.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-head small { display: block; max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #FBFAF7; }
.msg { max-width: 70%; background: #fff; border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 7px 11px; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--teal-soft); border-color: #C6E2D6; border-radius: 12px 12px 4px 12px; }
.msg b { font-size: 12px; color: var(--slate); } .msg p { margin: 2px 0; white-space: normal; overflow-wrap: anywhere; } .msg small { color: var(--muted); font-size: 10.5px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form textarea { resize: none; min-height: 40px; max-height: 120px; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: auto; } .chat-side { max-height: 260px; } .chat-main { height: 70vh; }
  .msg { max-width: 88%; }
}
input[type=color] { width: 90px; height: 40px; padding: 3px; cursor: pointer; }

/* ---------- v2.2 grouped sidebar menu ---------- */
.nav-group { border-radius: 10px; }
.nav-group > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: #E4E8F2; font-weight: 650; font-size: 13.5px; user-select: none; margin-top: 4px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--ink-2); color: #fff; }
.nav-group > summary:focus-visible { outline: 2px solid #3FC59A; outline-offset: 1px; }
.nav-group > summary .chev { width: 15px; height: 15px; margin-left: auto; fill: none; stroke: currentColor; stroke-width: 2.4; opacity: .6; transition: transform .18s; flex: none; }
.nav-group > summary .nav-badge.sum { margin-left: auto; }
.nav-group > summary .nav-badge.sum + .chev { margin-left: 6px; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group.has-active > summary { color: #fff; }
.nav-group.has-active > summary .ic { color: #3FC59A; }
.nav-group[open] > summary .nav-badge.sum { display: none; }
.nav-group[open] > summary .nav-badge.sum + .chev { margin-left: auto; }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 17px; padding-left: 9px; border-left: 1px solid var(--ink-3); }
.nav-sub .nav-link { padding: 7px 10px; font-size: 13.5px; }
.nav-sub .nav-link .ic { width: 16px; height: 16px; }
.nav-tools { display: flex; gap: 6px; padding: 12px 6px 0; margin-top: auto; }
.nav-mini { flex: 1; background: transparent; border: 1px solid var(--ink-3); color: #8E9AB8; border-radius: 7px; padding: 5px 6px; font-size: 11.5px; cursor: pointer; }
.nav-mini:hover { color: #fff; border-color: #6F7C9C; }
.method-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 16px; }
.method-pick label { cursor: pointer; display: block; }
.method-pick input { position: absolute; opacity: 0; }
.method-pick span { display: block; height: 100%; border: 1.5px solid var(--line, #DDE2EA); border-radius: 10px; padding: 12px 14px; transition: border-color .15s, background .15s; }
.method-pick span small { display: block; color: var(--muted, #6B7280); font-size: 12.5px; margin-top: 4px; font-weight: 400; }
.method-pick span em { font-style: normal; font-size: 10.5px; vertical-align: 2px; }
.method-pick input:checked + span { border-color: #3FC59A; background: rgba(63,197,154,.08); box-shadow: inset 0 0 0 1px #3FC59A; }
.method-pick input:focus-visible + span { outline: 2px solid #3FC59A; outline-offset: 2px; }
.text-danger { color: #C2410C; }
@media (max-width: 860px) { .method-pick { grid-template-columns: 1fr; } }
