/* CO-SYNE design tokens and shared components.
   Light (data-theme="day", the default in every module) follows the public
   website's Fluent look: white surfaces, blue actions, soft shadows. The
   graphite palette below is the optional Dark mode for night use. */
:root {
  color-scheme: dark;
  --bg: #0e1013; --bg-2: #121418; --panel: #171a1f; --panel-2: #1d2127; --panel-3: #23282f;
  --line: #2a2f36; --line-2: #363c45;
  --text: #e6e8eb; --muted: #9aa2ad; --faint: #6b7380;
  --brand: #c9a54a; --brand-2: #e0c171; --brand-bg: rgba(201, 165, 74, .12); --brand-ink: #15120a; --gold: #c9a54a;
  --ok: #3fb950; --ok-bg: rgba(63, 185, 80, .13);
  --warn: #f0883e; --warn-bg: rgba(240, 136, 62, .14);
  --danger: #f85149; --danger-bg: rgba(248, 81, 73, .14);
  --info: #79b8ff; --info-bg: rgba(121, 184, 255, .12);
  --primary: #e6e8eb; --primary-ink: #0e1013;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 10px; --radius-sm: 7px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
:root[data-theme="day"] {
  color-scheme: light;
  --bg: #f3f3f3; --bg-2: #fafafa; --panel: #ffffff; --panel-2: #f7f7f7; --panel-3: #efefef;
  --line: #e1e1e1; --line-2: #d1d1d1;
  --text: #1b1b1b; --muted: #5e5e5e; --faint: #6e6e6e;
  --brand: #0067b8; --brand-2: #005da6; --brand-bg: rgba(0, 103, 184, .1); --brand-ink: #ffffff;
  --gold: #a07a1e;
  --ok: #107c10; --ok-bg: rgba(16, 124, 16, .1);
  --warn: #8a5a00; --warn-bg: #fff4ce;
  --danger: #c42b1c; --danger-bg: rgba(196, 43, 28, .08);
  --info: #0067b8; --info-bg: #eaf3fc;
  --primary: #0067b8; --primary-ink: #ffffff;
  --shadow: 0 1.6px 4px rgba(0, 0, 0, .12), 0 12px 28px rgba(0, 0, 0, .14);
}
:root[data-theme="day"] .card { box-shadow: 0 .3px .9px rgba(0, 0, 0, .1), 0 1.6px 3.6px rgba(0, 0, 0, .1); }
:root[data-theme="day"] .btn.primary:hover, :root[data-theme="day"] .btn.brand:hover { background: #005da6; border-color: #005da6; filter: none; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: .95rem; } h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
p { margin: .4em 0; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85em; } .tiny { font-size: .75em; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ico { width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: -.2em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-3); border-color: var(--faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(.92); }
.btn.brand { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-3); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.lg { padding: 12px 18px; font-size: 1rem; }
.btn.icon { padding: 7px; }
.btn.block { width: 100%; }

/* form */
label { display: block; font-size: .8rem; color: var(--muted); margin: 8px 0 4px; font-weight: 550; }
input, select, textarea { width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-2); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 7px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 0 0 6px; color: var(--text); cursor: pointer; font-weight: 400; font-size: .88rem; }
.check:hover { background: var(--panel-2); }
.check input { width: auto; margin-top: 3px; accent-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); font-weight: 550; }
.seg button.on { background: var(--panel-3); color: var(--text); }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.flat { background: var(--panel-2); }
.card > header, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.pill.brand { background: var(--brand-bg); color: var(--brand-2); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: 0 0 auto; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--danger); } .dot.info { background: var(--info); }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(248, 81, 73, .6); } 70% { box-shadow: 0 0 0 8px rgba(248, 81, 73, 0); } 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.plate { font-family: var(--mono); font-weight: 700; letter-spacing: .06em; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel-2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-3); color: var(--text); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; border: 1px solid var(--line-2); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: var(--panel-2); }
.empty { color: var(--faint); text-align: center; padding: 26px 10px; font-size: .9rem; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: flex; gap: 9px; align-items: flex-start; }
.mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: .72rem; font-weight: 800; }
.mark.ok { background: var(--ok-bg); color: var(--ok); } .mark.bad { background: var(--danger-bg); color: var(--danger); }
.notice { border-radius: var(--radius-sm); padding: 9px 11px; font-size: .86rem; border: 1px solid var(--line); background: var(--panel-2); }
.notice.warn { background: var(--warn-bg); border-color: transparent; }
.notice.bad { background: var(--danger-bg); border-color: transparent; }
.notice.ok { background: var(--ok-bg); border-color: transparent; }

/* toasts */
.toasts { position: fixed; z-index: 9000; bottom: 64px; right: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { background: var(--panel-3); color: var(--text); border: 1px solid var(--line-2); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 380px; font-size: .9rem; animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* administrator notices */
.notices { position: fixed; z-index: 9500; top: 64px; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 20px)); display: flex; flex-direction: column; gap: 6px; }
.notice-bar { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 14px; border-radius: var(--radius); background: var(--panel-3); border: 1px solid var(--line-2); border-left: 4px solid var(--info); box-shadow: var(--shadow); font-size: .9rem; animation: rise .18s ease-out; }
.notice-bar b { white-space: nowrap; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--info); }
.notice-bar.warn { border-left-color: var(--warn); } .notice-bar.warn b { color: var(--warn); }
.notice-bar.critical { border-left-color: var(--danger); background: var(--danger-bg); } .notice-bar.critical b { color: var(--danger); }
@media (max-width: 520px) { .notice-bar { flex-wrap: wrap; } }

/* "install this app" prompt */
.install-pop { position: fixed; z-index: 9400; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(440px, calc(100% - 24px)); background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; display: flex; gap: 12px; align-items: flex-start; animation: rise .18s ease-out; }
.install-pop img { width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto; }

/* module install / download cards */
.modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; margin-bottom: 14px; }
.module { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.module header { display: flex; gap: 12px; align-items: center; }
.module header h2 { margin-bottom: 3px; }
.module-body { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; margin-top: 4px; }
.module-body h4 { margin-top: 6px; }
.qr { margin: 0; text-align: center; flex: 0 0 auto; }
.qr img { display: block; background: #fff; border-radius: 8px; padding: 4px; }
.dl { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dl li { display: flex; flex-direction: column; }
.dl a { display: inline-flex; gap: 7px; align-items: center; text-decoration: none; font-weight: 550; font-size: .88rem; }
.dl a:hover { text-decoration: underline; }
.driver-guide { margin-bottom: 14px; padding: 18px; border-color: var(--brand-bg); }
.dg-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.dg-head img { border-radius: 10px; flex: 0 0 auto; }
.dg-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.dg-cols h4 { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid-auto h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 480px) { .module-body { flex-direction: column-reverse; align-items: stretch; } .qr img { margin: 0 auto; } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 8000; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); width: min(860px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 18px; }

/* video tiles */
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile { position: relative; background: #000; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 16 / 10; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .62); color: #fff; padding: 2px 8px; border-radius: 5px; font-size: .75rem; display: flex; gap: 6px; align-items: center; }
.tile.self video { transform: scaleX(-1); }
.chat { display: flex; flex-direction: column; gap: 6px; overflow: auto; font-size: .88rem; }
.chat .msg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; max-width: 92%; }
.chat .msg.me { align-self: flex-end; background: var(--panel-3); }
.chat .msg b { font-size: .78rem; color: var(--muted); display: block; }

/* printable documents */
.doc { background: #fff; color: #111; padding: 26px 30px; border-radius: 6px; font-size: 13px; line-height: 1.45; }
.doc h1 { font-size: 20px; } .doc h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 6px; color: #333; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #111; padding-bottom: 10px; margin-bottom: 12px; }
.doc-head p { margin: 2px 0 0; color: #444; }
.doc-id { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.doc-table th, .doc-table td { border: 1px solid #bbb; padding: 5px 8px; text-align: left; vertical-align: top; }
.doc-table th { background: #f2f2f2; width: 22%; }
.doc .mono { color: #333; overflow-wrap: anywhere; }
body.print-doc { background: #fff; padding: 0; }
@media print { body.print-doc .doc { padding: 0; } }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
