:root {
  --ink: #17231f; --ink2: #43514c; --muted: #75817c; --rule: #dfe2dc; --paper: #f5f3ee; --card: #fff;
  --brass: #b08b52; --brass-lt: #f3ead9; --teal: #2b7a70; --teal-lt: #e2f0ed;
  --good: #2e7d4f; --good-lt: #e3f2e8; --warn: #a86a12; --warn-lt: #fbefd9; --bad: #b3372b; --bad-lt: #f9e3e0;
  --band: #14211d; --radius: 10px; --shadow: 0 1px 2px rgba(20, 33, 29, .06), 0 2px 8px rgba(20, 33, 29, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ece9; --ink2: #b9c2be; --muted: #8b9692; --rule: #2c3834; --paper: #0f1714; --card: #17211e;
    --brass: #d2ad73; --brass-lt: #2c2618; --teal: #5fb3a7; --teal-lt: #15302b;
    --good: #6cc08b; --good-lt: #15291d; --warn: #e0a54a; --warn-lt: #2e2412; --bad: #ec7b6e; --bad-lt: #331916;
    --band: #0b1210; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 32px; } }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--ink2); }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------- top band and navigation ---------- */
.band { background: var(--band); color: #f1ece2; }
.band .in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; color: #f1ece2; font-weight: 650; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand small { font-weight: 400; color: #b9b1a1; margin-left: 2px; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a { color: #d8d1c3; padding: 6px 10px; border-radius: 7px; font-size: 14px; }
.topnav a.on, .topnav a:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
.band form { margin: 0; }
.band .logout { background: none; border: 0; color: #b9b1a1; font: inherit; font-size: 13px; cursor: pointer; padding: 6px; }
@media (min-width: 900px) { .topnav { display: flex; } .band .logout { margin-left: 4px; } }
@media (max-width: 899px) { .band .logout { margin-left: auto; } }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; color: var(--muted);
               font-size: 11px; }
.bottomnav a.on { color: var(--teal); }
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.scan { color: var(--brass); }
@media (min-width: 900px) { .bottomnav { display: none; } }

/* ---------- layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.head { display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 200px; }
.head .sub { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px;
        margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 > .card { margin-bottom: 0; } .grid2 { margin-bottom: 14px; } }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; border-bottom: 1px solid var(--rule);
        scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 12px; color: var(--ink2); white-space: nowrap; border-bottom: 2px solid transparent; font-size: 14px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--rule); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; color: var(--ink); }
a.row:hover { text-decoration: none; background: color-mix(in srgb, var(--paper) 60%, transparent); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; font-size: 13px; color: var(--muted); flex: none; }
.chev { color: var(--muted); flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--rule); }
.dot.up { background: var(--good); box-shadow: 0 0 0 3px var(--good-lt); }
.dot.down { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-lt); }
.dot.never { background: var(--muted); opacity: .5; }
.jobno { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--brass);
         font-weight: 600; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase;
             letter-spacing: .04em; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule); }
table.t td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
.scrollx { overflow-x: auto; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px;
        border-radius: 99px; background: var(--rule); color: var(--ink2); white-space: nowrap; }
.pill.good { background: var(--good-lt); color: var(--good); }
.pill.warn { background: var(--warn-lt); color: var(--warn); }
.pill.bad { background: var(--bad-lt); color: var(--bad); }
.pill.teal { background: var(--teal-lt); color: var(--teal); }
.pill.brass { background: var(--brass-lt); color: var(--brass); }

/* ---------- messages ---------- */
.flash { border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--good-lt); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.flash.warn { background: var(--warn-lt); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash.err { background: var(--bad-lt); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.note { background: var(--brass-lt); border-left: 3px solid var(--brass); padding: 10px 12px; border-radius: 0 8px 8px 0;
        font-size: 14px; margin: 10px 0; }

/* ---------- forms ---------- */
form { margin: 0; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 12px 0 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); border-radius: 8px; padding: 9px 11px;
  min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.45;
                min-height: 460px; white-space: pre; tab-size: 2; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--teal) 60%, transparent); outline-offset: 1px;
                                            border-color: var(--teal); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.fields { display: grid; gap: 0 12px; }
@media (min-width: 600px) { .fields.two { grid-template-columns: 1fr 1fr; } .fields.three { grid-template-columns: 1fr 1fr 1fr; } }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input, .inline > select { flex: 1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--teal); }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { margin: 0; }
.days input { display: none; }
.days span { display: inline-block; min-width: 46px; text-align: center; padding: 8px 6px; border-radius: 8px;
             border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); font-weight: 600; color: var(--ink2); cursor: pointer; }
.days input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: 15px;
       font-weight: 600; padding: 9px 16px; min-height: 42px; border-radius: 8px; border: 1px solid transparent;
       background: var(--teal); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.sec { background: var(--card); color: var(--ink); border-color: color-mix(in srgb, var(--ink) 22%, transparent); }
.btn.brass { background: var(--brass); }
.btn.danger { background: var(--card); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.small { font-size: 13px; padding: 5px 10px; min-height: 32px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); cursor: pointer; }
.linkbtn.danger { color: var(--bad); }
details > summary { cursor: pointer; color: var(--teal); font-weight: 600; font-size: 14px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }
details.danger > summary { color: var(--bad); }

/* ---------- checklist ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--rule); }
.steps li:first-child { border-top: 0; }
.steps .tick { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px;
               font-weight: 700; border: 1.5px solid var(--rule); color: var(--muted); }
.steps li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.steps li.next .tick { border-color: var(--brass); color: var(--brass); }
.steps a { color: var(--ink); }
.steps li.done a { color: var(--ink2); }
.steps li.next a { font-weight: 600; }

/* ---------- key display ---------- */
.keybox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 17px; letter-spacing: .02em;
          background: var(--paper); border: 1px dashed var(--brass); border-radius: 8px; padding: 10px 12px; word-break: break-all;
          display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.keybox span { flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.yaml { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; overflow: auto;
           font-size: 12.5px; line-height: 1.45; max-height: 520px; margin: 0; }

/* ---------- week ---------- */
.week .day { padding: 8px 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 48px 1fr; gap: 10px; }
.week .day:first-child { border-top: 0; }
.week .dn { font-weight: 700; color: var(--ink2); padding-top: 3px; }
.sess { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.sess .time { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; white-space: nowrap; }
.zsw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---------- photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; background: var(--rule); }
.photos figcaption { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* ---------- scanner ---------- */
.scanner { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 50; display: none; flex-direction: column;
           align-items: center; justify-content: center; padding: 16px; color: #fff; }
.scanner.open { display: flex; }
.scanner video { width: 100%; max-width: 520px; border-radius: 12px; background: #000; }
.scanner .frame { position: relative; width: 100%; max-width: 520px; }
.scanner .frame::after { content: ""; position: absolute; inset: 18%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 14px;
                         box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25); pointer-events: none; }
.scanner .msg { margin: 14px 0; text-align: center; font-size: 15px; min-height: 22px; }
.scanner .btn.sec { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
.eui-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; letter-spacing: .04em;
             text-transform: uppercase; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.login { max-width: 380px; margin: 8vh auto 0; }
.qr svg { width: 220px; height: 220px; background: #fff; border-radius: 8px; display: block; margin: 10px auto; }
.fab { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 19; border-radius: 99px;
       box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
@media (min-width: 900px) { .fab { display: none; } }
.note code { word-break: break-all; }
