/* Tria Products brand (Brand Identity Manual): Meteorite Purple #3A245D, Tealish Blue #394E80,
   grey #555555, Roboto. The logo is only ever shown white on the purple/blue brand band, as the manual allows.
   Layout: one narrow working column — branded sign-in card, then a searchable ledger with an edit sheet. */
@font-face { font-family: "Roboto"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/roboto-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/roboto-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/roboto-latin-700-normal.woff2") format("woff2"); }
:root {
  --meteorite: #3A245D;          /* brand: Meteorite Purple */
  --tealish: #394E80;            /* brand: Tealish Blue */
  --brand-band: linear-gradient(100deg, #3A245D 0%, #394E80 100%);
  --bg: #ececef;
  --surface: #ffffff;
  --sunken: #f1f0f4;
  --line: #d9d8df;
  --fg: #1f1d26;
  --muted: #555555;              /* brand grey */
  --accent: #3A245D;
  --accent-fg: #ffffff;
  --accent-soft: #ebe6f3;
  --link: #394E80;
  --shard: #e2e1e7;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, Menlo, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131119; --surface: #1d1a26; --sunken: #262232; --line: #353044;
    --fg: #eceaf2; --muted: #a9a6b4; --accent: #7a5cb3; --accent-fg: #ffffff;
    --accent-soft: #2c2440; --link: #9fb3e3; --shard: #1a1722; --danger: #f2948a; --danger-soft: #3a1f22;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 48px;
  min-height: 100vh;
}
/* The angled "shard" shapes from the Tria letterhead, kept faint behind the page. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(162deg, transparent 0 62%, var(--shard) 62% 74%, transparent 74%),
    linear-gradient(118deg, transparent 0 70%, var(--shard) 70% 80%, transparent 80%);
}

/* Brand band: logo on Meteorite Purple → Tealish Blue */
.brand-band { background: var(--brand-band); color: #ffffff; }
.brand-band .logo { display: block; height: 44px; width: auto; max-width: 100%; align-self: flex-start; flex: none; object-fit: contain; }
.lock { padding: 0 !important; overflow: hidden; }
.lock .brand-band { padding: 22px 28px 18px; display: flex; flex-direction: column; gap: 10px; }
.lock .brand-band .app { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; font-weight: 500; }
.lock-body { padding: 22px 28px 26px; display: flex; flex-direction: column; gap: 16px; }
.appbar { border-radius: 12px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.appbar .id { display: flex; align-items: center; gap: 16px; min-width: 0; flex-wrap: wrap; }
.appbar .logo { height: 38px; }
.appbar .who { display: flex; flex-direction: column; gap: 1px; padding-left: 16px; border-left: 1px solid rgb(255 255 255 / 0.3); min-width: 0; }
.appbar .who strong { font-size: 1rem; font-weight: 500; }
.appbar .who span { font-size: 0.8rem; opacity: 0.8; }
.appbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.appbar button { background: rgb(255 255 255 / 0.12); border-color: rgb(255 255 255 / 0.35); color: #ffffff; }
.appbar button:hover { background: rgb(255 255 255 / 0.22); border-color: #ffffff; }
.appbar button.primary { background: #ffffff; color: var(--meteorite); border-color: #ffffff; }
.appbar button:focus-visible { outline-color: #ffffff; }
@media (max-width: 560px) { .appbar .who { padding-left: 0; border-left: 0; } }
.letterfoot { text-align: center; font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.letterfoot strong { color: var(--link); font-weight: 500; }
.wrap { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
h1, h2 { margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; font-weight: 500; }
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.danger.solid { background: var(--danger); color: var(--surface); border-color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { color: var(--fg); background: var(--sunken); }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
textarea { min-height: 90px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 500; }
.mono { font-family: var(--font-mono); font-size: 0.9em; }

.lock { width: 100%; max-width: 440px; margin: 5vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 12px 32px rgb(30 20 50 / 0.12); }
.lock form { display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--danger); font-size: 0.88rem; min-height: 1.3em; }
.note { background: var(--sunken); border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; color: var(--muted); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top .id { display: flex; flex-direction: column; gap: 2px; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-sec { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-sec + .panel-sec { border-top: 1px solid var(--line); }
.panel-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px); gap: 16px; align-items: start; }
.panel-row > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.panel-row > .stack { gap: 8px; }
@media (max-width: 620px) { .panel-row { grid-template-columns: 1fr; } }
.sec-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.sec-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
h3 { margin: 0; font-size: 0.95rem; }
.banner { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; display: flex; flex-direction: column; gap: 8px; }
.banner strong.mono { background: var(--surface); padding: 1px 6px; border-radius: 4px; user-select: all; }
.banner-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.banner.warn { background: var(--danger-soft); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap.activity { max-height: 320px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:first-child > th, tr:first-child > td { border-top: 0; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: var(--sunken); }
.acts { display: flex; gap: 4px; }
.acts button { padding: 4px 8px; font-size: 0.82rem; white-space: nowrap; }
.pill { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); margin-right: 4px; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.add-person { display: flex; flex-direction: column; gap: 10px; background: var(--sunken); border-radius: 8px; padding: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .grid4 { grid-template-columns: 1fr; } }
.row-end { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; font-size: 0.78rem; }
.steps li { flex: 1; padding: 6px 4px; border-radius: 6px; background: var(--sunken); color: var(--muted); text-align: center; }
.steps li.on { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.steps li.done { background: var(--accent-soft); color: var(--accent); }
.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.qr { align-self: center; background: #ffffff; padding: 10px; border-radius: 8px; line-height: 0; }
.qr svg { width: 196px; height: 196px; max-width: 100%; }
.setup-key { word-break: break-all; margin: 6px 0; padding: 8px; background: var(--sunken); border-radius: 6px; }
details summary { cursor: pointer; color: var(--accent); }
input.code { font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-weight: 600; font-size: 0.85rem; padding: 0 4px; }
a { color: var(--link); }
.bad-text { color: var(--danger); }

.files { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.files.drag { border-color: var(--accent); background: var(--accent-soft); }
.files-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.files-label { font-size: 0.85rem; font-weight: 500; }
.files-head button { padding: 5px 12px; font-size: 0.85rem; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-list:empty { display: none; }
.file-list li { display: flex; align-items: center; gap: 8px; background: var(--sunken); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.file-list .fsize { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.file-list button { padding: 3px 8px; font-size: 0.8rem; }
.file-list li.pending .fname { color: var(--muted); }

.tools { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; background: transparent; border: 1px solid var(--line); color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; margin-left: 4px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 124px; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--sunken); }
.row .t, .row .cred { min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .cred { display: flex; flex-direction: column; gap: 2px; }
.row .cred .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .btns { display: flex; gap: 2px; justify-content: flex-end; }
.tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--accent); margin-right: 6px; }
.empty { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
@media (max-width: 620px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .cred { grid-column: 1 / -1; grid-row: 2; }
  .row .btns { grid-column: 2; grid-row: 1; }
}

.scrim { position: fixed; inset: 0; background: rgb(10 8 20 / 0.45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 540px; max-height: 100%; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.pw { display: flex; gap: 6px; }
.pw input { flex: 1; min-width: 0; font-family: var(--font-mono); }
.sheet .foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.sheet .foot .r { display: flex; gap: 8px; margin-left: auto; }
.confirm { background: var(--danger-soft); border-radius: 8px; padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 0.9rem; z-index: 30; }
.foot-note { font-size: 0.8rem; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: rise .16s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: .6 } } }
