:root {
  --navy: #14233c; --ink: #1f2a37; --muted: #5b6878; --faint: #8a96a5;
  --accent: #0b5f86; --accent-soft: #e4f0f6; --amber: #a5660a; --amber-soft: #fdf3e1;
  --green: #1e7b45; --green-soft: #eef8f2; --red: #b42318; --red-soft: #fdecea;
  --border: #dde3ea; --bg: #f4f6f9; --white: #fff;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.side { background: var(--navy); color: #c9d4e2; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 0 6px; }
.side .mk { width: 32px; height: 32px; border-radius: 8px; background: #1f3a5c; display: grid; place-items: center; flex: none; }
.side .mk svg { width: 20px; height: 20px; stroke: #9fd3ea; fill: none; stroke-width: 1.8; }
.side .bn { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.15; }
.side .bs { font-size: 11px; color: #8fa3bb; }
.nav-i { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 14px; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
.nav-i:hover { background: #1b3050; }
.nav-i svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-i.on { background: #1f3a5c; color: #fff; font-weight: 600; }
.side .foot { margin-top: auto; font-size: 11px; color: #8fa3bb; padding: 0 8px; line-height: 1.4; }

.main { padding: 22px 26px 40px; min-width: 0; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.top h1 { font-size: 24px; color: var(--navy); }
.top p { font-size: 14px; color: var(--muted); margin-top: 3px; }
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.org { font-size: 13px; color: var(--muted); border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 12px; }
select.org { color: var(--ink); cursor: pointer; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi, .card { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 2px 6px rgba(20,35,60,.05); }
.kpi { padding: 12px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.kpi .v.sm { font-size: 17px; padding-top: 6px; font-family: ui-monospace, Menlo, monospace; }
.kpi .s { font-size: 11.5px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { padding: 16px 18px; display: flex; flex-direction: column; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card.narrow { max-width: 640px; }
.mt { margin-top: 14px; }
.two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
.card h3 { font-size: 16px; color: var(--navy); display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.card h3 .n { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12.5px; display: grid; place-items: center; flex: none; }
.hint { font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.card p.d { font-size: 13.5px; color: var(--muted); line-height: 1.45; margin: 6px 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; padding: 0 16px; white-space: nowrap; border: 0; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { height: 32px; font-size: 13px; padding: 0 12px; }
.btn-p { background: var(--accent); color: #fff; }
.btn-s { background: #fff; color: var(--accent); border: 1.5px solid #b9d0de; }
.btn-d { background: #fff; color: var(--red); border: 1.5px solid #f1c3bd; }
.btn-ok { background: var(--green); color: #fff; }
.meta { font-size: 12px; color: var(--faint); margin-top: 10px; line-height: 1.4; }

.drop { border: 2px dashed #b9c8d6; border-radius: 12px; background: #f8fafc; padding: 16px 12px; text-align: center; cursor: pointer; display: block; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 30px; height: 30px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop .t { font-size: 13.5px; margin-top: 4px; }
.drop .t u { color: var(--accent); font-weight: 600; text-decoration: none; }
.drop .h { font-size: 11.5px; color: var(--faint); margin-top: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 8px 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
td.prev { color: var(--muted); }
td.new { font-weight: 600; color: var(--navy); }
td code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.table-wrap { overflow-x: auto; margin: 8px 0 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { font-size: 12.5px; border-radius: 999px; padding: 4px 11px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); }
.chip.change, .chip.published { color: var(--green); background: var(--green-soft); border-color: #c7e6d3; }
.chip.conflict, .chip.draft { color: var(--amber); background: var(--amber-soft); border-color: #f0d9a8; }
.chip.upstream_kept, .chip.already_applied { color: var(--accent); background: var(--accent-soft); border-color: #c4dcea; }
.chip.error, .chip.rejected, .chip.failed { color: var(--red); background: var(--red-soft); border-color: #f1c3bd; }
.badge { font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }

.notice { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; line-height: 1.45; margin: 8px 0; }
.notice.ok { background: var(--green-soft); color: #165c34; border: 1px solid #c7e6d3; }
.notice.warn { background: var(--amber-soft); color: #7a4c08; border: 1px solid #f0d9a8; }
.notice.err { background: var(--red-soft); color: #8a1c12; border: 1px solid #f1c3bd; }
.notice ul { margin: 6px 0 0 18px; padding: 0; }
.notice a { color: inherit; font-weight: 600; }
#flash:empty { display: none; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.actions input { flex: 1; min-width: 200px; height: 40px; border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; }
.resolve { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form select, .form input { height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; color: var(--ink); font-weight: 400; }
.link { color: var(--accent); background: none; border: 0; cursor: pointer; font-weight: 600; padding: 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .brand, .side .foot { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid, .two { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}

/* ---- directory administration additions ---- */
.badge-local { font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border: 1px solid #f0d9a8; border-radius: 999px; padding: 5px 12px; }
.who .name { font-size: 13px; font-weight: 600; color: var(--navy); }
.sync { font-size: 12.5px; }
.sync.ok { color: var(--green); }
.sync.warn { color: var(--amber); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.missing { color: var(--amber); background: var(--amber-soft); border-color: #f0d9a8; }
.pill.pending { color: var(--accent); background: var(--accent-soft); border-color: #c4dcea; }
td.value { white-space: pre-line; max-width: 420px; }
.hidden { display: none !important; }
dialog { margin: auto; border: 1px solid var(--border); border-radius: 14px; padding: 0; max-width: min(760px, 94vw); width: 100%; box-shadow: 0 20px 50px rgba(20,35,60,.25); }
dialog::backdrop { background: rgba(20,35,60,.35); }
dialog .dlg { padding: 20px 22px; display: grid; gap: 12px; }
dialog h2 { font-size: 18px; color: var(--navy); }
dialog .list { max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
dialog .list table td { font-size: 13px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.history-change { font-size: 12.5px; margin: 2px 0; }
.history-change .old { color: var(--muted); }
.history-change .new { color: var(--navy); font-weight: 600; }
.empty-state { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.input { height: 40px; border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; font: inherit; width: 100%; }
.chip.published { color: var(--green); background: var(--green-soft); border-color: #c7e6d3; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
td.prev.value { min-width: 90px; }
#activity td:first-child, #versions td:nth-child(2), #change-sets td:nth-child(4) { white-space: nowrap; }
#activity td:nth-child(2) { min-width: 150px; }
#versions code, td code { white-space: nowrap; }
.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.kpis.kpis-2 { grid-template-columns: repeat(2, 1fr); }
.kpis.kpis-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .kpis.kpis-3 { grid-template-columns: 1fr; } }
.pill.provisional { color: var(--muted); background: #fff; border-style: dashed; }
.chip.pending { color: var(--muted); background: #fff; }
.chip.applied { color: var(--accent); background: var(--accent-soft); border-color: #c4dcea; }
details > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--navy); margin: 8px 0; }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 420px; background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 26px; display: grid; gap: 14px; }
.signin-card .brand-row { display: flex; gap: 10px; align-items: center; }
.signin-card .mk { width: 34px; height: 34px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; }
.signin-card .mk svg { width: 20px; height: 20px; stroke: #9fd3ea; fill: none; stroke-width: 1.8; }
.signin-card .bn { font-weight: 700; color: var(--navy); }
.signin-card .bs { font-size: 12px; color: var(--muted); }
.signin-card h1 { font-size: 20px; color: var(--navy); }
.signin-card .step { display: grid; gap: 8px; }
.signin-card label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.signin-card .qr { display: grid; gap: 6px; justify-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.signin-card .qr img { width: 180px; height: 180px; }
.signin-card code { word-break: break-all; }
