/* Service Desk — one stylesheet, no framework. Colours are roles (custom properties) so light/dark swap in one place. */
:root {
  color-scheme: light;
  --bg: #f3f2ee; --surface: #fcfcfb; --surface-2: #f0efea; --line: #dcdad2; --line-2: #c9c6bc;
  --ink: #15191c; --ink-2: #4c4f4d; --ink-3: #777872;
  --brand: #0d5c63; --brand-2: #094a50; --on-brand: #fff; --brand-tint: #e2efee;
  --nav: #10242b; --nav-ink: #c6d3d4; --nav-active: #1d3a43;
  --good: #1a7a48; --good-bg: #e1f1e7; --warn: #99560a; --warn-bg: #fbecd2; --crit: #b3261e; --crit-bg: #fbe3e0; --info: #1f5fae; --info-bg: #e1ecfa; --mute-bg: #e9e8e2;
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #e4e2da;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,25,28,.06), 0 4px 16px rgba(20,25,28,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121516; --surface: #1a1d1e; --surface-2: #222627; --line: #2f3435; --line-2: #414748;
    --ink: #eef0ee; --ink-2: #c0c4c1; --ink-3: #8e9390;
    --brand: #3aa6ad; --brand-2: #58bcc2; --on-brand: #06282b; --brand-tint: #17333a;
    --nav: #0c1113; --nav-ink: #aebbbc; --nav-active: #1b2c31;
    --good: #5fcb8f; --good-bg: #16301f; --warn: #f0b45c; --warn-bg: #38290f; --crit: #f28b82; --crit-bg: #3d1a17; --info: #8ab8f5; --info-bg: #17293f; --mute-bg: #2a2e2f;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2c3132;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.55rem; letter-spacing: -.015em; font-weight: 650; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
p { margin: 0 0 .7em; }
a { color: var(--brand); text-underline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); } .small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ----- shell ----- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-ink); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 650; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(140deg, #2fb3a6, #0d5c63); display: grid; place-items: center; font: 700 13px var(--mono); color: #fff; flex: none; }
.brand small { display: block; font-weight: 400; font-size: .72rem; color: var(--nav-ink); letter-spacing: .02em; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-size: .93rem; }
.nav a:hover { background: var(--nav-active); color: #fff; }
.nav a[aria-current="page"] { background: var(--nav-active); color: #fff; box-shadow: inset 3px 0 0 #2fb3a6; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #ffffff1a; font-size: .85rem; }
.nav-foot b { color: #fff; display: block; font-weight: 600; }
.nav-foot button { background: none; border: 0; color: var(--nav-ink); padding: 6px 0 0; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; margin-right: 12px; }
.nav-foot button:hover { color: #fff; }
main { padding: 28px clamp(16px, 3.2vw, 40px) 60px; min-width: 0; max-width: 1320px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; font-size: .92rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { font-size: .85rem; color: var(--ink-3); margin-bottom: 6px; display: block; text-decoration: none; }
.crumb:hover { color: var(--brand); }

/* ----- controls ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 .9rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--crit); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: progress; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
textarea { min-height: 92px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--brand); flex: none; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: .93rem; color: var(--ink); margin: 0; cursor: pointer; }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.req::after { content: " *"; color: var(--crit); }
.grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(12, 1fr); }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card > h2 { margin-bottom: 14px; }
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-size: 1.02rem; font-weight: 650; margin-bottom: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: end; }
.filters > div { flex: 1 1 150px; max-width: 240px; }
.filters > .grow { flex: 2 1 240px; max-width: none; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--brand); border-color: var(--brand); }

/* ----- chips ----- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; background: var(--mute-bg); color: var(--ink-2); }
.chip.open { background: var(--info-bg); color: var(--info); }
.chip.in_progress, .chip.ok, .chip.met { background: var(--good-bg); color: var(--good); }
.chip.second_line { background: var(--brand-tint); color: var(--brand); }
.chip.waiting, .chip.risk { background: var(--warn-bg); color: var(--warn); }
.chip.breach, .chip.critical { background: var(--crit-bg); color: var(--crit); }
.chip.high { background: var(--warn-bg); color: var(--warn); }

/* ----- tables ----- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; padding: 8px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.link { cursor: pointer; }
.tbl tr.link:hover td { background: var(--surface-2); }
.tbl .r { text-align: right; }
.tbl td strong { font-weight: 600; }
.empty { text-align: center; padding: 44px 16px; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; font-size: .88rem; color: var(--ink-3); }

/* ----- ticket detail ----- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--ink-3); } dl.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.clock { font: 650 1.9rem/1.1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding-bottom: 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 12px; top: 26px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.dot { width: 26px; height: 26px; border-radius: 50%; background: var(--mute-bg); display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--ink-2); }
.dot.closed { background: var(--good-bg); color: var(--good); } .dot.escalated { background: var(--brand-tint); color: var(--brand); } .dot.email, .dot.whatsapp { background: var(--info-bg); color: var(--info); }
.timeline .meta { font-size: .8rem; color: var(--ink-3); }
.timeline .body { margin-top: 4px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: .9rem; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); font-size: .8rem; display: flex; flex-direction: column; }
.file img, .file video { width: 100%; height: 108px; object-fit: cover; display: block; background: #000; }
.file .doc { height: 108px; display: grid; place-items: center; font: 700 1rem var(--mono); color: var(--ink-3); text-transform: uppercase; }
.file .cap { padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file .cap a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file .cap span { color: var(--ink-3); display: flex; justify-content: space-between; gap: 6px; }
.file button { background: none; border: 0; color: var(--crit); cursor: pointer; font: inherit; padding: 0; }
.progress { height: 6px; background: var(--mute-bg); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.suggest { position: relative; }
.suggest ul { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); }
.suggest li button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font: inherit; color: inherit; cursor: pointer; }
.suggest li button:hover, .suggest li button:focus { background: var(--surface-2); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: var(--ink); font-size: .9rem; border-left: 3px solid var(--info); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); }

/* ----- dashboard ----- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font: 650 1.75rem/1.15 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 6px; }
.kpi .d { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.dash { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.dash > .card { margin: 0; } .d6 { grid-column: span 6; } .d4 { grid-column: span 4; } .d3 { grid-column: span 3; } .d2 { grid-column: span 2; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--ink-3); }
.chart .bar { cursor: default; } .chart .bar:hover, .chart .bar:focus { opacity: .8; outline: none; }
.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 9px 12px; align-items: center; font-size: .9rem; }
.bars .track { height: 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bars .track i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .track i.zero { min-width: 0; }
.weeknav { display: flex; align-items: center; gap: 6px; }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); font-size: .8rem; padding: 5px 9px; border-radius: 6px; transform: translate(-50%, -130%); white-space: nowrap; }
details.tableview { margin-top: 10px; font-size: .85rem; } details.tableview summary { cursor: pointer; color: var(--ink-3); }

/* ----- dialogs, toasts, auth ----- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10,15,18,.5); }
dialog form { padding: 22px; } dialog h2 { font-size: 1.15rem; margin-bottom: 16px; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--surface); padding: 11px 14px; border-radius: 9px; font-size: .9rem; box-shadow: var(--shadow); }
.toast.err { background: var(--crit); color: #fff; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 20% -10%, #2fb3a622, transparent), var(--nav); }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth h1 { font-size: 1.35rem; margin: 14px 0 4px; }
.auth form > div { margin-top: 14px; } .auth .btn { width: 100%; margin-top: 20px; }
.perm th, .perm td { text-align: center; } .perm th:first-child, .perm td:first-child { text-align: left; }
.perm input { margin: auto; display: block; }

/* ----- small screens: bottom tab bar, tables become cards ----- */
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); } .d4, .d3, .d2 { grid-column: span 6; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 20; gap: 0; justify-content: space-around; }
  .nav .brand, .nav-foot { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; min-width: 0; text-align: center; }
  .nav a[aria-current="page"] { box-shadow: inset 0 3px 0 #2fb3a6; }
  main { padding: 18px 14px 96px; }
  .mobile-user { display: flex !important; }
  .c3, .c4, .c6, .c8 { grid-column: span 12; }
  .filters > div { max-width: none; flex-basis: 45%; }
  table.tbl.cards thead { display: none; }
  table.tbl.cards tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.tbl.cards td { display: flex; justify-content: space-between; gap: 14px; border: 0; padding: 3px 0; text-align: right; }
  table.tbl.cards td::before { content: attr(data-label); color: var(--ink-3); font-size: .8rem; text-align: left; flex: none; }
  table.tbl.cards td.lead { display: block; text-align: left; font-size: 1rem; } table.tbl.cards td.lead::before { display: none; }
}
.mobile-user { display: none; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--ink-3); margin-bottom: 14px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .nav, .actions, #toasts { display: none !important; } .shell { display: block; } body { background: #fff; } }
@media (max-width: 760px) {
  table.tbl.cards td:not(.lead) br, table.tbl.cards td:not(.lead) .small { display: none; }
  table.tbl.cards td > * { min-width: 0; overflow-wrap: anywhere; }
  .mobile-user > span:last-child { display: flex; flex: none; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .page-head .actions .btn { flex: 1 1 auto; }
}

/* ===== v1.1: devices, planned maintenance, period filter, customer history, calendar, maps ===== */
.nav a .sm { display: none; }
.chip.maint { background: #ece6fa; color: #5a3fb0; text-decoration: none; }
@media (prefers-color-scheme: dark) { .chip.maint { background: #2b2444; color: #b7a6f2; } }
.card > h2 .chip { margin-left: 6px; vertical-align: 2px; }
.devrow { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.devrow + .devrow { margin-top: 10px; }
.dev-remove { flex: none; padding: 0 11px; color: var(--ink-3); }
.counter-row { display: grid; grid-template-columns: 1fr 180px; gap: 10px; align-items: center; margin-top: 8px; font-size: .92rem; }
.report-box { margin-top: 18px; padding: 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); }
.map { width: 100%; height: 220px; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; display: block; }
.period-box { flex: 0 1 auto !important; max-width: none !important; }
.period { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period select { width: auto; min-width: 110px; }
.period .btn { padding: 0 11px; }
.plabel { font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; padding: 0 4px; white-space: nowrap; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; }
details.hist { padding: 0; }
details.hist > summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 14px 20px 14px 44px; cursor: pointer; list-style: none; position: relative; }
details.hist > summary::-webkit-details-marker { display: none; }
details.hist > summary::before { content: ""; position: absolute; left: 20px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: translateY(-65%) rotate(-45deg); transition: transform .15s; }
details.hist[open] > summary::before { transform: translateY(-75%) rotate(45deg); }
details.hist > summary:hover { background: var(--surface-2); border-radius: var(--radius); }
.hist-name { display: flex; flex-direction: column; gap: 1px; font-size: 1.02rem; }
.hist-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hist-body { padding: 4px 20px 18px; border-top: 1px solid var(--line); }
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav strong { min-width: 190px; text-align: center; font-size: 1.02rem; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; padding: 0 8px 8px; }
.cal-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-day { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 104px; padding: 6px; min-width: 0; }
.cal.week .cal-day { min-height: 260px; }
.cal-day.out { background: var(--surface-2); } .cal-day.out .cal-date { color: var(--ink-3); }
.cal-date { font-size: .82rem; font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.cal.month .dow { display: none; }
.cal-day.today .cal-date { color: var(--brand); } .cal-day.today { box-shadow: inset 0 3px 0 var(--brand); }
.cal-item { background: var(--brand-tint); border-left: 3px solid var(--brand); border-radius: 5px; padding: 5px 7px; margin-top: 4px; font-size: .78rem; line-height: 1.3; overflow: hidden; }
.cal-item.has-ticket { background: #ece6fa; border-color: #5a3fb0; }
@media (prefers-color-scheme: dark) { .cal-item.has-ticket { background: #2b2444; border-color: #b7a6f2; } }
.cal-item a { display: block; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item a strong, .cal-item a span { display: block; overflow: hidden; text-overflow: ellipsis; }
.cal-item a.small { color: var(--brand); font-weight: 600; margin-top: 2px; font-size: .74rem; }
@media (max-width: 760px) {
  .nav a .lg { display: none; } .nav a .sm { display: inline; }
  .counter-row { grid-template-columns: 1fr; }
  .cal-head { display: none; } .cal-grid { grid-template-columns: 1fr; }
  .cal.month .dow { display: inline; } .cal-day, .cal.week .cal-day { min-height: 0; }
  .cal.month .cal-day.out { display: none; }
  .cal.month .cal-day:not(:has(.cal-item)):not(.today) { display: none; }
  .period-box { flex-basis: 100% !important; }
  details.hist > summary { padding-right: 14px; } .hist-body { padding: 4px 14px 14px; }
}

/* ===== v1.2: live vehicles (Navirec) ===== */
#vmap { height: min(56vh, 520px); min-height: 320px; background: var(--surface-2); z-index: 0; }
.vmark, .vjob { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font: 650 11px/1 var(--font); padding: 5px 8px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.35); border: 2px solid #fff; }
.vmark { background: #4c4f4d; color: #fff; display: flex; gap: 5px; align-items: center; }
.vmark.driving { background: #1a7a48; } .vmark.idling { background: #99560a; } .vmark.offline, .vmark.towing { background: #b3261e; }
.vjob { background: #fff; color: #0d5c63; border-color: #0d5c63; border-radius: 6px; }
.leaflet-container { font-family: var(--font); } .leaflet-popup-content { font-size: .85rem; line-height: 1.45; }
.gm-pop { font: 13px/1.45 var(--font); color: #15191c; } .gm-pop a { color: #0d5c63; } .gm-pop .muted { color: #777872; }

/* ===== v1.4: work calendar by employee ===== */
.wcal-wrap { padding: 0; overflow-x: auto; }
.wcal { min-width: calc(170px + var(--days) * 170px); }
.wcal-row { display: grid; grid-template-columns: 170px repeat(var(--days), minmax(170px, 1fr)); border-bottom: 1px solid var(--line); }
.wcal-row:last-child { border-bottom: 0; }
.wcal-row > div { padding: 10px; border-right: 1px solid var(--line); min-width: 0; }
.wcal-row > div:last-child { border-right: 0; }
.wcal-head > div { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; background: var(--surface-2); }
.wcal-head .today { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.wcal-who { display: flex; flex-direction: column; gap: 2px; background: var(--surface); position: sticky; left: 0; z-index: 1; }
.wcal-cell.today { background: color-mix(in srgb, var(--brand-tint) 45%, transparent); }
.wcal-cell .cal-item:first-child { margin-top: 0; }
.wcal-free { color: var(--line-2); }
.cal-kind { display: block; font-size: .7rem; font-weight: 650; letter-spacing: .02em; color: var(--ink-2); margin-bottom: 2px; }
.cal-item.late { background: var(--crit-bg); border-color: var(--crit); } .cal-item.late .cal-kind { color: var(--crit); }
.cal-item.done { opacity: .6; border-color: var(--line-2); background: var(--surface-2); }
.cal-item.svc { background: var(--warn-bg); border-color: var(--warn); }
.wcal .cal-item a strong, .wcal .cal-item a span { white-space: normal; }
@media (max-width: 760px) {
  .wcal { min-width: 0; } .wcal-head { display: none; }
  .wcal-row { grid-template-columns: 1fr; padding: 10px 0; }
  .wcal-row > div { border-right: 0; padding: 4px 14px; }
  .wcal-who { position: static; flex-direction: row; align-items: baseline; gap: 8px; }
  .wcal-cell::before { content: attr(data-day); display: block; font-size: .72rem; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  .wcal-cell:not(:has(.cal-item)) { display: none; }
}

/* ===== v1.5: hour-ruler calendar, manual jobs, live onsite status ===== */
button.cal-item { display: block; width: 100%; text-align: left; font: inherit; font-size: .78rem; line-height: 1.3; color: var(--ink); cursor: pointer; border-top: 0; border-right: 0; border-bottom: 0; }
button.cal-item strong, button.cal-item > span:not(.cal-kind) { display: block; overflow: hidden; text-overflow: ellipsis; }
button.cal-item:hover { filter: brightness(.96); }
.cal-item.job { background: var(--info-bg); border-color: var(--info); }
.tg-wrap { padding: 0; overflow-x: auto; }
.tg { min-width: calc(64px + var(--cols) * 150px); }
.tg-row { display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(150px, 1fr)); }
.tg-head > div { padding: 10px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 1px; font-size: .9rem; min-width: 0; }
.tg-head > div:first-child, .tg-all > div:first-child { border-left: 0; }
.tg-head .today { box-shadow: inset 0 3px 0 var(--brand); } .tg-head .today strong { color: var(--brand); }
.tg-all > div { padding: 6px; border-bottom: 1px solid var(--line-2); border-left: 1px solid var(--line); min-height: 34px; min-width: 0; }
.tg-all .cal-item:first-child { margin-top: 0; }
.tg-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; line-height: 1.25; }
.tg-ruler { position: relative; }
.tg-ruler span { position: absolute; right: 8px; transform: translateY(-50%); font-size: .72rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tg-ruler span:first-child { transform: translateY(2px); } .tg-ruler span:last-child { transform: translateY(-100%); }
.tg-col { position: relative; border-left: 1px solid var(--line); cursor: cell; min-width: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 100% var(--pxh), 100% calc(var(--pxh) / 2); }
.tg-col.today, .tg-all .today { background-color: color-mix(in srgb, var(--brand-tint) 40%, transparent); }
.tg-col .cal-item { position: absolute; margin: 0; overflow: hidden; z-index: 1; box-shadow: 0 0 0 1px var(--surface); }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--crit); z-index: 2; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--crit); }
.wcal-who a { color: inherit; text-decoration: none; } .wcal-who a:hover strong { color: var(--brand); text-decoration: underline; }
.onsite-now { margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; font-weight: 650; font-size: .93rem; background: var(--mute-bg); color: var(--ink-2); }
.onsite-now.ok, .onsite-now.met { background: var(--good-bg); color: var(--good); } .onsite-now.open { background: var(--info-bg); color: var(--info); } .onsite-now.risk { background: var(--warn-bg); color: var(--warn); }
#onsite-badge:empty { display: none; }

/* ===== v1.5.2: view attachments inside the app ===== */
.file .thumb { display: block; width: 100%; padding: 0; border: 0; background: #000; cursor: zoom-in; color: inherit; }
.file .thumb.doc { background: var(--surface-2); cursor: pointer; }
.file .cap strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file .file-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; justify-content: flex-start; }
.file .file-actions .btn { color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); padding: 0 9px; min-height: 28px; font-size: .78rem; }
.file .file-actions .del { margin-left: auto; }
.files { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
dialog.viewer { width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.viewer-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.viewer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 16px; }
.viewer-head h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.viewer-body { background: var(--surface-2); border-radius: 8px; min-height: 200px; display: grid; place-items: center; overflow: auto; padding: 8px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100vh - 190px); display: block; border-radius: 4px; }
.viewer-body iframe { width: 100%; height: calc(100vh - 220px); min-height: 360px; border: 0; background: #fff; border-radius: 4px; }
.viewer-body pre { width: 100%; margin: 0; padding: 12px; max-height: calc(100vh - 200px); overflow: auto; font: .82rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; align-self: start; }

/* ===== v1.6: spare parts rows ===== */
.sprow { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 8px; margin-top: 8px; } .sprow:first-child { margin-top: 0; }
@media (max-width: 560px) { .sprow { grid-template-columns: 1fr auto; } .sprow .sp-name { grid-column: 1 / -1; } }

/* ===== v1.6: spare parts rows ===== */
.sprow { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 8px; margin-top: 8px; } .sprow:first-child { margin-top: 0; }
@media (max-width: 560px) { .sprow { grid-template-columns: 1fr auto; } .sprow .sp-name { grid-column: 1 / -1; } }

/* ===== v1.7: coloured ticket sections, Google address suggestions ===== */
.tsec { padding-top: 0; overflow: hidden; }
.tsec > h2 { margin: 0 -20px 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.tsec-open > h2 { background: #fdebd3; color: #7a4407; } .tsec-open { border-top: 3px solid #e8962e; }
.tsec-progress > h2 { background: #ddebfb; color: #174f93; } .tsec-progress { border-top: 3px solid #3d85d8; }
.tsec-closed > h2 { background: #dff2e4; color: #17603a; } .tsec-closed { border-top: 3px solid #36a566; }
.tsec > h2 .chip { background: rgba(255,255,255,.7); color: inherit; }
@media (prefers-color-scheme: dark) {
  .tsec-open > h2 { background: #3a2a12; color: #f3bd72; } .tsec-progress > h2 { background: #15293f; color: #9cc4f5; } .tsec-closed > h2 { background: #15301f; color: #7dd3a0; }
  .tsec > h2 .chip { background: rgba(0,0,0,.25); }
}
.addr-suggest { position: relative; }
.addr-suggest ul { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); }
.addr-suggest li button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font: inherit; color: inherit; cursor: pointer; }
.addr-suggest li button:hover, .addr-suggest li button:focus { background: var(--surface-2); outline: none; }
.addr-by { font-size: .7rem; color: var(--ink-3); text-align: right; padding: 2px 8px 0; }
dialog:has(.addr-suggest ul) { overflow: visible; }

/* ===== v1.8: drag and drop in the work calendar ===== */
.cal-item[draggable="true"] { cursor: grab; } .cal-item.dragging { opacity: .45; }
.tg-col.drop-ok { background-color: color-mix(in srgb, var(--brand-tint) 70%, transparent); }
.tg-allcell.drop-ok { outline: 2px dashed var(--brand); outline-offset: -3px; }
.tg-drop { position: absolute; left: 0; right: 0; height: 2px; background: var(--brand); z-index: 3; pointer-events: none; }
.tg-drop::after { content: attr(data-time); position: absolute; left: 4px; top: -20px; background: var(--brand); color: var(--on-brand); font: 650 .72rem var(--font); padding: 2px 6px; border-radius: 4px; }
.cal-settime { margin-top: 16px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.cal-settime > div { display: flex; flex-wrap: wrap; gap: 8px; } .cal-settime input { flex: 1 1 200px; width: auto; }

/* ===== v1.9: collapsible ticket sections ===== */
details.tsec > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -20px; padding: 12px 20px; cursor: pointer; list-style: none; border-bottom: 1px solid var(--line); }
details.tsec > summary::-webkit-details-marker { display: none; }
details.tsec:not([open]) > summary { border-bottom: 0; } details.tsec:not([open]) { padding-bottom: 0; }
details.tsec[open] > summary { margin-bottom: 14px; }
details.tsec > summary h2 { margin: 0; padding: 0; border: 0; background: none; color: inherit; }
.tsec-open > summary { background: #fdebd3; color: #7a4407; } .tsec-progress > summary { background: #ddebfb; color: #174f93; } .tsec-closed > summary { background: #dff2e4; color: #17603a; }
.tsec > summary .chip { background: rgba(255,255,255,.7); color: inherit; }
.tsec-toggle { width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-135deg); transition: transform .15s; margin-right: 4px; flex: none; }
details.tsec:not([open]) .tsec-toggle { transform: rotate(45deg); }
details.tsec > summary:focus-visible { outline-offset: -2px; }
@media (prefers-color-scheme: dark) {
  .tsec-open > summary { background: #3a2a12; color: #f3bd72; } .tsec-progress > summary { background: #15293f; color: #9cc4f5; } .tsec-closed > summary { background: #15301f; color: #7dd3a0; }
  .tsec > summary .chip { background: rgba(0,0,0,.25); }
}
.page-head .seg .btn { padding: 0 11px; }
.tbl.eng th { white-space: normal; vertical-align: bottom; line-height: 1.25; } .tbl.eng td.lead { white-space: nowrap; }

/* ===== v1.10: password checklist, account removal ===== */
.pwrules { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; font-size: .82rem; color: var(--ink-3); }
.pwrules li { padding-left: 22px; position: relative; }
.pwrules li::before { content: "○"; position: absolute; left: 3px; }
.pwrules li.ok { color: var(--good); } .pwrules li.ok::before { content: "✓"; font-weight: 700; }
.plain-list { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; }
