/* ------------------------------------------------------------------ *
 *  RADIUS management UI
 * ------------------------------------------------------------------ */
:root {
    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --border:        #dfe4ea;
    --border-strong: #c6cdd6;
    --text:          #16202c;
    --text-dim:      #5b6675;
    --text-faint:    #8a94a2;
    --accent:        #1e6fd9;
    --accent-dark:   #175bb1;
    --accent-soft:   #e8f1fd;
    --ok:            #16794b;
    --ok-soft:       #e2f5eb;
    --warn:          #96650a;
    --warn-soft:     #fdf2dc;
    --danger:        #b3261e;
    --danger-soft:   #fdeceb;
    --sidebar:        #ffffff;
    --sidebar-2:      #eef1f6;
    --sidebar-text:   #475363;
    --sidebar-strong: #16202c;
    --sidebar-muted:  #7b8697;
    --sidebar-line:   #e2e7ee;
    --sidebar-link:   #1e6fd9;
    --radius:        8px;
    --shadow:        0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Dark palette, applied either by explicit choice or by system preference.
   `data-theme` on <html> is set by the inline bootstrap in the page head. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #0f151d;
        --surface:       #161e29;
        --surface-2:     #1b2531;
        --border:        #2a3644;
        --border-strong: #3a4859;
        --text:          #e6ecf3;
        --text-dim:      #9aa7b8;
        --text-faint:    #6f7d90;
        --accent:        #5b9cf5;
        --accent-dark:   #7db0f7;
        --accent-soft:   #172740;
        --ok:            #4ec78e;
        --ok-soft:       #133227;
        --warn:          #e0b357;
        --warn-soft:     #33280f;
        --danger:        #f28b82;
        --danger-soft:   #35191a;
        --sidebar:        #0b1119;
        --sidebar-2:      #1f2a3a;
        --sidebar-text:   #b9c4d4;
        --sidebar-strong: #ffffff;
        --sidebar-muted:  #7f8ea3;
        --sidebar-line:   rgba(255, 255, 255, .07);
        --sidebar-link:   #9fb3cc;
        --shadow:        0 1px 2px rgba(0, 0, 0, .3);
    }
}

:root[data-theme="dark"] {
    --bg:            #0f151d;
    --surface:       #161e29;
    --surface-2:     #1b2531;
    --border:        #2a3644;
    --border-strong: #3a4859;
    --text:          #e6ecf3;
    --text-dim:      #9aa7b8;
    --text-faint:    #6f7d90;
    --accent:        #5b9cf5;
    --accent-dark:   #7db0f7;
    --accent-soft:   #172740;
    --ok:            #4ec78e;
    --ok-soft:       #133227;
    --warn:          #e0b357;
    --warn-soft:     #33280f;
    --danger:        #f28b82;
    --danger-soft:   #35191a;
    --sidebar:        #0b1119;
    --sidebar-2:      #1f2a3a;
    --sidebar-text:   #b9c4d4;
    --sidebar-strong: #ffffff;
    --sidebar-muted:  #7f8ea3;
    --sidebar-line:   rgba(255, 255, 255, .07);
    --sidebar-link:   #9fb3cc;
    --shadow:        0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 224px;
    flex: 0 0 224px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    padding: 15px 18px 13px;
    font-weight: 650;
    font-size: 14px;
    color: var(--sidebar-strong);
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-line);
}
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--sidebar-muted); letter-spacing: 0; }

/* Logo: colour artwork on light, white artwork on dark. Both files ship;
   CSS picks one so there is no flash while swapping themes. */
.logo { flex: 0 0 auto; display: block; height: 26px; width: auto; }
.logo.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo.on-light { display: none; }
    :root:not([data-theme="light"]) .logo.on-dark  { display: block; }
}
:root[data-theme="dark"] .logo.on-light { display: none; }
:root[data-theme="dark"] .logo.on-dark  { display: block; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-section { padding: 14px 10px 6px; font-size: 10.5px; text-transform: uppercase;
               letter-spacing: .09em; color: var(--sidebar-muted); font-weight: 600; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; margin-bottom: 1px;
    border-radius: 6px; color: var(--sidebar-text);
    font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-2); color: var(--sidebar-strong); text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav a .count { margin-left: auto; font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }

.sidebar-foot {
    padding: 12px 14px; border-top: 1px solid var(--sidebar-line);
    font-size: 12px; color: var(--sidebar-muted);
}
.sidebar-foot a { color: var(--sidebar-link); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px; height: 56px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; }
.topbar .spacer { flex: 1; }
.who { font-size: 12.5px; color: var(--text-dim); text-align: right; line-height: 1.35; }
.who strong { display: block; color: var(--text); font-weight: 550; }

.content { padding: 22px 24px 60px; max-width: 1240px; width: 100%; }
/* ---------- theme toggle ---------- */
.theme-toggle {
    flex: 0 0 auto;
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--border-strong); border-radius: 6px;
    background: var(--surface); color: var(--text-dim);
    cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: none; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* On the signed-out / portal pages there is no topbar to sit in. */
.theme-toggle.floating { position: fixed; top: 16px; right: 16px; z-index: 30; }


/* ---------- cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head {
    padding: 13px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); font-weight: 400; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot {
    padding: 12px 16px; border-top: 1px solid var(--border);
    background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius);
    display: flex; gap: 10px; align-items: center;
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px;
         margin-bottom: 18px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 13px 15px; box-shadow: var(--shadow);
}
.stat .n { font-size: 25px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.stat.good .n { color: var(--ok); }
.stat.warn .n { color: var(--warn); }
.stat.bad  .n { color: var(--danger); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-faint);
    padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
    background: var(--surface-2);
}
td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.shrink { width: 1%; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.empty { padding: 34px 16px; text-align: center; color: var(--text-dim); font-size: 13px; }
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

/* ---------- pills ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 100px; font-size: 11.5px; font-weight: 550;
    background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
    white-space: nowrap;
}
.pill.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.pill.bad    { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 5px; color: var(--text); }
label .hint { display: block; font-weight: 400; color: var(--text-dim); font-size: 12px; margin-top: 2px; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 7px 10px; font: inherit; font-size: 13.5px;
    color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: 6px;
}
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[disabled], input[readonly] { background: var(--surface-2); color: var(--text-dim); }

.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin-bottom: 9px; }
.check input { margin-top: 2px; flex: 0 0 auto; }
.check label { margin: 0; font-weight: 450; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 550;
    border-radius: 6px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
.btn.link:hover { background: var(--accent-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
    border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start;
}
.flash.success { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(22,121,75,.2); }
.flash.error   { background: var(--danger-soft); color: var(--danger); border-color: rgba(179,38,30,.2); }
.flash.warning { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(150,101,10,.2); }

/* ---------- misc ---------- */
.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }

.toolbar { display: flex; gap: 9px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar form { display: contents; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h2 { margin: 0 0 3px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; max-width: 62ch; }
.page-head .spacer { flex: 1; }

.secret-box {
    font-family: var(--mono); font-size: 14px; letter-spacing: .06em;
    background: var(--surface-2); border: 1px dashed var(--border-strong);
    border-radius: 6px; padding: 10px 12px; word-break: break-all; user-select: all;
}
.qr { background: #fff; padding: 12px; border-radius: var(--radius);
      border: 1px solid var(--border); display: inline-block; line-height: 0; }
.qr svg { display: block; width: 210px; height: 210px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { position: relative; padding-left: 30px; margin-bottom: 12px; font-size: 13.5px; }
.steps li::before {
    counter-increment: step; content: counter(step);
    position: absolute; left: 0; top: -1px; width: 21px; height: 21px;
    border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    font-size: 11.5px; font-weight: 650; display: grid; place-items: center;
}

.callout {
    border-left: 3px solid var(--accent); background: var(--accent-soft);
    padding: 11px 14px; border-radius: 0 6px 6px 0; font-size: 13px; margin-bottom: 14px;
}
.callout.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.callout.danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.callout p:last-child { margin-bottom: 0; }
.callout p:first-child { margin-top: 0; }

pre.conf {
    font-family: var(--mono); font-size: 12px; line-height: 1.55;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
    padding: 12px; overflow-x: auto; margin: 0; max-height: 320px;
}

/* ---------- centred pages ---------- */
.centered { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.panel { width: 100%; max-width: 420px; }
.panel .card { margin: 0; }
.panel-brand { text-align: center; margin-bottom: 18px; }
.panel-brand .logo { height: 34px; margin: 0 auto 10px; }
.panel-brand .name { font-size: 17px; font-weight: 650; }
.panel-brand .sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0;
           color: var(--text-faint); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.ms-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
    padding: 9px 14px; font-size: 13.5px; font-weight: 550;
    border: 1px solid var(--border-strong); border-radius: 6px;
    background: var(--surface); color: var(--text);
}
.ms-btn:hover { background: var(--surface-2); text-decoration: none; }

details.inline > summary {
    cursor: pointer; font-size: 12.5px; color: var(--accent); list-style: none;
    padding: 3px 0; user-select: none;
}
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > summary::before { content: "▸ "; }
details.inline[open] > summary::before { content: "▾ "; }
details.inline > div { padding-top: 10px; }

.row-form td { background: var(--surface-2); }

/* Settings: Entra section */
.card-body h3 { font-size: 13px; font-weight: 600; margin: 18px 0 4px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { margin: 6px 0; font-size: 13px; }
