/* Locus Internal — monochrome admin console.
   Color is reserved for destructive actions and errors. */

:root {
    --bg: #ffffff;
    --bg-raised: #f9fafb;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --red: #dc2626;
    --radius: 6px;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --alert-error-bg: #fef2f2;
    --alert-error-text: #b91c1c;
    --alert-error-border: #fecaca;

    --overlay: rgba(17, 24, 39, 0.4);
}

html.dark {
    --bg: #030712;
    --bg-raised: #0b1120;
    --border: #1f2937;
    --text: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
    --red: #ef4444;

    --alert-error-bg: #450a0a;
    --alert-error-text: #fca5a5;
    --alert-error-border: #7f1d1d;

    --overlay: rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    font-size: 14px;
}

a { color: inherit; }

.dim { color: var(--text-muted); font-weight: 500; margin-left: 6px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* --- Boot / auth gates ------------------------------------------------- */

.boot {
    padding: 80px 0;
    text-align: center;
    color: var(--text-muted);
}

.gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.gate-box {
    width: 100%;
    max-width: 340px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.gate-box h1 { font-size: 16px; font-weight: 700; }
.gate-box p { font-size: 13px; }
.gate-box label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

input, textarea, select {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 7px 9px;
}
input:focus, textarea:focus, select:focus, button:focus-visible {
    outline: 2px solid var(--text-secondary);
    outline-offset: -1px;
}
select { font-size: 12px; padding: 3px 6px; cursor: pointer; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; width: 100%; }

/* --- Buttons ------------------------------------------------------------ */

.btn {
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-raised); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { font-size: 12px; padding: 3px 9px; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover:not(:disabled) { opacity: 0.85; background: var(--text); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { opacity: 0.85; background: var(--red); }
.btn.danger-outline { color: var(--red); border-color: var(--red); }
.btn.danger-outline:hover:not(:disabled) { background: var(--alert-error-bg); }
.btn.load-more { margin-top: 12px; }

.link {
    font: inherit;
    background: none;
    border: none;
    padding: 0;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--text-muted);
    cursor: pointer;
    text-align: left;
}
.link:hover { text-decoration-color: var(--text); }

/* --- Shell -------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}
.wordmark { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.topnav { display: flex; gap: 4px; }
.topnav a {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 4px;
}
.topnav a:hover { color: var(--text); background: var(--bg-raised); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--bg-raised); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }

.content { padding: 20px; max-width: 1200px; }

/* --- Page chrome ---------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}
.page-head h1 { font-size: 15px; font-weight: 700; }

.filters { display: flex; gap: 4px; }
.filter {
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    text-transform: capitalize;
}
.filter:hover { color: var(--text); }
.filter.active { color: var(--bg); background: var(--text); border-color: var(--text); }

/* --- Tables ---------------------------------------------------------------- */

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.data .num { text-align: right; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions .btn { margin-left: 6px; }
tr.row:hover td { background: var(--bg-raised); }
tr.row.resolved td { color: var(--text-muted); }

.cell-trunc {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-trunc.wide { max-width: 340px; }
.cell-trunc .link {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 6px;
    color: var(--text-secondary);
}
.tag.solid { background: var(--text); border-color: var(--text); color: var(--bg); }

/* Expanded detail row */
tr.detail td { background: var(--bg-raised); padding: 12px 14px; }
.detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.detail-label:not(:first-child) { margin-top: 12px; }
.pre {
    font-family: var(--mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
    background: var(--bg);
    max-height: 260px;
    overflow: auto;
}
.ext {
    display: inline-block;
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 12px;
    word-break: break-all;
}
.reject-box { margin-top: 12px; max-width: 560px; }
.detail-actions { display: flex; gap: 8px; margin-top: 8px; }

/* --- Districts -------------------------------------------------------------- */

.create-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.create-form input { font-size: 13px; min-width: 200px; }

.domain-list { list-style: none; max-width: 420px; }
.domain-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.domain-add { display: flex; gap: 8px; margin-top: 8px; max-width: 420px; }
.domain-add input { flex: 1; font-family: var(--mono); font-size: 12px; padding: 4px 8px; }
.hint { margin-top: 6px; font-size: 12px; color: var(--text-muted); }

/* --- States --------------------------------------------------------------- */

.alert {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 10px;
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-border);
}
.flash {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    background: var(--bg-raised);
}
.loading { color: var(--text-muted); padding: 20px 0; font-size: 13px; }
.empty { color: var(--text-muted); padding: 20px 0; font-size: 13px; }

/* --- Modal ------------------------------------------------------------------ */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}
.modal {
    width: 100%;
    max-width: 440px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal h2 { font-size: 14px; font-weight: 700; }
.modal p { font-size: 13px; color: var(--text-secondary); }
.modal-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.modal-label input { font-family: var(--mono); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: 10px; }
    .content { padding: 14px; }
    .cell-trunc, .cell-trunc.wide { max-width: 140px; }
}
