/*  Safe Redact Control Center

    Colour tokens and typography are taken from the desktop application's design system
    (Resources/Theme.xaml and Resources/Typography.xaml) so the web console and the
    installed product read as one piece of software. Do not introduce a colour here that
    does not exist there.                                                              */

@font-face {
    font-family: "Inter Variable";
    src: url("fonts/InterVariable.ttf") format("truetype-variations");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    /* Theme.xaml */
    --canvas:        #161616;
    --chrome:        #1D1D1D;
    --chrome-raised: #242424;
    --panel:         #242424;
    --panel-raised:  #303030;
    --control:       #303030;
    --control-hover: #363636;
    --field:         #262626;
    --field-hover:   #303030;
    --hairline:      #363636;

    --ink:           #E6E6E6;
    --ink-2:         #AEAEAE;
    --ink-3:         #7C7C7C;

    --accent:        #D97757;
    --accent-press:  #B26247;
    --accent-soft:   rgba(217, 119, 87, .18);

    --amber:         #E0A341;
    --green:         #4FAE6B;
    --red:           #E5604D;

    --dialog-bg:     #15181D;
    --dialog-card:   #1B1F26;
    --dialog-border: #2F343D;

    --radius:        6px;
    --radius-sm:     4px;
}

* { box-sizing: border-box; }

/* Scrollbars are application chrome, so keep them in the same dark neutral palette as
   fields and dividers. Firefox uses the first rule; Chromium/WebView uses the rest. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--ink-3) var(--field);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--field); }
*::-webkit-scrollbar-thumb {
    background: var(--ink-3);
    border: 2px solid var(--field);
    border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-2); }
*::-webkit-scrollbar-corner { background: var(--field); }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: "Inter Variable", "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.55;
    font-feature-settings: "tnum" 1, "cv05" 1;
}

/* Typography.xaml: Base 13 · Caption 11 · Label 12/600 · Section 14/600 · Dialog 20/600 */
h1 { font-size: 20px; font-weight: 600; margin: 0 0 2px; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 600; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
    font-size: 12px; color: var(--ink-2);
    background: var(--field); border: 1px solid var(--hairline);
    border-radius: 3px; padding: 1px 5px;
}

/* ── header ─────────────────────────────────────────────────────────── */

.topbar {
    display: flex; align-items: center; gap: 32px;
    height: 52px; padding: 0 20px;
    background: var(--chrome); border-bottom: 1px solid var(--hairline);
}
.topbar nav { display: flex; align-items: center; gap: 4px; flex: 1; height: 100%; }
.topbar nav a {
    display: flex; align-items: center; height: 30px; padding: 0 12px;
    color: var(--ink-2); font-size: 13px; border-radius: var(--radius-sm);
}
.topbar nav a:hover { color: var(--ink); background: var(--control); text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; }
.topbar form { margin: 0; }

.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 13px; }
.brand .brand-icon { width: 30px; height: 30px; object-fit: contain; }
.brand strong { font-weight: 600; }
.brand span.sub { color: var(--ink-3); font-weight: 400; }

.scope-badge {
    margin-left: 8px; padding: 3px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .01em;
    color: var(--accent); background: var(--accent-soft);
    border: 1px solid rgba(217, 119, 87, .35);
}

/* ── layout ─────────────────────────────────────────────────────────── */

.page { max-width: 1180px; margin: 0 auto; padding: 26px 20px 72px; }
.page-head { margin-bottom: 20px; }
.lede { color: var(--ink-3); margin: 5px 0 0; font-size: 13px; max-width: 70ch; }
.back { display: inline-block; font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.back::before { content: "← "; }
.back:hover { color: var(--ink-2); text-decoration: none; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* The organisation table has seven meaningful columns. Keep its management action
   reachable at narrower desktop widths instead of clipping it behind the adjacent form. */
.organisation-table-scroll {
    width: 100%;
    overflow-x: auto;
    scrollbar-gutter: stable;
}
.organisation-table { min-width: 760px; }
.organisation-table th:last-child,
.organisation-table td:last-child {
    position: sticky;
    right: 0;
    background: var(--panel);
    box-shadow: -8px 0 10px -10px #000;
}
.organisation-table tbody tr:hover td:last-child { background: var(--chrome-raised); }

.panel {
    background: var(--panel); border: 1px solid var(--hairline);
    border-radius: var(--radius); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 12px 16px; border-bottom: 1px solid var(--hairline);
}
.panel-body { padding: 16px; }
.panel-body.bordered { border-top: 1px solid var(--hairline); background: var(--chrome-raised); }
.pad { padding: 14px 16px; margin: 0; }

.count {
    font-size: 11px; font-weight: 600; color: var(--ink-3);
    background: var(--control); border-radius: 999px; padding: 2px 8px;
}

/* ── text ───────────────────────────────────────────────────────────── */

.muted { color: var(--ink-3); }
.small { font-size: 11px; }
.hint { color: var(--ink-3); font-size: 11px; margin: 6px 0 0; max-width: 72ch; line-height: 1.6; }
.right { text-align: right; }
.verified { color: var(--green); font-size: 11px; font-weight: 600; }
.at-limit { color: var(--amber); font-weight: 600; }

/* ── forms ──────────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field.inline { margin-bottom: 0; }
.field.grow { flex: 1 1 200px; }

label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }

input, select, textarea {
    width: 100%; padding: 8px 10px;
    background: var(--field); color: var(--ink);
    border: 1px solid var(--hairline); border-radius: var(--radius-sm);
    font: inherit; font-size: 13px;
}
input:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--ink-3); }
textarea { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; resize: vertical; }
select {
    appearance: none; padding-right: 28px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                      linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: right 14px center, right 9px center;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.actions { display: inline-flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
    display: inline-block; padding: 8px 14px;
    background: var(--control); color: var(--ink);
    border: 1px solid var(--hairline); border-radius: var(--radius-sm);
    font: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--control-hover); border-color: #454545; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.btn.subtle { background: transparent; color: var(--ink-2); }
.btn.subtle:hover { background: var(--control); color: var(--ink); }
.btn.danger { color: var(--red); border-color: rgba(229, 96, 77, .4); background: transparent; }
.btn.danger:hover { background: rgba(229, 96, 77, .12); border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.tiny { padding: 2px 8px; font-size: 11px; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.ghost { background: transparent; border-color: var(--hairline); color: var(--ink-2); }
.btn.ghost:hover { background: var(--control); color: var(--ink); }

/* Keep the long provisioning form usable at laptop-height viewports. */
.provision-panel .panel-body {
    max-height: calc(100vh - 236px);
    overflow-y: auto;
    scrollbar-gutter: stable;
}
.provision-actions {
    position: sticky;
    bottom: -16px;
    z-index: 1;
    margin: 4px -16px -16px;
    padding: 10px 16px 16px;
    background: linear-gradient(to bottom, rgba(36, 36, 36, .2), var(--panel) 10px);
}
@media (max-width: 1000px) {
    .provision-panel .panel-body { max-height: none; overflow-y: visible; }
    .provision-actions { position: static; margin: 4px 0 0; padding: 0; background: none; }
}

/* ── tables ─────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 9px 16px;
    font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--ink-3); background: var(--chrome-raised);
    border-bottom: 1px solid var(--hairline);
}
td { padding: 11px 16px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--chrome-raised); }
table.compact th, table.compact td { padding: 7px 16px; font-size: 12px; }

/* ── indicators ─────────────────────────────────────────────────────── */

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    background: var(--control); color: var(--ink-2); border: 1px solid var(--hairline);
}
.tag.tiny { font-size: 10px; padding: 1px 6px; }
.tag.ok, .tag.active { background: rgba(79, 174, 107, .14); color: var(--green); border-color: rgba(79, 174, 107, .35); }
.tag.warn, .tag.pending { background: rgba(224, 163, 65, .14); color: var(--amber); border-color: rgba(224, 163, 65, .35); }
.tag.suspended { background: rgba(229, 96, 77, .14); color: var(--red); border-color: rgba(229, 96, 77, .35); }

.notice {
    padding: 11px 14px; margin-bottom: 18px;
    background: var(--dialog-card); border: 1px solid var(--dialog-border);
    border-left: 3px solid var(--ink-3); border-radius: var(--radius-sm); font-size: 13px;
}
.notice.ok { border-left-color: var(--green); }
.notice.error { border-left-color: var(--red); }
.notice.warn { border-left-color: var(--amber); }

.credential {
    display: inline-block; margin-left: 8px; padding: 3px 9px;
    font-family: "Cascadia Mono", Consolas, monospace; font-size: 14px; font-weight: 600;
    color: var(--accent); background: var(--field); border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
}

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-bottom: 1px solid var(--hairline); }
.metrics > div { padding: 13px 16px; border-right: 1px solid var(--hairline); }
.metrics > div:last-child { border-right: none; }
.metrics span { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 3px; }
.metrics strong { font-size: 13px; font-weight: 600; }

.summary { border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--chrome-raised); padding: 11px 14px; margin-bottom: 14px; }
.summary > div { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; font-size: 12px; }
.summary span { color: var(--ink-3); }

.device-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 0; }
.device-line-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── auth ───────────────────────────────────────────────────────────── */

.auth-page, .activate-page {
    min-height: 100vh; display: grid; place-items: center;
    padding: 32px 20px; background: var(--dialog-bg);
}
.auth-card, .activate-card {
    width: 100%; background: var(--dialog-card);
    border: 1px solid var(--dialog-border); border-radius: 10px; padding: 32px;
}
.auth-card { max-width: 400px; }
.activate-card { max-width: 470px; }

.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.auth-brand .brand-icon { width: 42px; height: 42px; object-fit: contain; }
.auth-brand strong { display: block; font-size: 15px; font-weight: 600; line-height: 1.25; }
.auth-brand span { font-size: 12px; color: var(--ink-3); }
.auth-help { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.auth-help p { margin: 0; font-size: 11px; color: var(--ink-3); line-height: 1.65; }
.auth-footer { margin: 22px 0 0; font-size: 11px; color: var(--ink-3); text-align: center; }

.code-input {
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 22px; letter-spacing: .2em; text-align: center; text-transform: uppercase;
    padding: 11px; color: var(--accent);
}
.device-card { margin-top: 18px; padding: 13px 15px; border: 1px solid var(--hairline); background: var(--field); border-radius: var(--radius-sm); }
.device-card .label { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.row { display: flex; gap: 8px; margin-top: 18px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: var(--dialog-card); color: var(--ink);
    border-top: 2px solid var(--amber); padding: 11px 20px; font-size: 13px;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; color: var(--ink-3); }

/* Role picker sitting inside a table row: sized to the row, not the form grid. */
.inline-select {
    width: auto; padding: 3px 24px 3px 8px; font-size: 12px;
    background-position: right 9px center, right 5px center;
}

hr.rule { border: 0; border-top: 1px solid var(--hairline); margin: 18px 0; }
