:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1c2430; --muted: #5d6878; --line: #e2e6ec; --soft: #f0f2f5;
  --accent: #c8102e; --accent-ink: #fff; --link: #1d5fa8;
  --warn: #9a5b00; --warn-bg: #fff3df; --ok: #1d7a46; --ok-bg: #e4f5ea;
  --info: #2457a6; --info-bg: #e7effb; --bad: #b3261e; --bad-bg: #fde8e7;
  --radius: 6px;
  font: 13px/1.45 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --card: #1b2129; --ink: #e7ebf0; --muted: #9aa5b4; --line: #2c3440; --soft: #222a34;
    --accent: #ff5a6e; --accent-ink: #12161c; --link: #7fb2ff;
    --warn: #f0a63a; --warn-bg: #3a2c12; --ok: #4cc584; --ok-bg: #163324;
    --info: #8ab4ff; --info-bg: #1b2b45; --bad: #ff8a80; --bad-bg: #3d1d1b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--link); }
.boot { padding: 48px; color: var(--muted); }
.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
       display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.brand .logo { height: 44px; width: auto; display: block; }
.brand span { padding-left: 10px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.brand.big { justify-content: center; margin-bottom: 4px; }
.brand.big .logo { height: 64px; }
.brand.big span { font-size: 15px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 6px 10px; border-radius: 5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { background: var(--soft); color: var(--ink); }
.tab.on { background: var(--soft); color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tab .n { font-size: 11px; color: var(--muted); margin-left: 4px; }
.tools { display: flex; align-items: center; gap: 8px; }
.search { width: 220px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }
.search:focus { background: var(--card); outline: 2px solid var(--link); outline-offset: -1px; }
.who { color: var(--muted); font-size: 12px; white-space: nowrap; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.banner { font-size: 12px; color: var(--info); background: var(--info-bg); border-radius: var(--radius); padding: 5px 10px; margin-bottom: 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.head h1 { font-size: 17px; }
.head p { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 5px;
       padding: 5px 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.alt { background: var(--card); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.alt:hover { background: var(--soft); filter: none; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--link); padding: 0; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: wait; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px;
        text-align: left; cursor: pointer; }
.tile:hover { border-color: var(--muted); }
.tile b { display: block; font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.bad b { color: var(--bad); } .tile.warn b { color: var(--warn); } .tile.ok b { color: var(--ok); }

/* Panels & tables */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.panel > h2 { font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel > h2 .n { color: var(--muted); font-weight: 400; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; background: var(--soft); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--soft); }
td.nw { white-space: nowrap; }
.num { font-weight: 600; color: var(--link); white-space: nowrap; }
.empty { padding: 10px 12px; color: var(--muted); }

/* Pills */
.pill { display: inline-block; padding: 0 7px; border-radius: 99px; font-size: 11.5px; line-height: 18px; border: 1px solid var(--line); white-space: nowrap; }
.pill.hold { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.go { background: var(--info-bg); color: var(--info); border-color: transparent; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pri { font-size: 12px; white-space: nowrap; }
.pri.urgent { color: var(--bad); font-weight: 700; } .pri.high { color: var(--warn); font-weight: 600; }
.pri.low { color: var(--muted); }
.due { color: var(--bad); font-weight: 600; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 2px 10px; cursor: pointer; font-size: 12px; }
.chip.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.tag { display: inline-block; font-size: 11px; background: var(--soft); border-radius: 3px; padding: 0 5px; margin: 1px 2px 1px 0; }

/* Tech load */
.load { padding: 7px 12px; border-bottom: 1px solid var(--line); }
.load:last-child { border-bottom: 0; }
.load div { display: flex; justify-content: space-between; }
.bar { height: 4px; background: var(--soft); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.w0 { width: 0 } .w1 { width: 12% } .w2 { width: 25% } .w3 { width: 37% } .w4 { width: 50% }
.w5 { width: 62% } .w6 { width: 75% } .w7 { width: 87% } .w8 { width: 100% }

/* Dispatch board */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.col header { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.col header .ct { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.col header .tags { margin-top: 3px; }
.card { margin: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; background: var(--card); width: calc(100% - 12px); text-align: left; display: block; }
.card:hover { border-color: var(--muted); }
.card h3 { font-size: 12.5px; font-weight: 600; margin: 1px 0; }
.retired { opacity: .6; }

/* Inventory */
.inv { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 12px; align-items: start; }
.whl { padding: 4px 0 8px; }
.whg { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px 2px; }
.whi { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; border-left: 2px solid transparent;
       background: none; padding: 5px 12px; cursor: pointer; }
.whi:hover { background: var(--soft); }
.whi.on { background: var(--soft); border-left-color: var(--accent); font-weight: 600; }
.whi .sub { font-weight: 400; }
.whi.unit { padding-left: 26px; position: relative; }
.whi.unit::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 50%; width: 7px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
th.r, td.r { text-align: right; }
.line.sl { grid-template-columns: 1fr 80px 26px; }

/* Admin */
.listadd { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.listadd input { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; background: var(--card); }
.listadd .err { flex-basis: 100%; }
.lvals { list-style: none; margin: 0; padding: 0; }
.lvals li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.lvals li.off span:first-child { color: var(--muted); text-decoration: line-through; }
dl.facts.roles, dl.facts.sysd { grid-template-columns: 140px 1fr; padding: 8px 12px 12px; margin: 0; }
.temppw { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; align-items: baseline; background: var(--soft); border-radius: 6px; padding: 12px; }
.temppw b { font-size: 16px; letter-spacing: .03em; }
button.who { color: var(--muted); font-weight: 500; }

/* Read-only accounts: hide controls that change records (the server refuses them anyway) */
.ro [data-a="new"]:not([data-id="pwd"]), .ro [data-a="act"], .ro [data-a="eqedit"], .ro #drawer form, .ro #eqdrawer form,
.ro .listadd, .ro [data-a="lact"], .ro [data-a="lmove"] { display: none !important; }

/* Activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 6px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 120px 150px 1fr; gap: 10px; }
.feed li:last-child { border-bottom: 0; }

/* Dialogs */
dialog { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 0; }
dialog::backdrop { background: rgba(10, 14, 20, .35); }
.modal { width: min(620px, calc(100vw - 24px)); border-radius: 8px; max-height: calc(100vh - 40px); }
.drawer { overflow-x: hidden; margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(620px, 100vw); border-radius: 0; border-width: 0 0 0 1px; }
.dh { position: sticky; top: 0; background: var(--card); padding: 10px 14px; border-bottom: 1px solid var(--line);
      display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; z-index: 1; }
.dh h2 { font-size: 15px; }
.x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.db { padding: 12px 14px; }
.db > p { margin-top: 8px; white-space: pre-wrap; }
.sec { border-top: 1px solid var(--line); padding: 10px 14px; }
.sec > h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
dl.facts { display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; margin: 8px 0 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.blockers { margin: 6px 0; padding: 6px 10px 6px 24px; background: var(--warn-bg); color: var(--warn); border-radius: 5px; }
.okbox { margin: 6px 0; padding: 6px 10px; background: var(--ok-bg); color: var(--ok); border-radius: 5px; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes time { color: var(--muted); font-size: 11.5px; display: block; }

/* Forms */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.f { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f input[type=checkbox] { width: auto; }
.f input:not([type=checkbox]), .f select, .f textarea { color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; font-size: 13px; width: 100%; }
.f textarea { min-height: 56px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid var(--link); outline-offset: -1px; }
.check { display: flex; flex-direction: row; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 3px 10px; }
.err { color: var(--bad); font-size: 12px; min-height: 0; }
.err:not(:empty) { margin-top: 8px; }
.err ul { margin: 2px 0 0; padding-left: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.line { display: grid; grid-template-columns: 1fr 1.4fr 70px 26px; gap: 6px; margin-bottom: 6px; align-items: end; }
.qty { display: grid; grid-template-columns: 1fr 80px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.inline { background: var(--soft); border-radius: 6px; padding: 10px; margin-top: 8px; }

/* Equipment record */
.msg { margin: 8px 14px 0; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: var(--info-bg); color: var(--info); }
.f .msg { margin: 4px 0 0; }
.sech { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sech h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
dl.facts.two { grid-template-columns: 96px 1fr 96px 1fr; margin-top: 0; }
dl.facts.two dd.wide { grid-column: 2 / -1; }
.eqcalls { margin-top: 8px; }
.spacer { flex: 1; }
table.hist td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.hist td:first-child { padding-left: 0; }

/* Quick add (inline inside a form) */
.quick { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; background: var(--soft);
         border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 12px; }
.quick .full, .quick > b { grid-column: 1 / -1; }
.quick .actions { margin-top: 0; }
.quick .err:not(:empty) { margin-top: 0; }
select option[value="__new"] { font-weight: 600; }

/* Sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px; display: grid; gap: 10px; }
.login h1 { font-size: 16px; }

#toast { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card);
         padding: 7px 14px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }

@media (max-width: 900px) {
  .grid2, .inv { grid-template-columns: minmax(0, 1fr); }
  .search { width: 140px; }
  .who { display: none; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tools { margin-left: auto; }
  .form, .quick { grid-template-columns: 1fr; }
  dl.facts.two { grid-template-columns: 96px 1fr; }
  dl.facts.two dd.wide { grid-column: 2; }
  .feed li { grid-template-columns: 1fr; gap: 0; }
  .line { grid-template-columns: 1fr 1fr; }
  main { padding: 12px 16px; }
}
