:root {
  --navy: #003142;
  --navy-2: #0a4a60;
  --orange: #f16826;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17262d;
  --muted: #55696f;
  --line: #dde4e8;
  --ok: #1a8a4a;
  --bad: #c62828;
  --warn: #8a5200;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 12px; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; padding: 0 8px; }
.brand span { color: var(--orange); }
.brand small { display: block; font-size: 11px; font-weight: 400; opacity: .7; letter-spacing: 0; }
nav { display: grid; gap: 2px; flex: 1; align-content: start; }
nav a { color: #e3eef2; text-decoration: none; padding: 10px 12px; border-radius: 6px; cursor: pointer; }
nav a:hover { background: var(--navy-2); }
nav a.active { background: #b8460f; color: #fff; }
.who { font-size: 12px; display: grid; gap: 6px; padding: 0 8px; color: #cfe0e7; word-break: break-all; }

main { padding: 24px; max-width: 1100px; width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stat { font-size: 26px; font-weight: 700; }

label, .fld { display: grid; gap: 4px; align-content: start; font-size: 13px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
input, select, textarea { font: inherit; padding: 9px 10px; min-height: 40px; border: 1px solid #8fa1a8; border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #f0f3f5; }
.form { display: grid; align-items: start; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
.hint { font-size: 13px; color: var(--muted); }

.btn { font: inherit; border: 1px solid #b9c5cb; background: #fff; color: var(--text); padding: 9px 14px; min-height: 40px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--navy); }
.btn.primary { background: #b8460f; border-color: #b8460f; color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: #fff; border-color: #3d6b7d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.wrap { white-space: pre-wrap; word-break: break-word; max-width: 360px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 13px; font-weight: 600; background: #e8eef1; color: var(--muted); }
.badge.ok { background: #e2f4ea; color: var(--ok); }
.badge.bad { background: #fde8e8; color: var(--bad); }
.badge.warn { background: #fff1d9; color: var(--warn); }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { font: inherit; padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.qr { width: 240px; height: 240px; border: 1px solid var(--line); border-radius: 8px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; max-width: 360px; }
.toast.bad { background: var(--bad); }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff > div { background: #f7f9fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; white-space: pre-wrap; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  nav { grid-auto-flow: column; overflow-x: auto; }
  main { padding: 14px; }
  .diff { grid-template-columns: 1fr; }
}

/* inline sections */
.sub { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
details.mon { border-top: 1px solid var(--line); padding: 10px 0; }
details.mon > summary { cursor: pointer; }

/* toggle switches */
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 22px; background: #c5ced6; position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
input[type=checkbox]:checked { background: #1f9d55; }
input[type=checkbox]:checked::after { transform: translateX(16px); }
input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
input[type=checkbox]:focus-visible { outline: 2px solid #f26b21; outline-offset: 2px; }
.switches { margin: 18px 0; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; gap: 10px; }
.switches h2 { margin: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .7; font-weight: 600; }
.switches label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #fff; font-size: 13px; cursor: pointer; }
.swrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.swrow:first-of-type { border-top: 0; }
.swrow small { display: block; color: var(--muted); font-weight: 400; }

/* accessibility */
:focus-visible { outline: 3px solid #f6a15f; outline-offset: 2px; }
main:focus, h1:focus { outline: none; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; color: #000; padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }
summary { cursor: pointer; padding: 4px 0; }
details.adv { margin-top: 4px; }
details.adv > summary { color: var(--muted); font-size: 13px; }
details.adv > .form { margin-top: 10px; }
.grow { flex: 1; min-width: 220px; }
input[type=search] { max-width: 420px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* fixes: toggles must not inherit input sizing; use the full width */
input[type=checkbox] { width: 38px; min-height: 0; height: 22px; padding: 0; border: 0; }
main { max-width: none; }

.people .row { gap: 8px; margin-top: 8px; }
.people input { flex: 1; min-width: 0; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--line, #d8d4cc); border-radius: 999px; background: #fff; }
.chips li.muted { border: 0; background: none; padding-left: 0; }
.chips .x { min-height: 0; height: 22px; width: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; }
.chips .x:hover { background: #eee; }

.combo { position: relative; flex: 1; min-width: 0; }
.combo input { width: 100%; }
.combo-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow: auto; background: #fff; color: #1f1d1a; border: 1px solid #b9b3a8; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.combo-list.hidden { display: none; }
.combo-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.combo-list li:hover, .combo-list li.on { background: #f4e9e1; }
.combo-list li.empty { color: #6b665e; cursor: default; }
.combo-list li.empty:hover { background: none; }
