/* Panelboard — a control-panel visual language for a facilities engineer's own work.
   Blueprint navy ground, enamel panel labels, amber annunciator lamps. */

:root {
  --ink:      #0D1520;
  --panel:    #151F2E;
  --panel-2:  #1C2839;
  --line:     #27374C;
  --chalk:    #E6EDF5;
  --slate:    #7E93AC;
  --signal:   #F2A33C;
  --flag:     #E5654E;
  --ok:       #4EA98A;

  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --pad: 16px;
  --r: 10px;
  --topbar-h: 208px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink);
  color: var(--chalk);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body::before {   /* faint drafting grid */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .38;
  background-image:
    linear-gradient(rgba(126,147,172,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126,147,172,.055) 1px, transparent 1px);
  background-size: 26px 26px;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ gate --- */
.gate {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: var(--ink); padding: var(--pad);
}
.gate-card { width: 100%; max-width: 330px; text-align: center; }
.gate-mark {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: .32em; color: var(--signal); margin-bottom: 22px;
}
.gate-copy { color: var(--slate); font-size: 14px; margin: 0 0 18px; }
.gate-error { color: var(--flag); font-size: 13px; margin-top: 14px; }
#gate-token {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px; margin-bottom: 10px;
  font-family: var(--mono); font-size: 15px;
}

/* ---------------------------------------------------------- topbar --- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  background: linear-gradient(var(--ink) 78%, rgba(13,21,32,.94));
  border-bottom: 1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) var(--pad) 10px;
  backdrop-filter: blur(12px);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wordmark {
  font-family: var(--display); font-size: 19px; font-weight: 700;
  letter-spacing: -.02em; margin: 2px 0 0;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 9px; color: var(--slate); border: 1px solid transparent;
}
.icon-btn:hover { color: var(--chalk); border-color: var(--line); }
.chip-toggle {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .12em;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--slate); background: var(--panel);
}
.chip-toggle[data-scope="work"] { color: var(--signal); border-color: rgba(242,163,60,.45); }
.chip-toggle[data-scope="home"] { color: var(--ok); border-color: rgba(78,169,138,.45); }

/* ------------------------------------------- annunciator (signature) --- */
.annunciator {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  margin: 12px 0 10px; padding: 4px;
  background: #0A111B; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.ann {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 6px; border-radius: 5px;
  background: #111A27; border: 1px solid #1E2B3C; color: #55677D;
  transition: color .18s, border-color .18s, background .18s;
}
.ann-label {
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; white-space: nowrap;
}
.ann-count { font-family: var(--mono); font-size: 18px; font-weight: 600; line-height: 1; }
.ann.lit          { color: var(--signal); border-color: rgba(242,163,60,.4); background: rgba(242,163,60,.07); }
.ann.lit-alarm    { color: var(--flag);   border-color: rgba(229,101,78,.45); background: rgba(229,101,78,.09); }
.ann.lit-ok       { color: var(--ok);     border-color: rgba(78,169,138,.35); background: rgba(78,169,138,.07); }

/* -------------------------------------------------------- view rail --- */
.viewrail {
  display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none;
  margin-bottom: 8px; padding-bottom: 1px;
}
.viewrail::-webkit-scrollbar { display: none; }
.vtab {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 7px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; color: var(--slate);
}
.vtab.is-active { color: var(--ink); background: var(--chalk); font-weight: 600; }

.searchwrap { position: relative; }
#search {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 14px;
}
#search::placeholder { color: #56687E; }

/* ------------------------------------------------------------ list --- */
.list {
  position: relative; z-index: 1;
  padding: calc(var(--topbar-h) + 8px) var(--pad) 128px;
  min-height: 100%;
}
.daygroup {
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: #55677D;
  margin: 20px 0 8px; display: flex; align-items: center; gap: 10px;
}
.daygroup::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.daygroup:first-child { margin-top: 0; }
.daygroup.hot { color: var(--flag); }

.item {
  position: relative; display: flex; gap: 11px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 12px 11px 14px; margin-bottom: 6px;
  overflow: hidden; transition: background .15s, opacity .2s;
}
.item:hover { background: var(--panel-2); }
/* urgency rail — the annunciator's quiet echo on every row */
.item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line);
}
.item.due-soon::before { background: var(--signal); }
.item.overdue::before  { background: var(--flag); }
.item.is-note::before  { background: #3C5170; }
.item.is-done { opacity: .42; }
.item.is-done::before { background: var(--ok); }

.tick {
  flex: 0 0 auto; width: 19px; height: 19px; margin-top: 2px; border-radius: 5px;
  border: 1.5px solid #3E5470; display: grid; place-items: center; color: transparent;
  transition: border-color .15s, background .15s, color .15s;
}
.tick:hover { border-color: var(--signal); }
.is-done .tick { background: var(--ok); border-color: var(--ok); color: var(--ink); }

.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 500; word-wrap: break-word; }
.is-done .item-title { text-decoration: line-through; }
.item-body {
  font-size: 13px; color: var(--slate); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 6px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em;
}
.meta-due { color: var(--slate); }
.meta-due.soon { color: var(--signal); }
.meta-due.late { color: var(--flag); font-weight: 600; }
.tag {
  color: #92A7C0; background: rgba(146,167,192,.11);
  padding: 2px 6px; border-radius: 4px;
}
.tag.scope-home { color: var(--ok); background: rgba(78,169,138,.12); }
.pri { color: var(--flag); font-weight: 600; letter-spacing: .1em; }
.wo { color: var(--signal); text-decoration: none; border-bottom: 1px dotted rgba(242,163,60,.5); }
.recur-mark { color: #6B8098; }

/* calendar rows */
.evt { display: flex; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.evt-time {
  font-family: var(--mono); font-size: 11px; color: var(--signal);
  flex: 0 0 62px; padding-top: 2px;
}
.evt-title { font-size: 14px; }
.evt-loc { font-size: 12px; color: var(--slate); margin-top: 2px; }

.empty { text-align: center; padding: 56px 20px; color: var(--slate); }
.empty-mark {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  color: #3E5470; margin-bottom: 10px;
}
.empty p { margin: 0; font-size: 14px; }

/* ----------------------------------------------------- capture bar --- */
.capturebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(13,21,32,0), var(--ink) 26%);
}
.capture-row {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid #33455C;
  border-radius: 13px; padding: 5px 5px 5px 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,.5);
}
.capture-row:focus-within { border-color: var(--signal); }
#capture { flex: 1; background: none; border: 0; padding: 9px 0; font-size: 16px; min-width: 0; }
#capture:focus { outline: none; }
#capture::placeholder { color: #63768C; }
.mic { width: 38px; height: 38px; }
.btn-send {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 9px; background: var(--signal); color: #10192a;
}
.parse-hint {
  font-family: var(--mono); font-size: 11px; color: var(--signal);
  background: rgba(242,163,60,.09); border: 1px solid rgba(242,163,60,.28);
  border-radius: 8px; padding: 6px 11px; margin-bottom: 7px;
  letter-spacing: .04em; animation: rise .16s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 40;
  background: var(--chalk); color: var(--ink);
  font-size: 13.5px; font-weight: 500; padding: 9px 16px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: 90vw; text-align: center;
}

/* --------------------------------------------------------- sheets ---- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(6,10,16,.72); }
.sheet-panel {
  position: relative; width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 8px var(--pad) calc(22px + env(safe-area-inset-bottom));
  animation: slideup .2s ease-out;
}
@keyframes slideup { from { transform: translateY(18px); opacity: .6; } }
@media (min-width: 720px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet-panel { max-width: 560px; border-radius: 14px; border: 1px solid var(--line); }
  .list { max-width: 820px; margin: 0 auto; }
  .capturebar { max-width: 820px; margin: 0 auto; }
  .topbar { padding-left: max(var(--pad), calc(50vw - 410px)); padding-right: max(var(--pad), calc(50vw - 410px)); }
}
.sheet-grip { width: 34px; height: 4px; border-radius: 2px; background: #33455C; margin: 4px auto 14px; }
.sheet-title {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--slate); margin: 0 0 16px;
}
.d-title {
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line);
  font-family: var(--display); font-size: 19px; font-weight: 600; padding: 0 0 9px; margin-bottom: 12px;
}
.d-title:focus { outline: none; border-color: var(--signal); }
.d-body {
  width: 100%; background: #101A27; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-size: 14px; resize: vertical; margin-bottom: 14px;
}

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.field { display: block; }
.field > span {
  display: block; font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .15em; text-transform: uppercase; color: #55677D; margin-bottom: 5px;
}
.field input, .field select {
  width: 100%; background: #101A27; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font-size: 14px;
}
.seg-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-bottom: 12px; }
.seg { display: flex; background: #101A27; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button {
  flex: 1; padding: 7px 4px; border-radius: 6px; font-size: 12.5px; color: var(--slate);
}
.seg button.on { background: var(--panel-2); color: var(--chalk); font-weight: 600; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-primary {
  flex: 1; background: var(--signal); color: #10192a; font-weight: 600;
  padding: 12px; border-radius: 9px; font-size: 15px;
}
.btn-danger {
  background: rgba(229,101,78,.12); color: var(--flag);
  border: 1px solid rgba(229,101,78,.3); padding: 12px 18px; border-radius: 9px; font-size: 15px;
}
.btn-ghost {
  border: 1px solid var(--line); color: var(--chalk); background: var(--panel-2);
  padding: 6px 12px; border-radius: 7px; font-size: 13px;
}
.btn-ghost.danger { color: var(--flag); }

.setting { border-top: 1px solid var(--line); padding: 15px 0; }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14.5px; font-weight: 600; margin-bottom: 5px;
}
.setting-copy { font-size: 13px; color: var(--slate); margin: 0; }
.copyrow { display: flex; gap: 8px; align-items: center; margin-top: 9px; }
.copyrow code {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 10.5px; color: var(--signal);
  background: #101A27; border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
[hidden]{display:none !important}
