/* ==========================================================================
   URL Redirector — design system
   Editorial/Swiss: hairline rules instead of card chrome, tight typography,
   one accent colour, tabular numbers, compact rows.
   No CSS framework. Every colour goes through a token so the dark palette is
   a single block of overrides.
   ========================================================================== */

/* --- Tokens -------------------------------------------------------------- */

:root {
    color-scheme: light;

    --paper:        #fcfcfa;
    --surface:      #ffffff;
    --surface-sunk: #f4f3ef;
    --ink:          #14161a;
    --ink-soft:     #3d424b;
    --muted:        #6b6f76;
    --rule:         #e4e2dc;
    --rule-strong:  #cfccc4;

    --accent:       #1f5fd8;
    --accent-ink:   #ffffff;
    --accent-wash:  rgba(31, 95, 216, .07);
    --accent-line:  rgba(31, 95, 216, .35);

    --ok:      #2f7a4d;
    --ok-wash: rgba(47, 122, 77, .10);
    --warn:      #9a6108;
    --warn-wash: rgba(154, 97, 8, .10);
    --danger:      #b3261e;
    --danger-wash: rgba(179, 38, 30, .08);

    --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

    --fs-xs:   11.5px;
    --fs-sm:   12.5px;
    --fs-base: 14px;
    --fs-md:   15px;
    --fs-lg:   18px;
    --fs-xl:   22px;
    --fs-2xl:  28px;

    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

    --radius: 3px;
    --sidebar-w: 216px;
    --measure: 1180px;
}

:root[data-theme="dark"],
html:not([data-theme="light"]) {
    /* placeholder so the selector list below stays symmetrical */
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --paper:        #101113;
        --surface:      #17181b;
        --surface-sunk: #1c1e22;
        --ink:          #e9e7e2;
        --ink-soft:     #c2c5cb;
        --muted:        #9096a0;
        --rule:         #2a2c31;
        --rule-strong:  #3d4149;

        --accent:       #6f9dff;
        --accent-ink:   #0b1020;
        --accent-wash:  rgba(111, 157, 255, .12);
        --accent-line:  rgba(111, 157, 255, .40);

        --ok:      #56ab7c;
        --ok-wash: rgba(86, 171, 124, .14);
        --warn:      #d09a4c;
        --warn-wash: rgba(208, 154, 76, .14);
        --danger:      #e5766c;
        --danger-wash: rgba(229, 118, 108, .14);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --paper:        #101113;
    --surface:      #17181b;
    --surface-sunk: #1c1e22;
    --ink:          #e9e7e2;
    --ink-soft:     #c2c5cb;
    --muted:        #9096a0;
    --rule:         #2a2c31;
    --rule-strong:  #3d4149;

    --accent:       #6f9dff;
    --accent-ink:   #0b1020;
    --accent-wash:  rgba(111, 157, 255, .12);
    --accent-line:  rgba(111, 157, 255, .40);

    --ok:      #56ab7c;
    --ok-wash: rgba(86, 171, 124, .14);
    --warn:      #d09a4c;
    --warn-wash: rgba(208, 154, 76, .14);
    --danger:      #e5766c;
    --danger-wash: rgba(229, 118, 108, .14);
}

/* --- Reset --------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: var(--fs-base)/1.55 var(--sans);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }

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

code, .mono { font-family: var(--mono); font-size: .92em; }

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: var(--s5) 0;
}

svg.i {
    width: 1em; height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
    vertical-align: -.125em;
}

/* --- App shell ----------------------------------------------------------- */

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

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    border-right: 1px solid var(--rule);
    background: var(--surface);
    padding: var(--s4) 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: var(--s2);
    padding: 0 var(--s4) var(--s5);
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: -.02em;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 var(--s2); }

.nav-label {
    padding: var(--s4) var(--s2) var(--s1);
    font-size: var(--fs-xs);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: 6px var(--s2);
    color: var(--ink-soft);
    border-radius: var(--radius);
    font-size: var(--fs-base);
}
.nav-link:hover { background: var(--surface-sunk); text-decoration: none; color: var(--ink); }
.nav-link.is-active {
    color: var(--accent);
    background: var(--accent-wash);
    box-shadow: inset 2px 0 0 var(--accent);
}
.nav-link svg.i { color: var(--muted); font-size: 15px; }
.nav-link.is-active svg.i { color: var(--accent); }

.sidebar-foot {
    margin-top: auto;
    padding: var(--s4) var(--s4) 0;
    border-top: 1px solid var(--rule);
    font-size: var(--fs-sm);
    color: var(--muted);
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s3) var(--s5);
    border-bottom: 1px solid var(--rule);
    background: var(--surface);
}
.topbar .spacer { margin-left: auto; }
.topbar .who { font-size: var(--fs-sm); color: var(--muted); }

.content { padding: var(--s6) var(--s5) var(--s8); width: 100%; max-width: var(--measure); }

/* --- Page furniture ------------------------------------------------------ */

.page-head {
    display: flex;
    align-items: flex-end;
    gap: var(--s4);
    flex-wrap: wrap;
    padding-bottom: var(--s3);
    border-bottom: 1px solid var(--ink);
    margin-bottom: var(--s5);
}
.page-head .titles { margin-right: auto; min-width: 0; }
.page-head .lede { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

.section { margin-bottom: var(--s6); }
.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--s3);
    padding-bottom: var(--s2);
    border-bottom: 1px solid var(--rule);
    margin-bottom: var(--s3);
}
.section-head h3 { font-size: var(--fs-md); }
.section-head .note { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); }

.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    color: var(--muted);
    margin-bottom: var(--s3);
}
.back:hover { color: var(--ink); text-decoration: none; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font: 500 var(--fs-base)/1 var(--sans);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); text-decoration: none; color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.08); color: var(--accent-ink); border-color: var(--accent); }

.btn-danger { color: var(--danger); border-color: var(--rule-strong); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-danger.is-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger.is-solid:hover { color: #fff; filter: brightness(1.08); }

.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-sunk); color: var(--ink); border-color: transparent; }

.btn-sm { padding: 4px 9px; font-size: var(--fs-sm); }
.btn-icon { padding: 5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-link {
    background: none; border: 0; padding: 0;
    color: var(--accent); font: inherit; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

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

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}
table.data th {
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 var(--s3) var(--s2);
    border-bottom: 1px solid var(--rule-strong);
    white-space: nowrap;
}
table.data td {
    padding: var(--s3);
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}
table.data tbody tr:hover td { background: var(--surface-sunk); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .shrink { width: 1%; white-space: nowrap; }
table.data td:first-child, table.data th:first-child { padding-left: 0; }
table.data td:last-child,  table.data th:last-child  { padding-right: 0; }

table.data.compact td { padding: 7px var(--s3); }

.row-title { font-weight: 550; color: var(--ink); }
.row-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 1px; }

/* --- Status text (no badges) --------------------------------------------- */

.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-sm);
    color: var(--muted);
    white-space: nowrap;
}
.status::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.status.is-on     { color: var(--ok); }
.status.is-off    { color: var(--muted); }
.status.is-warn   { color: var(--warn); }
.status.is-danger { color: var(--danger); }
.status.is-info   { color: var(--accent); }
.status.no-dot::before { display: none; }

.tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: var(--fs-xs);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    color: var(--muted);
    white-space: nowrap;
}
.tag.is-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }
.tag.is-warn   { color: var(--warn);   border-color: var(--warn-wash);   background: var(--warn-wash); }
.tag.is-ok     { color: var(--ok);     border-color: var(--ok-wash);     background: var(--ok-wash); }

.kbd {
    font-family: var(--mono);
    font-size: var(--fs-sm);
    background: var(--surface-sunk);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1px 5px;
}

/* --- Forms --------------------------------------------------------------- */

.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }

.label, label.label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 550;
    color: var(--ink);
    margin-bottom: 5px;
}

.hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 5px; }
.hint code { background: var(--surface-sunk); padding: 0 3px; border-radius: 2px; }

.error { font-size: var(--fs-sm); color: var(--danger); margin-top: 4px; display: block; }
.error:empty { display: none; }

/* ASP.NET always renders the validation summary, marking it valid when there is
   nothing to report — and it contains a hidden <li>, so "has no list items" is not
   a usable test. Hide it on the class the framework sets instead. */
.validation-summary-valid { display: none !important; }
.notice ul { margin: 0; padding-left: 18px; }
.notice li { margin: 2px 0; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=datetime-local],
select, textarea {
    width: 100%;
    padding: 7px 10px;
    font: var(--fs-base)/1.4 var(--sans);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input.mono, textarea.mono, select.mono { font-family: var(--mono); }
input.is-bad { border-color: var(--danger); }
input.is-good { border-color: var(--ok); }

select {
    appearance: none;
    padding-right: 28px;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: var(--s2);
    font-size: var(--fs-base);
    cursor: pointer;
}
.check input[type=checkbox], .check input[type=radio] {
    width: 15px; height: 15px;
    margin: 3px 0 0;
    accent-color: var(--accent);
    flex: none;
    cursor: pointer;
}
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--s2) var(--s4);
}
.check-box {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: var(--s2) var(--s3);
}
.check-box:hover { border-color: var(--rule-strong); }

.row { display: flex; gap: var(--s4); flex-wrap: wrap; }
.row > * { min-width: 0; }
.col     { flex: 1 1 240px; }
.col-2   { flex: 2 1 400px; }
.col-fix { flex: 0 0 auto; }

.form-actions {
    display: flex;
    gap: var(--s2);
    align-items: center;
    padding-top: var(--s4);
    margin-top: var(--s5);
    border-top: 1px solid var(--rule);
}

.inline-form { display: inline; }

/* --- Panels, notices, empty states --------------------------------------- */

.panel {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: var(--s4);
    background: var(--surface);
}
.panel.sunk { background: var(--surface-sunk); border-color: transparent; }

.notice {
    display: flex;
    align-items: flex-start;
    gap: var(--s2);
    padding: 10px var(--s3);
    margin-bottom: var(--s4);
    border-left: 2px solid var(--muted);
    background: var(--surface-sunk);
    font-size: var(--fs-base);
    color: var(--ink-soft);
}
.notice svg.i { margin-top: 3px; }
.notice .close { margin-left: auto; }
.notice.is-ok     { border-left-color: var(--ok);     background: var(--ok-wash);     color: var(--ink); }
.notice.is-warn   { border-left-color: var(--warn);   background: var(--warn-wash);   color: var(--ink); }
.notice.is-danger { border-left-color: var(--danger); background: var(--danger-wash); color: var(--ink); }
.notice.is-info   { border-left-color: var(--accent); background: var(--accent-wash); color: var(--ink); }

.empty {
    text-align: center;
    padding: var(--s7) var(--s4);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    color: var(--muted);
}
.empty h3 { color: var(--ink); margin-bottom: var(--s2); }
.empty svg.i { font-size: 26px; color: var(--rule-strong); margin-bottom: var(--s3); }

/* --- Stats --------------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}
.stat { padding: var(--s4) var(--s4) var(--s4) 0; }
.stat + .stat { border-left: 1px solid var(--rule); padding-left: var(--s4); }
.stat .k {
    font-size: var(--fs-xs);
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}
.stat .v {
    font-size: var(--fs-2xl);
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1.15;
    margin-top: 2px;
}
.stat .s { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }

/* --- Charts -------------------------------------------------------------- */

.chart { position: relative; height: 240px; }
.chart.short { height: 190px; }

/* --- Definition lists ---------------------------------------------------- */

dl.facts { margin: 0; display: grid; grid-template-columns: 150px 1fr; gap: 0; }
dl.facts dt {
    padding: var(--s2) var(--s3) var(--s2) 0;
    border-bottom: 1px solid var(--rule);
    color: var(--muted);
    font-size: var(--fs-sm);
}
dl.facts dd {
    margin: 0;
    padding: var(--s2) 0;
    border-bottom: 1px solid var(--rule);
    min-width: 0;
    overflow-wrap: anywhere;
}

/* --- Dialog -------------------------------------------------------------- */

dialog.sheet {
    width: min(720px, calc(100vw - 32px));
    max-height: min(80vh, 900px);
    padding: 0;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(10, 12, 16, .45); }
dialog.sheet .sheet-head {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s4);
    border-bottom: 1px solid var(--rule);
    position: sticky; top: 0;
    background: var(--surface);
}
dialog.sheet .sheet-body { padding: var(--s4); overflow-y: auto; }
dialog.sheet h4 { margin-top: var(--s5); }
dialog.sheet h4:first-child { margin-top: 0; }

/* --- Auth pages ---------------------------------------------------------- */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s5);
}
.auth-inner { width: 100%; max-width: 360px; }
.auth-brand {
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: -.02em;
    margin-bottom: var(--s1);
}
.auth-lede { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s5); }
.auth-form {
    border-top: 1px solid var(--ink);
    padding-top: var(--s4);
}
.auth-foot { margin-top: var(--s4); font-size: var(--fs-sm); color: var(--muted); }

/* --- Landing ------------------------------------------------------------- */

.landing { max-width: 720px; margin: 0 auto; padding: var(--s8) var(--s5); }
.landing h1 { font-size: 40px; margin-bottom: var(--s3); }
.landing .lede { font-size: var(--fs-lg); color: var(--muted); margin-bottom: var(--s6); }
.landing ul.capabilities { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.landing ul.capabilities li {
    display: flex;
    gap: var(--s4);
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--rule);
    font-size: var(--fs-base);
}
.landing ul.capabilities b { flex: 0 0 168px; font-weight: 550; }
.landing ul.capabilities span { color: var(--muted); }

/* --- Utilities ----------------------------------------------------------- */

.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs    { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack   > * + * { margin-top: var(--s3); }
.stack-s > * + * { margin-top: var(--s2); }
.flex { display: flex; align-items: center; gap: var(--s2); }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.right { margin-left: auto; }
.mt0 { margin-top: 0; } .mt2 { margin-top: var(--s2); } .mt3 { margin-top: var(--s3); }
.mt4 { margin-top: var(--s4); } .mt5 { margin-top: var(--s5); } .mt6 { margin-top: var(--s6); }
.mb0 { margin-bottom: 0; } .mb2 { margin-bottom: var(--s2); } .mb3 { margin-bottom: var(--s3); }
.mb4 { margin-bottom: var(--s4); } .mb5 { margin-bottom: var(--s5); }
.hidden { display: none !important; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--rule);
        padding-bottom: var(--s3);
    }
    .sidebar-foot { display: none; }
    .nav { flex-direction: row; flex-wrap: wrap; gap: var(--s1); }
    .nav-label { width: 100%; padding-top: var(--s3); }
    .nav-link.is-active { box-shadow: inset 0 -2px 0 var(--accent); }
    .content { padding: var(--s5) var(--s4) var(--s7); }
    .stat + .stat { border-left: 0; padding-left: 0; }
    dl.facts { grid-template-columns: 1fr; }
    dl.facts dt { border-bottom: 0; padding-bottom: 0; }
}

/* --- Third-party: tom-select (country picker) ---------------------------- */

.ts-wrapper { width: 100%; }
.ts-control {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 34px;
    padding: 5px 8px !important;
    background: var(--surface) !important;
    border: 1px solid var(--rule-strong) !important;
    border-radius: var(--radius) !important;
    color: var(--ink) !important;
    font-size: var(--fs-base);
}
.ts-wrapper.focus .ts-control {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-wash) !important;
}
.ts-control > .item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-sunk);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1px 4px 1px 6px;
    font-size: var(--fs-sm);
    color: var(--ink);
}
.ts-control input { color: var(--ink) !important; font-size: var(--fs-base); }
.ts-dropdown {
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    color: var(--ink);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    margin-top: 3px;
}
.ts-dropdown .option { padding: 5px 8px; font-size: var(--fs-base); }
.ts-dropdown .active { background: var(--accent-wash); color: var(--ink); }
.ts-dropdown .no-results { padding: 6px 8px; color: var(--muted); }
.ts-control > .item .remove {
    border-left: 0;
    padding: 0 3px;
    color: var(--muted);
    text-decoration: none;
}
.ts-control > .item .remove:hover { color: var(--danger); background: none; }
