/* Design tokens. Every colour in the interface resolves to one of these, so a
   theme change is confined to this block and its dark counterpart. */
:root {
    color-scheme: light;

    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel-2: #fafafb;
    --raised: #ffffff;

    --line: #e2e4ea;
    --line-soft: #edeff3;

    --ink: #16181d;
    --ink-2: #565d6d;
    --ink-3: #868d9c;

    --accent: #4b56c9;
    --accent-hover: #3d47b0;
    --accent-ink: #ffffff;
    --accent-soft: #eef0fd;

    --up: #0f7343;
    --up-soft: #e5f4ec;
    --down: #697080;
    --down-soft: #edeff3;
    --warn: #8a5a00;
    --warn-soft: #fbf1de;
    --bad: #b42318;
    --bad-soft: #fdecea;

    --shadow-1: 0 1px 2px rgba(16, 18, 29, .07);
    --shadow-2: 0 2px 4px rgba(16, 18, 29, .06), 0 12px 32px -14px rgba(16, 18, 29, .28);
    --shadow-3: 0 8px 16px rgba(16, 18, 29, .10), 0 32px 64px -24px rgba(16, 18, 29, .38);

    --r-sm: 5px;
    --r: 8px;
    --r-lg: 12px;

    --sidebar-w: 232px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #0e1014;
        --panel: #16191f;
        --panel-2: #1b1e25;
        --raised: #1d2028;

        --line: #2a2e38;
        --line-soft: #23262e;

        --ink: #e8eaef;
        --ink-2: #a3aab9;
        --ink-3: #737b8b;

        --accent: #7f87e8;
        --accent-hover: #949bf0;
        --accent-ink: #12141a;
        --accent-soft: #23263a;

        --up: #4ade80;
        --up-soft: #17301f;
        --down: #8b93a3;
        --down-soft: #23262e;
        --warn: #f0b357;
        --warn-soft: #302512;
        --bad: #f77066;
        --bad-soft: #351a19;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
        --shadow-3: 0 8px 16px rgba(0, 0, 0, .4), 0 32px 64px -24px rgba(0, 0, 0, .8);
    }
}

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

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -.01em;
}

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

a:hover {
    text-decoration: underline;
}

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

.num {
    font-variant-numeric: tabular-nums;
}

.hidden {
    display: none !important;
}

.icon {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.spin {
    animation: spin 900ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.btn:hover:not(:disabled) {
    background: var(--panel-2);
    border-color: var(--ink-3);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn:focus-visible, .input:focus-visible, .select:focus-visible,
.tab:focus-visible, .nav-link:focus-visible, .check: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:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-danger {
    color: var(--bad);
    border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
}

.btn-danger:hover:not(:disabled) {
    background: var(--bad-soft);
    border-color: var(--bad);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--line-soft);
    border-color: transparent;
    color: var(--ink);
}

.btn-sm {
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
}

.btn-icon {
    width: 32px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 26px;
}

/* ── Form controls ───────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
}

.hint {
    font-size: 12px;
    color: var(--ink-3);
}

.input, .select, .textarea {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    width: 100%;
    min-width: 0;
}

.textarea {
    height: auto;
    padding: 8px 10px;
    font-family: var(--mono);
    resize: vertical;
}

.input::placeholder {
    color: var(--ink-3);
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
    appearance: none;
    padding-right: 26px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
        linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: right 12px center, right 7px center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
}

.search .icon {
    position: absolute;
    left: 9px;
    color: var(--ink-3);
    pointer-events: none;
}

.search .input {
    padding-left: 30px;
}

.check {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── App shell ───────────────────────────────────────────────────────── */

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 12px;
    border-right: 1px solid var(--line);
    background: var(--panel);
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 14px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-ink);
    flex: none;
}

.brand-mark .icon {
    width: 17px;
    height: 17px;
}

.brand-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.brand-version {
    font-size: 11px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.nav-link:hover {
    background: var(--line-soft);
    color: var(--ink);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}

.who {
    min-width: 0;
    flex: 1;
}

.who-label {
    font-size: 11px;
    color: var(--ink-3);
}

.who-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content {
    min-width: 0;
    padding: 22px 26px 96px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-title {
    font-size: 21px;
}

.page-sub {
    margin-top: 2px;
    color: var(--ink-2);
    font-size: 13px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
}

.back-link:hover {
    color: var(--ink);
    text-decoration: none;
}

/* ── Panels ──────────────────────────────────────────────────────────── */

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-1);
    margin-bottom: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.panel-title {
    font-size: 14px;
}

.panel-body {
    padding: 14px;
}

.panel-body > :last-child {
    margin-bottom: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    align-items: end;
}

/* ── Stats ───────────────────────────────────────────────────────────── */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    box-shadow: var(--shadow-1);
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
}

.stat-value {
    margin-top: 4px;
    font-size: 25px;
    font-weight: 650;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.stat-foot {
    margin-top: 2px;
    font-size: 12px;
    color: var(--ink-3);
}

.stat.is-up .stat-value { color: var(--up); }
.stat.is-warn .stat-value { color: var(--warn); }

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.toolbar .field {
    width: 158px;
}

.toolbar .field.grow {
    flex: 1;
    min-width: 200px;
    width: auto;
}

.toolbar-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Tables ──────────────────────────────────────────────────────────── */

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--panel-2);
}

.table tbody tr.selected {
    background: var(--accent-soft);
}

.table .col-check {
    width: 34px;
    padding-right: 0;
}

.table .col-actions {
    width: 1%;
    text-align: right;
}

.table .num {
    text-align: right;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    opacity: .55;
    transition: opacity .12s;
}

tr:hover .row-actions, .row-actions:focus-within {
    opacity: 1;
}

.th-sort {
    cursor: pointer;
    user-select: none;
}

.th-sort:hover {
    color: var(--ink);
}

.th-sort::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: 1px;
    border: 4px solid transparent;
}

.th-sort.asc::after {
    border-bottom-color: var(--accent);
    vertical-align: 3px;
}

.th-sort.desc::after {
    border-top-color: var(--accent);
}

/* A cell whose value can be arbitrarily long — a controller URL, a hostname —
   and must not push the row actions out of the panel. */
.table .trunc {
    display: inline-block;
    max-width: 24ch;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.link-cell {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
}

.link-cell:hover {
    text-decoration: underline;
}

/* ── Chips and dots ──────────────────────────────────────────────────── */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 20px;
    padding: 0 7px;
    border-radius: 10px;
    background: var(--down-soft);
    color: var(--down);
    /* The soft backgrounds sit close to the panel they are on, so the outline
       is what makes a chip read as a chip rather than as tinted text. */
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.chip-up { background: var(--up-soft); color: var(--up); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--down);
    flex: none;
}

.dot-up { background: var(--up); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); }

.owner-none {
    color: var(--ink-3);
    font-style: italic;
}

/* ── States ──────────────────────────────────────────────────────────── */

.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 44px 16px;
    color: var(--ink-3);
    font-size: 13px;
    text-align: center;
}

.state .icon {
    width: 22px;
    height: 22px;
}

.note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 11px;
    border-radius: var(--r-sm);
    background: var(--panel-2);
    border: 1px solid var(--line-soft);
    color: var(--ink-2);
    font-size: 12.5px;
}

.note .icon {
    margin-top: 1px;
}

.note-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.note-bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.note-up { background: var(--up-soft); border-color: transparent; color: var(--up); }

/* ── Tabs ────────────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 2px;
    padding: 0 8px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 11px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-2);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--ink);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Key/value grids, used for UCI-style section documents ───────────── */

.kv {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1px;
    background: var(--line-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    overflow: hidden;
}

.kv-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 10px;
    background: var(--panel);
    min-width: 0;
}

.kv-key {
    font-size: 11px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
}

.kv-val {
    font-family: var(--mono);
    font-size: 12.5px;
    word-break: break-word;
}

.kv-val.empty {
    color: var(--ink-3);
    font-style: italic;
}

.sect {
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 10px;
    overflow: hidden;
}

.sect-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: var(--panel-2);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.sect-head .chev {
    transition: transform .15s;
}

.sect.open .sect-head .chev {
    transform: rotate(90deg);
}

.sect-type {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
}

.sect-count {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--ink-3);
    font-weight: 500;
}

.sect-body {
    padding: 10px 12px;
    display: none;
}

.sect.open .sect-body {
    display: block;
}

/* ── Detail summary ──────────────────────────────────────────────────── */

.identity {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px 20px;
    padding: 14px;
}

.identity-item {
    min-width: 0;
}

.identity-key {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.identity-val {
    margin-top: 2px;
    font-size: 13.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.metric {
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--panel-2);
}

.metric-key {
    font-size: 11.5px;
    color: var(--ink-2);
}

.metric-val {
    margin-top: 1px;
    font-size: 19px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.metric-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
    margin-left: 2px;
}

.bar {
    margin-top: 6px;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}

.bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.bar.is-warn > span { background: var(--warn); }
.bar.is-bad > span { background: var(--bad); }

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ── Selection bar ───────────────────────────────────────────────────── */

.selbar {
    position: fixed;
    left: calc(var(--sidebar-w) + 26px);
    right: 26px;
    bottom: 20px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--raised);
    box-shadow: var(--shadow-3);
    animation: rise .16s ease-out;
}

@keyframes rise {
    from { transform: translateY(8px); opacity: 0; }
}

.selbar-count {
    font-size: 13px;
    font-weight: 600;
    padding-right: 4px;
}

.selbar-end {
    margin-left: auto;
}

/* ── Modal ───────────────────────────────────────────────────────────── */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(16, 18, 29, .42);
    backdrop-filter: blur(2px);
    animation: fade .12s ease-out;
}

@keyframes fade {
    from { opacity: 0; }
}

.modal {
    width: 100%;
    max-width: 460px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    animation: rise .16s ease-out;
}

.modal-wide {
    max-width: 760px;
}

.modal-head {
    padding: 15px 18px 0;
}

.modal-title {
    font-size: 16px;
}

.modal-sub {
    margin-top: 3px;
    color: var(--ink-2);
    font-size: 13px;
}

.modal-body {
    padding: 14px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
}

/* ── Toasts ──────────────────────────────────────────────────────────── */

.toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(400px, calc(100vw - 36px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 12px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--raised);
    box-shadow: var(--shadow-2);
    font-size: 13px;
    animation: rise .16s ease-out;
}

.toast .icon {
    margin-top: 1px;
}

.toast-ok .icon { color: var(--up); }
.toast-err .icon { color: var(--bad); }
.toast-info .icon { color: var(--accent); }

.toast-text {
    min-width: 0;
    flex: 1;
}

.toast-detail {
    margin-top: 2px;
    color: var(--ink-2);
    font-size: 12px;
    word-break: break-word;
}

/* ── Secret reveal ───────────────────────────────────────────────────── */

.secret {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.secret-value {
    font-family: var(--mono);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Login ───────────────────────────────────────────────────────────── */

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 372px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--panel);
    box-shadow: var(--shadow-2);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 20px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-foot {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

/* ── v2 units ────────────────────────────────────────────────────────── */

.nav-group {
    margin: 12px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* The selection bar of the v2 devices page carries six actions. */
.selbar {
    flex-wrap: wrap;
}

.load-more {
    padding: 12px 14px;
    border-top: 1px solid var(--line-soft);
    text-align: center;
}

.panel-body > .load-more {
    border-top: none;
}

.output {
    max-height: 340px;
    margin: 10px 0 0;
    padding: 10px 12px;
    overflow: auto;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--panel-2);
    font-family: var(--mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.raw {
    margin-top: 12px;
    font-size: 12.5px;
}

.raw summary {
    cursor: pointer;
    color: var(--ink-2);
    user-select: none;
}

.raw[open] summary {
    margin-bottom: 8px;
}

.json {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    word-break: break-word;
}

.json-block {
    padding-left: 14px;
    border-left: 1px solid var(--line-soft);
}

.json > .json-block {
    padding-left: 0;
    border-left: none;
}

.json-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0 8px;
}

.json-row > .json-block {
    flex-basis: 100%;
}

.json-key {
    color: var(--ink-3);
}

.json-key::after {
    content: ":";
}

.json-inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0 8px;
}

.json-leaf {
    color: var(--ink);
}

.apply-panel {
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel-2);
}

.apply-steps {
    margin-top: 10px;
}

.countdown {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.countdown-value {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.cfg-pair {
    display: inline-flex;
}

.cfg-pair > .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cfg-pair > .btn:last-child {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cfg-editor {
    margin: 0 0 18px;
    padding: 12px 14px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.cfg-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cfg-editor-head h3 {
    font-size: 14px;
}

.cfg-top > .note,
.cfg-conflict > .note {
    margin-bottom: 10px;
}

.cfg-section {
    margin-bottom: 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--panel-2);
}

.cfg-section.is-refused {
    border-color: var(--bad);
}

.cfg-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-soft);
}

.cfg-section-key {
    font-weight: 600;
}

.cfg-section-actions {
    margin-left: auto;
}

.cfg-section-body {
    padding: 10px 12px 12px;
}

.cfg-section.is-deleted .cfg-section-body {
    display: none;
}

.cfg-section.is-deleted .cfg-section-key {
    text-decoration: line-through;
}

.cfg-group + .cfg-group {
    margin-top: 12px;
}

.cfg-group-title {
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.cfg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px 14px;
}

.cfg-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding-left: 8px;
    border-left: 2px solid transparent;
}

.cfg-field.is-changed {
    border-left-color: var(--accent);
}

.cfg-field.is-invalid,
.cfg-field.is-refused {
    border-left-color: var(--bad);
}

.cfg-field.is-invalid .input,
.cfg-field.is-invalid .select,
.cfg-field.is-invalid .textarea,
.cfg-field.is-refused .input,
.cfg-field.is-refused .select,
.cfg-field.is-refused .textarea {
    border-color: var(--bad);
}

.cfg-label {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12px;
    color: var(--ink-2);
}

.cfg-required {
    color: var(--bad);
    text-decoration: none;
}

.cfg-tag {
    font-size: 11px;
    color: var(--ink-3);
}

.cfg-static {
    min-height: 32px;
    display: flex;
    align-items: center;
    font-size: 13px;
}

.cfg-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cfg-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.cfg-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.cfg-message {
    font-size: 12px;
    color: var(--bad);
    word-break: break-word;
}

.cfg-message:empty {
    display: none;
}

.cfg-more {
    margin-top: 12px;
}

.cfg-more > summary {
    cursor: pointer;
    font-size: 12.5px;
    color: var(--ink-2);
    user-select: none;
}

.cfg-more[open] > summary {
    margin-bottom: 10px;
}

.cfg-rules {
    margin: 0;
    padding-left: 18px;
    color: var(--ink-2);
}

.cfg-add {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.cfg-add > .field {
    flex: 1 1 180px;
}

.cfg-add-action {
    padding-top: 22px;
}

.cfg-add > .cfg-message {
    flex-basis: 100%;
}

.cfg-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 860px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .brand {
        padding: 0 8px 0 0;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-foot {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .content {
        padding: 16px 14px 96px;
    }

    .selbar {
        left: 14px;
        right: 14px;
    }
}
