:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16191f;
  --ink-2: #4a5160;
  --ink-3: #7b8394;
  --line: #e3e6eb;
  --line-2: #d1d5dc;
  --accent: #0f5c8c;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0f7;
  --emergency: #c8231c;
  --emergency-soft: #fdecea;
  --immediate: #b85c00;
  --immediate-soft: #fff3e3;
  --routine: #3d6b4f;
  --routine-soft: #eaf3ed;
  --ok: #1f7a4a;
  --ok-soft: #e7f5ed;
  --warn-soft: #fff7e0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 8px; }
small, .muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #12202c; color: #c9d3de; padding: 16px 12px; position: sticky; top: 0; height: 100vh;
        display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700;
         font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #2d8fd5; display: grid; place-items: center;
              font-size: 14px; color: #fff; }
.company-name { font-size: 12px; color: #8ea0b3; padding: 0 8px 12px; border-bottom: 1px solid #22394b;
                margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a { color: #c9d3de; padding: 8px 10px; border-radius: 6px; display: flex; align-items: center; gap: 10px;
          font-weight: 500; }
.side a:hover { background: #1b3041; text-decoration: none; color: #fff; }
.side a.on { background: #214159; color: #fff; }
.side .sect { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f8499;
              padding: 14px 10px 4px; }
.side .count { margin-left: auto; font-size: 12px; background: var(--emergency); color: #fff; border-radius: 10px;
               padding: 0 7px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #22394b; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot form { margin: 6px 0 0; }
.linkbtn { background: none; border: 0; padding: 0; color: #8ec5ef; cursor: pointer; font: inherit; }
.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 24px 28px 64px; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px;
             flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

/* ---------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
           justify-content: space-between; gap: 12px; }
.panel-b { padding: 16px; }
.panel + .panel { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }

/* ---------- stat tiles */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        box-shadow: var(--shadow); color: inherit; display: block; }
a.tile:hover { text-decoration: none; border-color: var(--line-2); }
.tile .k { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.tile .v { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile.em { border-left: 4px solid var(--emergency); }
.tile.im { border-left: 4px solid var(--immediate); }
.tile.od .v { color: var(--emergency); }

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
       border-radius: 6px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit;
       font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.2; min-height: 36px; }
.btn:hover { background: #f7f8fa; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0c4f79; }
.btn.danger { color: var(--emergency); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.block { width: 100%; }
label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 4px; color: var(--ink-2); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search],
input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; font: inherit;
  background: #fff; color: var(--ink); min-height: 36px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #7db7e0; outline-offset: 1px; border-color: var(--accent); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: 16px; height: 16px; }
.inline-form { display: inline; margin: 0; }

/* ---------- flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; font-weight: 500;
         word-break: break-word; }
.flash.ok { background: var(--ok-soft); border-color: #b5dfc6; color: #13532f; }
.flash.error { background: var(--emergency-soft); border-color: #f3b9b4; color: #8a1812; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px;
         border-radius: 999px; white-space: nowrap; line-height: 18px; }
.p-emergency { background: var(--emergency); color: #fff; }
.p-immediate { background: var(--immediate-soft); color: var(--immediate); box-shadow: inset 0 0 0 1px #f2cf9f; }
.p-routine { background: var(--routine-soft); color: var(--routine); }
.s-badge { background: #eef1f5; color: var(--ink-2); }
.s-received { background: #eef1f5; color: #344054; }
.s-quote_submitted { background: #f3ecfd; color: #6b3fb3; }
.s-scheduled { background: var(--accent-soft); color: var(--accent); }
.s-in_progress { background: #fff3e3; color: #9a4d00; }
.s-completed { background: var(--ok-soft); color: var(--ok); }
.s-canceled { background: #f2f2f2; color: #777; text-decoration: line-through; }
.dept { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.age { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; color: var(--ink-2); }
.age.overdue { color: var(--emergency); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #eef1f5; color: var(--ink-2); }
.tag.tenant { background: #fdf2e9; color: #93400f; }
.tag.overdue { background: var(--emergency-soft); color: var(--emergency); }

/* ---------- tables / ticket rows */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 8px 12px;
     border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8fafc; }
tr.row-emergency td:first-child { box-shadow: inset 3px 0 0 var(--emergency); }
tr.row-immediate td:first-child { box-shadow: inset 3px 0 0 var(--immediate); }
.tnum { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.ttitle { font-weight: 600; color: var(--ink); }
.tsub { font-size: 12px; color: var(--ink-3); }
.table-wrap { overflow-x: auto; }

.group-h { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #fafbfc;
           border-bottom: 1px solid var(--line); font-weight: 650; }
.group-h .n { color: var(--ink-3); font-weight: 500; }
.group + .group { border-top: 1px solid var(--line); }

/* ---------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input[type=search] { width: auto; min-width: 130px; }
.filters input[type=search] { min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 12px; color: var(--ink-2); font-weight: 550; font-size: 13px; border-left: 1px solid var(--line-2); }
.seg a:first-child { border-left: 0; }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }

/* ---------- board */
.board { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(230px, 1fr)); gap: 12px; overflow-x: auto;
         padding-bottom: 8px; }
.col { background: #eceef2; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col-h { display: flex; justify-content: space-between; font-weight: 650; font-size: 13px; padding: 2px 4px 10px; }
.card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
        margin-bottom: 8px; color: inherit; box-shadow: var(--shadow); }
.card:hover { text-decoration: none; border-color: var(--line-2); }
.card.pe { border-left: 4px solid var(--emergency); }
.card.pi { border-left: 4px solid var(--immediate); }
.card .ttitle { font-size: 13px; margin: 4px 0; }

/* ---------- pipeline stepper */
.stepper { display: flex; gap: 0; margin: 4px 0 0; }
.step { flex: 1; position: relative; padding-top: 22px; text-align: center; font-size: 12px; color: var(--ink-3); }
.step::before { content: ""; position: absolute; top: 8px; left: 0; right: 0; height: 3px; background: var(--line); }
.step:first-child::before { left: 50%; }
.step:last-child::before { right: 50%; }
.step .pt { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 15px; height: 15px;
            border-radius: 50%; background: #fff; border: 3px solid var(--line-2); z-index: 1; }
.step.done::before { background: var(--accent); }
.step.done .pt { background: var(--accent); border-color: var(--accent); }
.step.cur .pt { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.cur, .step.done { color: var(--ink); font-weight: 600; }
.step .when { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; }
.step.skipped { color: var(--ink-3); font-weight: 400; }
.step.skipped .pt { border-style: dashed; }

/* ---------- ticket detail */
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.desc { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 12px;
        margin-top: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 8px 0; }
.timeline .ic { width: 26px; height: 26px; border-radius: 50%; background: #eef1f5; display: grid; place-items: center;
                font-size: 12px; color: var(--ink-2); }
.timeline .ic.note { background: var(--accent-soft); color: var(--accent); }
.timeline .ic.status { background: var(--ok-soft); color: var(--ok); }
.timeline .body { font-size: 13px; }
.timeline .body .note-text { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px;
                              padding: 8px 10px; margin-top: 4px; }
.timeline .internal { font-size: 11px; color: var(--immediate); font-weight: 600; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.quote { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.quote .amt { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- unit history */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.unit-cell { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
             color: inherit; }
.unit-cell:hover { text-decoration: none; border-color: var(--accent); }
.unit-cell .un { font-weight: 650; }
.unit-cell .us { font-size: 11px; color: var(--ink-3); }
.unit-cell.w0 { border-left: 4px solid var(--emergency); }
.unit-cell.w1 { border-left: 4px solid var(--immediate); }
.unit-cell.w2 { border-left: 4px solid var(--accent); }
.bars .bar-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 10px; align-items: center; font-size: 13px;
                 margin-bottom: 6px; }
.bars .track { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 4px; }

/* ---------- dashboard matrix */
.matrix td, .matrix th { text-align: right; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix a { color: inherit; display: block; }
.matrix .zero { color: #c3c8d0; }
.matrix .hot { color: var(--emergency); font-weight: 700; }
.pipe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.pipe a { padding: 12px; text-align: center; color: inherit; border-right: 1px solid var(--line); }
.pipe a:last-child { border-right: 0; }
.pipe a:hover { background: #fafbfc; text-decoration: none; }
.pipe .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pipe .k { font-size: 12px; color: var(--ink-2); }
.agebars { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding: 0 4px; }
.agebars a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%;
             color: inherit; text-decoration: none; }
.agebars .b { width: 100%; background: #9cc3df; border-radius: 4px 4px 0 0; min-height: 2px; }
.agebars a.old .b { background: var(--immediate); }
.agebars .n { font-size: 12px; font-weight: 650; margin-bottom: 3px; }
.agebars .l { font-size: 11px; color: var(--ink-3); margin-top: 6px; text-align: center; white-space: nowrap; }
.feed { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border: 0; }

/* ---------- my jobs (mobile first) */
.jobs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.job { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.job.pe { border-top: 4px solid var(--emergency); }
.job.pi { border-top: 4px solid var(--immediate); }
.job .where { font-size: 17px; font-weight: 700; }
.job .what { margin: 6px 0 10px; }
.job .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.job .go { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- empty / auth / public */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty h2 { margin-bottom: 6px; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 400px; }
.auth .brand { color: var(--ink); justify-content: center; padding-bottom: 20px; font-size: 20px; }
.auth .panel-b { padding: 24px; }
.public-wrap { max-width: 620px; margin: 0 auto; padding: 24px 16px 60px; }
.public-head { text-align: center; margin-bottom: 20px; }
.public-head .co { font-size: 13px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.prio-opts { display: grid; gap: 8px; }
.prio-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: 8px;
            padding: 10px 12px; cursor: pointer; background: #fff; font-weight: 400; color: var(--ink); }
.prio-opt input { margin-top: 3px; }
.prio-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.prio-opt b { display: block; }
.hp { position: absolute; left: -9999px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: var(--mono); font-size: 12px; }
.landing { max-width: 880px; margin: 0 auto; padding: 60px 20px; }
.landing h1 { font-size: 40px; letter-spacing: -.02em; }
.landing .lead { font-size: 18px; color: var(--ink-2); margin: 14px 0 26px; max-width: 620px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 40px; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 50; height: 100vh; width: 100%; }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
            background: #12202c; color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar .brand { padding: 0; font-size: 15px; }
  .menu-btn { background: none; border: 1px solid #3b556b; color: #fff; border-radius: 6px; padding: 6px 10px; font: inherit; }
  .close-menu { display: block !important; }
  .page { padding: 16px 16px 60px; }
  .g2, .g3, .features { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none !important; }
  .facts { grid-template-columns: 110px 1fr; }
  .filters select, .filters input[type=search] { flex: 1 1 140px; min-width: 0; }
  .stepper .step { font-size: 10px; }
  .stepper .step .when { display: none; }
  .pipe { grid-template-columns: repeat(2, 1fr); }
  .pipe a:nth-child(2) { border-right: 0; }
  .pipe a:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .jobs { grid-template-columns: 1fr; }
  .landing h1 { font-size: 30px; }
}
.close-menu { display: none; }

/* consistent columns across grouped ticket tables */
.grouped table.tt { table-layout: fixed; }
.tt .c-num { width: 64px; } .tt .c-dept { width: 150px; } .tt .c-prio { width: 120px; }
.tt .c-status { width: 160px; } .tt .c-asg { width: 150px; } .tt .c-age { width: 60px; }
@media (max-width: 820px) { .tt .c-num { width: 48px; } .tt .c-prio { width: 96px; } .tt .c-age { width: 44px; } }
.prio-opt small { display: block; line-height: 1.4; }
.grid > .panel + .panel, .split > .panel + .panel { margin-top: 0; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flash.warn { background: var(--warn-soft); border-color: #f1d98a; color: #6b4e00; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: #eef1f5; }
.photo-grid figcaption { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
input[type=file] { font: inherit; font-size: 13px; padding: 6px; border: 1px dashed var(--line-2); border-radius: 6px; width: 100%; background: #fafbfc; }

.copy { flex-wrap: wrap; }
.copy input { flex: 1 1 260px; }
.setup { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
.setup li { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.setup li.done { color: var(--ink-3); font-weight: 500; text-decoration: line-through; }
.setup .box { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center;
              font-size: 12px; color: #fff; flex: none; }
.setup li.done .box { background: var(--ok); border-color: var(--ok); }
@media (max-width: 820px) { .setup { grid-template-columns: 1fr; } }
