:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2327;
  --muted: #6b7378;
  --line: #e3e1da;
  --accent: #1f5f8b;
  --ok: #2e7d4f;
  --ok-bg: #e5f2ea;
  --warn: #9a5b00;
  --warn-bg: #fbefd9;
  --bad: #a3322a;
  --bad-bg: #f8e3e1;
  --bond: #4b3f8f;
  --bond-bg: #ebe8f8;
  --select: #eef4f9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181a;
    --panel: #1d2124;
    --ink: #e4e6e7;
    --muted: #8f989d;
    --line: #2e3438;
    --accent: #7db4dc;
    --ok: #7fcf9c;
    --ok-bg: #1f3428;
    --warn: #f0bd6a;
    --warn-bg: #3a2e19;
    --bad: #f0928a;
    --bad-bg: #3b2220;
    --bond: #b7acf2;
    --bond-bg: #2b2741;
    --select: #22303a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.app { min-height: 100vh; display: flex; flex-direction: column; }

.top {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.top h1 { font-size: 16px; margin: 0; letter-spacing: .02em; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  border: 0; background: none; color: var(--muted); padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--select); color: var(--accent); font-weight: 600; }
.conn { font-size: 12px; color: var(--muted); }
.conn.up::before { content: "● "; color: var(--ok); }
.conn.down::before { content: "● "; color: var(--warn); }

.flash {
  margin: 12px 20px 0; padding: 10px 14px; border-radius: 6px; cursor: pointer;
}
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

.body { display: flex; gap: 16px; padding: 16px 20px; align-items: flex-start; }
main { flex: 1; min-width: 0; }

table { border-collapse: collapse; width: 100%; }
.grid { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grid th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em;
}
.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.row { cursor: pointer; }
.row:hover td { background: var(--select); }
.row.selected td { background: var(--select); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.damaged { color: var(--bad); font-size: 12px; }

.chip {
  display: inline-block; padding: 1px 8px; margin: 0 4px 2px 0; border-radius: 10px;
  font-size: 12px; white-space: nowrap; background: var(--line);
}
.chip.bond { background: var(--bond-bg); color: var(--bond); }
.chip.released, .chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.domestic { background: var(--line); color: var(--muted); }
.chip.hold, .chip.blocked { background: var(--bad-bg); color: var(--bad); }
.chip.clock.ok { background: var(--line); color: var(--muted); }
.chip.clock.due-soon { background: var(--warn-bg); color: var(--warn); }
.chip.clock.expired { background: var(--bad-bg); color: var(--bad); }
.chip.set { background: var(--bond-bg); color: var(--bond); }
.chip.unset { background: var(--line); color: var(--muted); }
.chip.closed { background: var(--line); color: var(--muted); }

.card {
  width: 440px; flex: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; position: sticky; top: 64px;
  max-height: calc(100vh - 80px); overflow: auto;
}
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card h2 { margin: 0; font-size: 18px; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
.close { border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.mini td { padding: 2px 8px 2px 0; }

.actions { display: flex; flex-direction: column; gap: 6px; }
.form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.form label { width: 110px; color: var(--muted); font-size: 12px; }
.form input[type=number] { width: 70px; }
.form input:not([type]) { width: 150px; }
input, select {
  font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); color: var(--ink);
}
button {
  font: inherit; padding: 3px 10px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--panel);
}
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; }
.tab, .close { border: 0; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.timeline .when { color: var(--muted); font-size: 12px; margin-right: 8px; font-variant-numeric: tabular-nums; }
.timeline li.struck > div:first-child { text-decoration: line-through; color: var(--muted); }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.bill { margin-bottom: 16px; }
.bill h3 { margin: 8px 0; font-size: 15px; }
main > div > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* --- sign-in ------------------------------------------------------------ */
.signin { max-width: 340px; margin: 12vh auto; padding: 0 16px; }
.signin h1 { font-size: 22px; margin-bottom: 20px; }

/* --- navigation groups: DC | customs shed | office ----------------------- */
.tabs { flex-wrap: wrap; }
.tab.shed { margin-left: 0; }
.tab.dc + .tab.shed, .tab.shed + .tab.office { margin-left: 14px; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; }

/* --- forms -------------------------------------------------------------- */
.form.col { flex-direction: column; align-items: stretch; gap: 10px; }
.form.col label { width: auto; }
.big { font-size: 17px; padding: 10px 12px; min-height: 44px; }
.huge { font-size: 28px; padding: 10px 14px; min-height: 60px; width: 100%; }
.big-label { font-size: 14px; color: var(--muted); }
button.primary { background: var(--accent); }
button.huge.primary { font-weight: 600; }
.hidden { display: none; }
.photo-btn {
  display: flex; align-items: center; justify-content: center; border: 1px dashed var(--accent);
  border-radius: 6px; color: var(--accent); cursor: pointer; width: auto !important;
}
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }

/* --- dock (phone/tablet) ------------------------------------------------- */
.dock { max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel select.big, .panel input.big { width: 100%; }
details.new summary { cursor: pointer; color: var(--accent); margin: 10px 0; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.prow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.prow select.big { width: auto; flex: 1; }

/* --- free-time notices ---------------------------------------------------- */
.notices { display: flex; flex-direction: column; gap: 10px; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.notice pre { white-space: pre-wrap; font: inherit; margin: 0 0 8px; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .body { padding: 10px 12px; flex-direction: column; }
  .card { width: 100%; position: static; max-height: none; }
  .grid { display: block; overflow-x: auto; }
}

button:disabled { opacity: .4; cursor: default; }

.form.col input, .form.col select, .form.col button { width: 100%; }
.warn { color: var(--warn); font-weight: 600; }
@media (max-width: 720px) {
  .top .tabs { order: 3; width: 100%; }
  .top .who { margin-left: auto; }
}
