/* DF Route. Palette: teal + rosa mexicano + marigold. */
:root {
  --teal: #0b5563; --teal-d: #073b45; --rosa: #c2006b; --gold: #ffd166;
  --bg: #f4f6f7; --card: #fff; --ink: #1c2a30; --muted: #5d6b72; --line: #dbe3e6;
  --ok: #059669; --warn: #b45309; --bad: #b91c1c;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(11,85,99,.06);
  --nav-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
/* overflow-x on html, never on body: body overflow would break the sticky navbar */
html { overflow-x: hidden; scroll-padding-top: calc(var(--nav-h) + 16px); }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
a { color: var(--teal); }
a:hover { color: var(--rosa); }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; color: var(--teal-d); }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code { background: #eef3f4; padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .late { color: var(--bad); font-weight: 600; } .warn { color: var(--warn); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 2000; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------------------------------------------------------------- navbar */
.navbar {
  position: sticky; top: 0; z-index: 1000; min-height: var(--nav-h);
  display: flex; align-items: center; gap: 12px; padding: 8px clamp(12px, 3vw, 28px);
  background: var(--teal); color: #fff; transition: box-shadow .2s;
}
.navbar.scrolled { box-shadow: 0 8px 24px rgba(0,0,0,.18); background: var(--teal-d); }
.navbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.navbar-brand:hover { color: #fff; }
.navbar-logo { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.navbar-brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.navbar-brand-tagline { font-size: .72rem; opacity: .85; white-space: nowrap; }
.main-nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; margin-left: 12px; }
.main-nav a { color: #e8f4f6; text-decoration: none; padding: 9px 11px; border-radius: 8px; font-size: .93rem; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.main-nav a:hover, .main-nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.main-nav a.active { box-shadow: inset 0 -3px 0 var(--gold); }
.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-box { display: flex; align-items: center; gap: 6px; }
.user-link { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; min-height: 40px; }
.user-link:hover { color: var(--gold); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--rosa); display: grid; place-items: center; font-weight: 700; }
.navbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.navbar .nav-toggle { display: none; color: #fff; }
.pill { background: var(--rosa); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; min-width: 20px; text-align: center; font-weight: 700; }
body.signed-out .nav-toggle, body.signed-out .main-nav { display: none; }

/* language selector (AG-WEB-STANDARDS §2.5) */
.lang-selector-wrapper { position: relative; }
.lang-selector-btn { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; cursor: pointer; font: inherit; font-size: .85rem; }
.lang-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.2); width: min(260px, 90vw); z-index: 1100; overflow: hidden; }
.lang-dropdown.active { display: block; }
.lang-search { padding: 8px; border-bottom: 1px solid var(--line); }
.lang-search input { width: 100%; }
.lang-list { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow: auto; }
.lang-item { display: flex; gap: 8px; align-items: center; padding: 10px; border-radius: 6px; cursor: pointer; min-height: 40px; }
.lang-item:hover, .lang-item.active { background: #e8f2f4; }
.lang-endonym { margin-left: auto; color: var(--muted); font-size: .85rem; }

/* ------------------------------------------------------------------ main */
main { padding: clamp(14px, 3vw, 32px); max-width: 1600px; margin: 0 auto; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lede { font-size: 1.05rem; color: var(--muted); margin: 0; }
.crumbs { font-size: .9rem; margin-bottom: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(14px, 2vw, 20px); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card.notice { border-left: 5px solid var(--teal); }
.card.notice.warn { border-left-color: var(--warn); background: #fff8eb; }
.loading { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }

/* ------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn.primary { background: var(--rosa); border-color: var(--rosa); color: #fff; }
.btn.primary:hover { background: #a3005a; color: #fff; }
.btn.outline { border-color: var(--teal); color: var(--teal); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-outline { border-color: #f1b4b4; color: var(--bad); }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { border-color: var(--line); }
.icon-btn.sm { width: 40px; height: 40px; }
input, select, textarea { font: inherit; color: inherit; padding: 9px 11px; border: 1px solid #c4d0d4; border-radius: 8px; background: #fff; min-height: 40px; max-width: 100%; }
textarea { resize: vertical; width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--rosa); }
input[type=range] { accent-color: var(--rosa); padding: 0; flex: 1; }
input[type=color] { padding: 2px; width: 48px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-weight: 600; font-size: .9rem; }
.field input, .field select, .field textarea { width: 100%; }
.hint { color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow-form { max-width: 420px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-error { color: var(--bad); font-weight: 600; margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inline-form input[type=text] { flex: 1 1 200px; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 46px; width: 100%; }
.eye-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.eye-btn:hover { color: var(--teal); }

/* ------------------------------------------------------------------ auth */
.auth-card { max-width: 420px; margin: clamp(20px, 8vh, 80px) auto; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- badges etc */
.badge { --badge: #6b7280; display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  color: var(--badge); background: color-mix(in srgb, var(--badge) 13%, white); border: 1px solid color-mix(in srgb, var(--badge) 35%, white); }
.prio { font-size: .85rem; font-weight: 600; }
.prio.critical { color: var(--bad); } .prio.high { color: var(--warn); } .prio.low { color: var(--muted); }
.progress { height: 10px; background: #e4ecee; border-radius: 99px; overflow: hidden; min-width: 60px; }
.progress.sm { height: 7px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--rosa)); border-radius: 99px; }
.prog-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.prog-cell .progress { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { text-decoration: none; color: var(--ink); }

/* ------------------------------------------------------------- dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border-top: 4px solid var(--teal); }
.kpi.bad { border-top-color: var(--bad); } .kpi.warn { border-top-color: var(--warn); }
.kpi-value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.kpi-label { font-weight: 600; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.stack-bar { display: flex; height: 20px; border-radius: 99px; overflow: hidden; background: #e4ecee; }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; }
.legend a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.stop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.stop-card { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.stop-card:hover { border-color: var(--teal); color: var(--ink); }
.stop-card.pause { background: #f8f3e6; }
.stop-head { display: flex; gap: 10px; align-items: center; }
.stop-seq { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.stop-countdown { font-weight: 700; color: var(--rosa); }
.stop-nums { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 0 16px; }
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { padding: 8px 0; border-bottom: 1px solid #eef2f3; overflow-wrap: anywhere; }
.mini-list li:last-child { border-bottom: 0; }
.mini-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .82rem; margin-top: 3px; align-items: center; }
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cat-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.cat-list .progress { grid-column: 1 / -1; }

/* ------------------------------------------------------------ collection */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.tool-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.filters select { flex: 1 1 160px; max-width: 260px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin: 8px 0 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid #edf1f2; text-align: left; vertical-align: top; }
table.data th { background: #f1f6f7; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
table.data tbody tr:hover { background: #fafcfc; }
table.data td.narrow, table.data th.narrow { width: 44px; }
.th-btn { all: unset; cursor: pointer; display: inline-flex; min-height: 32px; align-items: center; }
.th-btn:focus-visible { outline: 3px solid var(--gold); }
.pause-row { background: #fbf7ec; } .muted-row { opacity: .6; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.star { border: 0; background: transparent; color: #b8c4c8; cursor: pointer; width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 8px; }
.star.on { color: #e6a700; }
.card-grid { display: grid; gap: 12px; }
.card-grid.size-s { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.card-grid.size-m { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.card-grid.size-l { grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); }
.rec-card { text-decoration: none; color: var(--ink); margin: 0; container-type: inline-size; }
.rec-card:hover { border-color: var(--teal); color: var(--ink); }
.rec-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.rec-fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; font-size: .88rem; }
.rec-fields dt { color: var(--muted); }
.rec-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 240px) { .rec-fields { grid-template-columns: 1fr; } .rec-fields dt { margin-top: 4px; } }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 2px 12px; }
.pick-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: 16px; align-items: start; }
.status-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.range-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.checklist { list-style: none; padding: 0; margin: 10px 0 0; }
.checklist li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; border-bottom: 1px solid #eef2f3; }
.checklist li .check { flex: 1 1 220px; }
.checklist li.done .check span { text-decoration: line-through; color: var(--muted); }
.notes { list-style: none; padding: 0; margin: 14px 0 0; }
.notes li { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.notes p { margin: 2px 0 0; }
.diff { margin: 0; padding-left: 16px; font-size: .85rem; overflow-wrap: anywhere; }
.phones { list-style: none; margin: 0; padding: 0; }
.phone-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.phone-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.phone-row input[type=tel] { flex: 1 1 160px; }
.phone-row input[type=text] { flex: 1 1 120px; }

/* ------------------------------------------------------------- messages */
.messenger { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.conv-pane { padding: 6px; max-height: 72vh; overflow: auto; margin: 0; }
.conv-list { list-style: none; padding: 0; margin: 0; }
.conv-list a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.conv-list li.active a, .conv-list a:hover { background: #e8f2f4; }
.conv-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; overflow-wrap: anywhere; }
.conv-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-pane { display: flex; flex-direction: column; min-height: 60vh; margin: 0; }
.thread { display: flex; flex-direction: column; height: 100%; min-height: 55vh; }
.thread-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.back-link { display: none; }
.msg-log { list-style: none; margin: 0; padding: 12px 4px; flex: 1; overflow: auto; max-height: 56vh; display: flex; flex-direction: column; gap: 10px; }
.msg-log li { max-width: min(78%, 640px); background: #eef3f4; border-radius: 12px; padding: 8px 12px; align-self: flex-start; }
.msg-log li.mine { align-self: flex-end; background: #fde7f2; }
.msg-form { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 10px; }
.msg-form textarea { flex: 1; }

/* ------------------------------------------------------------- proposal */
.prose p { max-width: 75ch; }
.toc ol { margin: 6px 0 0; padding-left: 20px; columns: 2 240px; }
.toc li { min-height: 32px; }

/* ----------------------------------------------------------------- modal */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; }
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: rgba(10, 30, 36, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 140%); background: var(--teal-d); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 3000; transition: transform .25s; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.show { transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .navbar .nav-toggle { display: inline-grid; margin-left: auto; }
  .nav-actions { margin-left: 0; }
  .main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--teal-d); padding: 8px 12px 14px; margin: 0; box-shadow: 0 12px 24px rgba(0,0,0,.2); }
  body.nav-open .main-nav { display: flex; }
  .main-nav a { padding: 12px; }
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .messenger { grid-template-columns: 1fr; }
  .messenger.has-thread .conv-pane { display: none; }
  .messenger:not(.has-thread) .thread-pane { display: none; }
  .back-link { display: inline-flex; }
}
@media (max-width: 640px) {
  .navbar { flex-wrap: wrap; }
  .navbar-brand-tagline, .user-name { display: none; }
  .lang-selector-btn { padding: 6px 8px; }
  /* Tables turn into labelled stacked rows on phones. */
  table.stackable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: 100%; }
  table.stackable tr { border-bottom: 2px solid var(--line); padding: 6px 0; }
  table.stackable td { border: 0; padding: 4px 12px; display: grid; grid-template-columns: 38% 1fr; gap: 8px; }
  table.stackable td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; }
  table.stackable td[data-label=""]::before, table.stackable td:not([data-label])::before { content: none; }
  table.stackable td:not([data-label]), table.stackable td[data-label=""] { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: visible; }
  .filters select { max-width: none; }
  .msg-log li { max-width: 92%; }
}
