/* admin.css - Triumviry admin. Dark theme, system fonts, no external resources (CSP: style-src 'self'). */
:root {
  --bg: #0e1117; --panel: #161b24; --panel-2: #1c2330; --line: #2e3949; --text: #e8ecf2; --muted: #a3afc2;
  --accent: #7db4ff; --primary: #2f6fe4; --primary-hover: #3f7df0; --danger: #c43c3c; --danger-hover: #d54c4c;
  --focus: #ffd479; --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
code, .key { font-family: var(--mono); font-size: .9em; }
code { background: var(--panel-2); border-radius: 4px; padding: .05rem .3rem; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .lead { color: var(--muted); max-width: 70ch; }
.sr-only, .sr-offscreen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { margin: 2rem; text-align: center; }
.empty { color: var(--muted); padding: 1rem 0; margin: 0; list-style: none; }
.plain-list { margin: .4rem 0 .75rem; padding-left: 1.2rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- shell ---- */
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 100; background: var(--primary); color: #fff; border: 0; padding: .5rem .9rem; border-radius: var(--radius); }
.skip-link:focus { left: .5rem; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-user { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.user-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark { display: inline-flex; gap: 3px; } .brand-mark i { display: block; width: 8px; height: 22px; border-radius: 2px; background: var(--accent); }
.brand-mark i:nth-child(2) { background: #a58bff; height: 16px; align-self: end; } .brand-mark i:nth-child(3) { background: #5fd3a8; height: 12px; align-self: end; }
.brand-name { font-weight: 700; letter-spacing: .02em; } .brand-sub { color: var(--muted); }
.brand-large { justify-content: center; margin-bottom: 1rem; font-size: 1.3rem; } .brand-large .brand-mark i { width: 10px; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 53px); }
.sidenav { background: var(--panel); border-right: 1px solid var(--line); padding: 1rem .6rem; display: flex; flex-direction: column; gap: .2rem; position: sticky; top: 53px; align-self: start; height: calc(100vh - 53px); }
.nav-link { display: block; padding: .55rem .8rem; border-radius: var(--radius); color: var(--text); text-decoration: none; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--panel-2); }
.nav-link[aria-current="page"] { background: var(--panel-2); border-left-color: var(--accent); font-weight: 700; }
.content { padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 3rem; min-width: 0; outline: none; }
.page { max-width: 1200px; }
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.card-title { margin-bottom: .75rem; }
.loading { display: flex; align-items: center; gap: .5rem; color: var(--muted); padding: 1rem 0; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { scroll-behavior: auto !important; } }

/* ---- auth ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem; }
.auth-card h1 { text-align: center; font-size: 1.35rem; } .auth-card > .muted { text-align: center; }
.input-row { display: flex; gap: .5rem; } .input-row .input { flex: 1; min-width: 0; }
.input-code { letter-spacing: .25em; text-align: center; font-family: var(--mono); font-size: 1.2rem; }
.steps { padding-left: 1.2rem; color: var(--muted); } .qr { display: block; margin: .75rem auto; background: #fff; padding: 6px; border-radius: var(--radius); }
.secret-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; } .secret-label { color: var(--muted); min-width: 4.5rem; }
.secret { flex: 1; min-width: 0; padding: .3rem .5rem; word-break: break-all; } .secret-wrap { font-size: .75rem; }
.backup-codes { columns: 2; list-style: none; padding: .8rem; margin: 0 0 1rem; background: var(--panel-2); border-radius: var(--radius); font-family: var(--mono); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; line-height: 1.2; padding: .55rem 1rem; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none; color: var(--text); background: transparent; }
.btn:disabled, fieldset:disabled .btn { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--panel-2); border-color: var(--line); } .btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); } .btn-ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn-danger { background: var(--danger); color: #fff; } .btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-danger-text { color: #ff9b9b; }
.btn-small { padding: .3rem .65rem; font-size: .88rem; } .btn-block { display: flex; width: 100%; margin-top: .6rem; } .btn-icon { min-width: 2rem; padding-inline: .4rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; min-width: 0; }
.field > label, .tr-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; }
.input, select.input, textarea.input { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid #44536a; border-radius: var(--radius); padding: .5rem .65rem; min-width: 0; }
.input:hover { border-color: #6b7e99; }
.input-small { width: auto; max-width: 14rem; }
input[type="number"].input-small { width: 9rem; }
input[type="file"].input { padding: .4rem; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--primary); vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .4rem .9rem; margin: .5rem 0 .25rem 1.4rem; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; margin: 0 0 1rem; } .fieldset legend { padding: 0 .4rem; font-weight: 600; }
.form-lock { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1.25rem; }
.form-error { color: #ffb4b4; } .form-error:empty { display: none; } .form-error ul { margin: .3rem 0; padding-left: 1.2rem; } .form-error-hint { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: flex-end; margin-bottom: .5rem; }
.toolbar .field { min-width: 11rem; flex: 0 1 15rem; } .toolbar .field-grow { flex: 1 1 16rem; } .field-inline { margin: 0; }

/* ---- notices, chips, toasts ---- */
.notice { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; background: var(--panel-2); }
.notice p { margin: .3rem 0 0; } .notice ul { margin: .3rem 0; padding-left: 1.2rem; } .notice-actions { margin-top: .6rem; }
.notice-info { border-left-color: var(--accent); } .notice-warn { border-left-color: #f0b84d; } .notice-error { border-left-color: #f07878; }
.chip { display: inline-block; font-size: .78rem; font-weight: 600; line-height: 1.4; padding: .05rem .55rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.chip-neutral { background: #262f3d; color: #cdd5e1; border-color: #3a4658; } .chip-ok { background: #12372a; color: #93f0c2; border-color: #1f6046; }
.chip-info { background: #11304f; color: #a8d0ff; border-color: #1f5388; } .chip-warn { background: #40300d; color: #ffd98a; border-color: #735616; }
.chip-error { background: #4a1c21; color: #ffb0b5; border-color: #7e2f37; }
.chip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; } .chip-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; } .chip-label { min-width: 11rem; font-weight: 600; }
.toast-area { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.toast-stack { display: flex; flex-direction: column; gap: .5rem; } .toast-stack:empty { display: none; }
.toast { pointer-events: auto; display: flex; justify-content: space-between; gap: .75rem; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid #5fd3a8; border-radius: var(--radius); padding: .65rem .8rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
.toast-error { border-left-color: #f07878; } .toast-warn { border-left-color: #f0b84d; } .toast-info { border-left-color: var(--accent); }
.toast-body { min-width: 0; } .toast-msg { overflow-wrap: anywhere; } .toast-details { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .85rem; color: var(--muted); }
.toast-close { background: transparent; border: 0; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .2rem; align-self: flex-start; }

/* ---- dialogs ---- */
dialog.modal { padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); width: min(520px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); }
dialog.modal-wide { width: min(980px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(4, 7, 12, .72); }
.modal-panel { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); } .modal-header h2 { margin: 0; }
.modal-close { background: transparent; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.modal-body { padding: 1rem 1.25rem; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: .6rem; padding: .8rem 1.25rem; border-top: 1px solid var(--line); }

/* ---- tables, meters, key/values ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin: .25rem 0 1rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--panel-2); padding: .55rem .75rem; white-space: nowrap; }
table.data th.num { text-align: right; }
table.data td { padding: .55rem .75rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: rgba(125, 180, 255, .05); }
.cell-wrap { overflow-wrap: anywhere; min-width: 10rem; max-width: 36rem; } .cell-cov { min-width: 12rem; }
.cov { display: flex; align-items: center; gap: .6rem; } .cov-value { min-width: 3.6rem; text-align: right; font-variant-numeric: tabular-nums; }
progress.meter { appearance: none; -webkit-appearance: none; width: 100%; height: .7rem; border: 0; border-radius: 999px; overflow: hidden; background: #0a0d13; box-shadow: inset 0 0 0 1px var(--line); }
progress.meter::-webkit-progress-bar { background: #0a0d13; } progress.meter::-webkit-progress-value { background: linear-gradient(90deg, #4f8ff0, #5fd3a8); border-radius: 999px; }
progress.meter::-moz-progress-bar { background: linear-gradient(90deg, #4f8ff0, #5fd3a8); border-radius: 999px; }
progress.meter-large { height: 1.1rem; }
.kv { display: grid; grid-template-columns: minmax(10rem, max-content) 1fr; gap: .3rem 1.25rem; margin: .75rem 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.75rem; font-weight: 700; } .stat-label { color: var(--muted); font-size: .85rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; } .two-col > .card { margin-bottom: 0; } .two-col { margin-bottom: 1.1rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .75rem 0; } .pager-info { color: var(--muted); font-size: .9rem; }

/* ---- translations ---- */
.tr-list { display: flex; flex-direction: column; gap: .8rem; }
.tr-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.tr-item.is-dirty { border-color: var(--focus); } .tr-item.is-obsolete { opacity: .75; }
.tr-head { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .6rem; } .key { color: var(--accent); overflow-wrap: anywhere; margin-right: .3rem; }
.tr-body { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.tr-col { min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.tr-source { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .65rem; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.6rem; }
.tr-target { resize: vertical; line-height: 1.5; min-height: 2.6rem; }
.tr-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .6rem; }
.tr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }

/* ---- jobs, import, glossary ---- */
.job-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .6rem; } .job-head .btn-row { margin: 0 0 0 auto; }
.job-progress { margin: .5rem 0; }
.chain { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.chain-item { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .7rem; }
.chain-pos { color: var(--muted); min-width: 1.5rem; } .chain-label { flex: 1; min-width: 8rem; font-weight: 600; }
.report { margin-top: 1rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.term-list { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .5rem 1rem; }
.term-item { display: flex; gap: .5rem; align-items: center; }
.add-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; } .add-row .field { flex: 1 1 18rem; margin-bottom: 0; } .add-row .btn { margin-bottom: 0; }

/* ---- responsive ---- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem; }
  .nav-link { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; } .nav-link[aria-current="page"] { border-bottom-color: var(--accent); }
  .tr-body { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .5rem; }
}
@media (max-width: 560px) {
  .user-email { display: none; } .topbar { padding-inline: .8rem; } .content { padding-inline: .8rem; }
  .backup-codes { columns: 1; } .job-head .btn-row { margin-left: 0; }
}
@media (forced-colors: active) { .chip, .btn, .input { border: 1px solid CanvasText; } progress.meter { forced-color-adjust: none; } }
