/* FDVPN admin panel. No framework: one stylesheet, one theme in the logo's colours: black, orange, white. */
:root {
    --bg: #000000;
    --surface: #0d0c0b;
    --surface-2: #191715;
    --border: #2b2826;           /* thin lines inside blocks: table rows, inputs, separators */
    --block-border: #8f6440;     /* the frame of every block: cards, tiles, sidebar (muted copper) */
    --text: #ebe7e2;
    --muted: #9e978f;
    --accent: #eea866;           /* soft apricot: links, primary buttons, active nav */
    --accent-hover: #f5c08e;
    --accent-ink: #1a0f05;
    --accent-soft: #261b11;
    --ok: #67c29d;
    --ok-soft: #13261e;
    --warn: #e6cb6a;             /* yellow, so a warning never looks like the orange of every block */
    --warn-soft: #2a2410;
    --danger: #e98585;
    --danger-soft: #2e1717;
    --chart-down: #eea866;
    --chart-up: #6fbfb4;
    --radius: 12px;
    --shadow: none;
    --glow: 0 0 0 1px var(--accent), 0 0 12px rgb(238 168 102 / 15%);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border-radius: 5px; padding: .1em .35em; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem;
    padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--block-border);
}
/* The wordmark has white letters and the page is black, so it needs no badge of its own */
.brand, .logo-badge { display: inline-flex; align-items: center; background: transparent; border-radius: 10px; padding: .45rem .7rem; }
.brand { align-self: flex-start; }
.brand img, .logo-badge img { display: block; height: auto; max-width: 100%; }
.brand:hover { text-decoration: none; opacity: .9; }
.logo-badge { padding: .7rem 1rem; border-radius: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-radius: 8px;
    color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 1.4rem; padding: 0 .4rem; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; text-align: center; }
.badge.danger { background: var(--danger); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .25rem; padding: 0 .5rem; font-size: .85rem; }
.sidebar-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 1.75rem 2rem 3rem; max-width: 1200px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumb { font-size: .85rem; color: var(--muted); }
.crumb::after { content: " /"; }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--block-border); }
    .nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
    .nav a { white-space: nowrap; gap: .4rem; }
    .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: .75rem; }
    .sidebar-foot .muted { display: none; }
    .content { padding: 1.25rem 1rem 2.5rem; }
}

/* ---------- Cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card > p:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.empty { color: var(--muted); padding: .5rem 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { display: flex; flex-direction: column; gap: .25rem; background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; color: var(--text); }
a.tile:hover { text-decoration: none; box-shadow: var(--glow); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-value.small { font-size: 1.15rem; }
.tile-value small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.tile.warn { border-color: var(--warn); }
.tile.danger { border-color: var(--danger); }
.tile.danger .tile-value { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.off td { opacity: .6; }
th[data-sort-key] { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ▲"; }
th[aria-sort="descending"]::after { content: " ▼"; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.row-actions form { margin: 0; }

/* ---------- Pills, dots ---------- */
.pill { display: inline-block; padding: .05rem .55rem; margin: 0 .2rem .2rem 0; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.muted { opacity: .6; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); margin-right: .35rem; vertical-align: baseline; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

/* ---------- Forms, buttons ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 500; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: .5rem .65rem; min-width: 0; width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[readonly] { background: var(--surface-2); font-family: var(--mono); font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem 1rem; align-items: end; margin-top: .5rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; }
.form-actions.sticky { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 35%); margin-bottom: 1rem; }
.inline-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
.narrow { max-width: 12rem; }
form { margin: 0; }

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .9rem;
    padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; text-decoration: none; white-space: nowrap; list-style: none;
}
.button:hover { background: var(--surface-2); text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.danger { color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.small { padding: .25rem .6rem; font-size: .8rem; }
.button.wide { width: 100%; }
.button.big { padding: .85rem 1.2rem; font-size: 1.05rem; }
.button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }

/* (i) next to a label: the explanation shows on hover, keyboard focus or tap (Ui.Hint) */
.hint {
    position: relative; display: inline-grid; place-items: center; flex: none; width: 1.05rem; height: 1.05rem; margin-left: .3rem;
    border: 1px solid var(--muted); border-radius: 50%; color: var(--muted); font: italic 600 .68rem/1 Georgia, serif;
    cursor: help; vertical-align: .12em; user-select: none;
}
.hint:hover, .hint:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.hint::after {
    content: attr(data-tip); position: absolute; z-index: 30; left: -.6rem; bottom: calc(100% + 8px); width: max-content;
    max-width: min(20rem, 72vw); padding: .55rem .7rem; border: 1px solid var(--block-border); border-radius: 8px;
    background: var(--surface-2); color: var(--text); font: 400 .82rem/1.45 var(--font); letter-spacing: 0; text-align: left;
    white-space: normal; text-transform: none; box-shadow: 0 6px 20px rgb(0 0 0 / 60%);
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s;
}
.hint:hover::after, .hint:focus::after { opacity: 1; visibility: visible; }
h2 .hint { font-size: .62rem; }

/* Settings: one compact row per setting, label (with its hint) left, a field sized to its content right */
.setting { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting.stacked { flex-direction: column; align-items: stretch; }
.setting-label { display: inline-flex; align-items: center; min-width: 0; }
.setting-label label { display: inline-flex; flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-size: .9rem; font-weight: 500; }
.setting input, .setting select, .setting textarea { font-size: .86rem; padding: .32rem .55rem; border-radius: 7px; }
.setting .w-xs { width: 5rem; }
.setting .w-sm { width: 9rem; }
.setting .w-md { width: min(15rem, 100%); }
.setting .mono { font-family: var(--mono); font-size: .78rem; }
.setting .range { display: inline-flex; align-items: center; gap: .4rem; }
.settings .card { padding-top: .9rem; padding-bottom: .9rem; }
.settings .card-head { margin-bottom: .25rem; }
.span-all { grid-column: 1 / -1; }
.inline-settings { display: flex; flex-direction: column; max-width: 34rem; }
.inline-settings .form-actions { margin-top: .5rem; }
.protocol-forms form { display: flex; flex-direction: column; min-width: 0; }
.protocol-forms h3 { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .4rem; }
.protocol-forms h3 .pill { margin: 0; }
.protocol-forms p.small { margin: .2rem 0 .35rem; }
.protocol-forms .button.primary { align-self: flex-start; margin-top: .7rem; }
table.compact th, table.compact td { padding: .4rem .6rem; font-size: .88rem; }

/* Servers map: wwwroot/img/world.svg + one dot per server (Pages/Shared/ServerMap.cs) */
.server-map { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.server-map svg { display: block; width: 100%; height: auto; max-height: 26rem; border-radius: 10px; background: #050505; }
.server-map .land { fill: #23201d; stroke: #4a433b; stroke-width: .7; }
.server-map .pin circle { stroke: #000; stroke-width: 1.5; vector-effect: non-scaling-stroke; fill: var(--muted); }
.server-map .pin.ok circle { fill: var(--ok); }
.server-map .pin.down circle { fill: var(--danger); }
.server-map .pin.new circle { fill: var(--warn); }
.server-map .pin circle.glow { fill: var(--ok); stroke: none; opacity: .22; }
.server-map .pin text { fill: var(--text); font-family: var(--font); font-weight: 600; paint-order: stroke; stroke: #000; stroke-linejoin: round; }
.server-map a:hover .pin text, .server-map a:focus-visible .pin text { fill: var(--accent); }
.map-legend { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; font-size: .82rem; color: var(--muted); }
.map-legend .dot { margin-right: .3rem; }

.copy-row { display: flex; gap: .5rem; margin: .5rem 0; }
.copy-row input { flex: 1; }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; margin: .5rem 0; }
details.qr-toggle img { display: block; margin: .5rem 0; background: #fff; border-radius: 8px; max-width: 100%; height: auto; }
details.qr-toggle.inline { position: relative; }
details.qr-toggle.inline > summary { margin: 0; color: var(--text); }
details.qr-toggle.inline[open] img { position: absolute; right: 0; z-index: 5; box-shadow: var(--shadow); border: 1px solid var(--border); }
summary.button::-webkit-details-marker { display: none; }

/* ---------- Flash, alerts ---------- */
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.error-box { background: var(--danger-soft); color: var(--danger); padding: .75rem; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; }

.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.alert-item { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .65rem .85rem; border-radius: 10px; border-left: 4px solid var(--muted); background: var(--surface-2); }
.alert-item > div, .alert-item { flex-wrap: wrap; }
.alert-item > div { display: flex; flex-direction: column; gap: .15rem; }
.alert-item.critical { border-left-color: var(--danger); }
.alert-item.warning { border-left-color: var(--warn); }
.alert-item.info { border-left-color: var(--accent); }
ul.alert-list > li.alert-item:not(:has(> div)) { flex-direction: column; gap: .15rem; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.rank li:last-child { border-bottom: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.services { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .25rem; }

/* ---------- SSH install ---------- */
.ssh-fields { border: 1px solid var(--block-border); border-radius: 10px; padding: .5rem 1rem .75rem; margin: 1rem 0; min-width: 0; }
.ssh-fields legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 600px) { .span-2 { grid-column: auto; } }
textarea { font-family: var(--mono); font-size: .8rem; resize: vertical; }
.stream-log {
    background: #050505; color: #e0e0e0; border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; margin: .75rem 0; max-height: 26rem; overflow: auto;
    white-space: pre-wrap; overflow-wrap: anywhere; border-left: 4px solid var(--accent);
}
.stream-log.ok { border-left-color: var(--ok); }
.stream-log.failed { border-left-color: var(--danger); }

/* ---------- Inbounds ---------- */
.inbound { border: 1px solid var(--block-border); border-radius: 10px; padding: .85rem 1rem; margin-bottom: .75rem; }
.inbound.off { opacity: .65; }
.inbound header { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .35rem; }
.inbound p { margin: .35rem 0; }
.inbound footer { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--border); }

/* ---------- Chart ---------- */
.chart-plot { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .down { fill: var(--chart-down); }
.chart .up { fill: var(--chart-up); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--surface-2); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; pointer-events: none; }
.legend { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--muted); }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.swatch.down { background: var(--chart-down); }
.swatch.up { background: var(--chart-up); }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); border-radius: 8px; padding: .45rem .65rem; font-size: .8rem; line-height: 1.4; white-space: nowrap; transform: translate(-50%, -110%); }

/* ---------- Costs ---------- */
.chart .cost { fill: var(--chart-down); }
.chart .cost-forecast { fill: var(--chart-down); opacity: .35; }
.swatch.cost { background: var(--chart-down); }
.swatch.cost-forecast { background: var(--chart-down); opacity: .35; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 5.5rem 1fr 7.5rem; gap: .75rem; align-items: center; padding: .3rem 0; }
.bars-label { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.bars-value { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.bars-track { position: relative; height: .7rem; }
.bars-track meter { position: absolute; inset: 0; width: 100%; height: 100%; appearance: none; border: 0; background: var(--surface-2); border-radius: 99px; }
.bars-track meter.forecast { opacity: .35; }
.bars-track meter + meter { background: transparent; }
.bars-track meter::-webkit-meter-bar { background: transparent; border: 0; border-radius: 99px; height: 100%; }
.bars-track meter::-webkit-meter-optimum-value { background: var(--chart-down); border-radius: 99px; }
.bars-track meter::-moz-meter-bar { background: var(--chart-down); border-radius: 99px; }
.code-block { background: var(--surface-2); border-radius: 8px; padding: .75rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Public pages (login, connect) ---------- */
body.public { min-height: 100vh; }
.public-main { max-width: 560px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.login-card { margin-top: 12vh; background: var(--surface); border: 1px solid var(--block-border); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem; text-align: center; display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.login-card form { width: 100%; }
.connect-head { display: flex; align-items: center; gap: .85rem; margin-bottom: 1.25rem; }
.connect-head p { margin: 0; }
.connect-main { border-color: var(--accent); }
.connect h2 { margin-bottom: .5rem; }
.platform > summary { list-style: none; color: var(--text); margin: 0; }
.platform > summary::-webkit-details-marker { display: none; }
.platform > summary h2 { display: inline; margin: 0; }
.platform > summary::after { content: "▾"; float: right; color: var(--muted); }
.platform[open] > summary { margin-bottom: .5rem; }
.steps { padding-left: 1.25rem; margin: .5rem 0; }
.apps { list-style: none; padding: 0; margin: 0; }
.apps li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
