* {
    box-sizing: border-box;
}

body {
    margin: 0;

    background: #0e1116;
    color: #e9ecf1;

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

header {
    padding: 18px 28px;

    background: #181c23;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #2b313b;
}

main {
    max-width: 1450px;

    margin: auto;

    padding: 26px;
}

.panel {
    margin-top: 20px;

    padding: 20px;

    background: #181c23;

    border: 1px solid #292f39;

    border-radius: 10px;
}

.stats {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(160px, 1fr)
        );

    gap: 14px;

    margin-top: 20px;
}

.stat {
    padding: 20px;

    background: #181c23;

    border: 1px solid #292f39;

    border-radius: 10px;
}

.number {
    font-size: 28px;

    font-weight: 700;
}

.label {
    color: #929ba8;
}

.muted {
    color: #929ba8;
}

.small {
    font-size: 12px;
}

.good {
    color: #7bd88f;
}

.bad {
    color: #ef7777;
}

.row {
    display: flex;

    gap: 10px;

    flex-wrap: wrap;
}

.actions {
    display: flex;

    align-items: center;

    gap: 8px;

    flex-wrap: wrap;
}

input {
    padding: 10px;

    background: #0f1217;
    color: white;

    border: 1px solid #3b424e;

    border-radius: 7px;
}

button,
.button-link {
    padding: 9px 14px;

    border: 0;

    border-radius: 7px;

    cursor: pointer;

    text-decoration: none;

    display: inline-block;
}

.primary {
    background: #edf0f5;
    color: #111;
}

.danger {
    background: #842f35;
    color: white;
}

.full {
    width: 100%;
}

table {
    width: 100%;

    border-collapse: collapse;
}

th,
td {
    padding: 10px;

    text-align: left;

    border-top: 1px solid #2c333d;

    vertical-align: top;
}

th {
    color: #929ba8;
}

details.product {
    margin-top: 14px;

    border: 1px solid #303743;

    border-radius: 10px;

    overflow: hidden;

    background: #151920;
}

details.product > summary {
    padding: 16px;

    background: #1d222b;

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 15px;

    cursor: pointer;
}

.product-body {
    padding: 12px;
}

details.owner {
    margin: 10px 0;

    border: 1px solid #303743;

    border-radius: 8px;

    overflow: hidden;
}

details.owner > summary {
    padding: 12px 14px;

    background: #171b22;

    display: flex;

    justify-content: space-between;

    cursor: pointer;
}

.owner-id {
    margin-left: 10px;

    color: #8993a1;

    font-family: monospace;

    font-size: 12px;
}

.owner-body {
    overflow-x: auto;
}

summary::-webkit-details-marker {
    margin-right: 8px;
}

.flash {
    margin-bottom: 15px;

    padding: 12px;

    background: #203a29;

    border-radius: 7px;
}

.keybox,
pre {
    background: #0d1015;

    border: 1px solid #37404b;

    border-radius: 7px;

    padding: 14px;

    white-space: pre-wrap;

    word-break: break-word;
}

a {
    color: #aac4ff;
}

.login-body,
.public-body {
    min-height: 100vh;

    display: flex;

    justify-content: center;

    align-items: center;
}

.login-card,
.public-card {
    width: 390px;

    max-width: 92%;

    padding: 32px;

    background: #181c23;

    border: 1px solid #2c323d;

    border-radius: 12px;
}

.login-card input {
    width: 100%;

    margin-bottom: 14px;
}


/* ============================================================
   RADAR DASHBOARD HIERARCHY
   ============================================================ */

details.radar-group,
details.relay-group {
    margin: 12px 0;
    border: 1px solid #303844;
    border-radius: 8px;
    overflow: hidden;
    background: #12161c;
}

/* Remove browser's built-in disclosure marker */
details.radar-group > summary,
details.relay-group > summary {
    list-style: none;
}

details.radar-group > summary::-webkit-details-marker,
details.relay-group > summary::-webkit-details-marker {
    display: none;
}

/* Radar header */
details.radar-group > summary {
    padding: 14px 16px;
    background: #1a2028;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;

    cursor: pointer;
}

/* Relay header */
details.relay-group > summary {
    padding: 12px 16px;
    background: #161b22;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;

    cursor: pointer;
}

/* Our own disclosure arrow */
details.radar-group > summary::before,
details.relay-group > summary::before {
    content: "▶";
    flex: 0 0 auto;
    font-size: 0.8rem;
    margin-right: 4px;
}

details.radar-group[open] > summary::before,
details.relay-group[open] > summary::before {
    content: "▼";
}

/* Let the title block consume available space */
details.radar-group > summary > div,
details.relay-group > summary > div {
    flex: 1;
    min-width: 0;
}

.radar-body {
    padding: 12px;
}

.relay-body {
    padding: 0;
    overflow-x: auto;
}

/* Give nested relay groups some separation */
.radar-body > details.relay-group {
    margin: 8px 0;
}

/* Keep hierarchy visually indented */
.owner-body {
    padding: 12px 16px;
}

.radar-body {
    padding-left: 14px;
    padding-right: 14px;
}

/* Prevent table from touching container edges */
.relay-body table {
    margin: 0;
    width: 100%;
}


/* ============================================================
   OWNER ADMIN CONTROLS
   ============================================================ */

.owner-admin-card {
    margin: 0 0 14px 0;
    padding: 12px 14px;
    border: 1px solid #303844;
    border-radius: 8px;
    background: #11161c;
}

.owner-admin-card > .row {
    margin-top: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.owner-admin-card form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.owner-admin-card input {
    min-width: 220px;
}

#live-status {
    white-space: nowrap;
}


/* ============================================================
   MARK'S LAB ADMIN UX REFRESH
   Append to static/admin.css
   ============================================================ */

:root {
    --ui-bg: #0a0d12;
    --ui-surface: #11161e;
    --ui-surface-2: #171d27;
    --ui-surface-3: #1d2531;
    --ui-border: #2b3442;
    --ui-border-soft: #202836;
    --ui-text: #eef2f7;
    --ui-muted: #93a0b2;
    --ui-accent: #7aa2ff;
    --ui-accent-soft: rgba(122, 162, 255, 0.12);
    --ui-success: #67d69b;
    --ui-success-soft: rgba(103, 214, 155, 0.12);
    --ui-danger: #ff7272;
    --ui-danger-soft: rgba(255, 114, 114, 0.12);
    --ui-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    --ui-radius: 12px;
}

html {
    background: var(--ui-bg);
}

body {
    background:
        radial-gradient(circle at top left, rgba(122,162,255,0.08), transparent 32rem),
        var(--ui-bg);
    color: var(--ui-text);
}

header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(14px);
    background: rgba(10, 13, 18, 0.88);
    border-bottom: 1px solid var(--ui-border-soft);
    box-shadow: 0 8px 30px rgba(0,0,0,0.14);
}

main {
    max-width: 1500px;
    margin: 0 auto;
    padding: 28px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(145deg, #24314a, #151d2b);
    border: 1px solid #34425b;
    color: #dce6ff;
    font-weight: 800;
    letter-spacing: .06em;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--ui-border-soft);
    border-radius: 10px;
}

.nav-link {
    color: var(--ui-muted);
    text-decoration: none;
    padding: 8px 11px;
    border-radius: 7px;
    font-size: .9rem;
    font-weight: 650;
    transition: background .15s ease, color .15s ease;
}

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

.panel,
.stat,
.metric-card,
.profile-hero,
.page-hero {
    border-color: var(--ui-border) !important;
    box-shadow: var(--ui-shadow);
}

.panel {
    background: linear-gradient(180deg, rgba(23,29,39,.94), rgba(17,22,30,.96));
    border-radius: var(--ui-radius);
}

.page-hero {
    margin-bottom: 18px;
    padding: 24px 26px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background:
        linear-gradient(120deg, rgba(122,162,255,.12), transparent 50%),
        var(--ui-surface);
}

.page-hero h1,
.profile-hero h1 {
    margin: 3px 0 6px;
    font-size: clamp(1.55rem, 3vw, 2.25rem);
}

.eyebrow {
    color: var(--ui-accent);
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .72rem;
    font-weight: 800;
}

.compact-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat,
.metric-card {
    background: linear-gradient(180deg, var(--ui-surface-2), var(--ui-surface));
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar .search-wrap {
    flex: 1 1 360px;
}

.toolbar input,
.toolbar select,
.stack-form input,
.stack-form textarea,
.owner-admin-card input {
    width: 100%;
    box-sizing: border-box;
    background: #0d1218;
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    padding: 10px 12px;
    outline: none;
}

.toolbar input:focus,
.toolbar select:focus,
.stack-form input:focus,
.stack-form textarea:focus,
.owner-admin-card input:focus {
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 3px var(--ui-accent-soft);
}

.table-shell {
    overflow-x: auto;
    border: 1px solid var(--ui-border-soft);
    border-radius: 10px;
}

.modern-table,
.table-shell table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th,
.table-shell th {
    background: #111720;
    color: var(--ui-muted);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 750;
}

.modern-table th,
.modern-table td,
.table-shell th,
.table-shell td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--ui-border-soft);
    text-align: left;
    vertical-align: middle;
}

.modern-table tbody tr,
.table-shell tbody tr {
    background: rgba(255,255,255,0.008);
}

.modern-table tbody tr:hover,
.table-shell tbody tr:hover {
    background: rgba(122,162,255,.045);
}

.modern-table tbody tr:last-child td,
.table-shell tbody tr:last-child td {
    border-bottom: 0;
}

.avatar-name {
    color: var(--ui-text);
    font-weight: 750;
    text-decoration: none;
}

.avatar-name:hover {
    color: var(--ui-accent);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .02em;
    border: 1px solid transparent;
}

.success-badge {
    color: var(--ui-success);
    background: var(--ui-success-soft);
    border-color: rgba(103,214,155,.23);
}

.danger-badge {
    color: var(--ui-danger);
    background: var(--ui-danger-soft);
    border-color: rgba(255,114,114,.23);
}

.count-pill {
    display: inline-block;
    min-width: 32px;
    padding: 4px 8px;
    text-align: center;
    border-radius: 999px;
    background: var(--ui-surface-3);
    border: 1px solid var(--ui-border);
    font-weight: 750;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 16px 0 18px;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(122,162,255,.13), transparent 55%),
        var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(145deg, #263553, #171e2c);
    border: 1px solid #3a4a69;
    font-size: 1.7rem;
    font-weight: 850;
}

.profile-heading {
    min-width: 0;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card {
    padding: 17px;
}

.metric-label {
    color: var(--ui-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 7px;
}

.metric-value {
    font-size: 1.55rem;
    font-weight: 800;
}

.small-value {
    font-size: .98rem;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
}

.section-heading h3 {
    margin: 3px 0 0;
}

.detail-list {
    display: grid;
    gap: 2px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 11px 0;
    border-bottom: 1px solid var(--ui-border-soft);
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-row span {
    color: var(--ui-muted);
}

.stack-form {
    display: grid;
    gap: 10px;
}

.alert-card {
    padding: 13px 14px;
    border-radius: 9px;
    margin-bottom: 12px;
}

.danger-alert {
    background: var(--ui-danger-soft);
    border: 1px solid rgba(255,114,114,.23);
}

.back-link {
    color: var(--ui-muted);
    text-decoration: none;
    font-size: .9rem;
}

.back-link:hover {
    color: var(--ui-text);
}

.empty-state {
    padding: 32px !important;
    text-align: center !important;
    color: var(--ui-muted);
}

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

.button-link,
button {
    border-radius: 8px !important;
}

.button-link.primary-link {
    background: var(--ui-accent-soft);
    color: #dce6ff;
    border-color: rgba(122,162,255,.32);
}

details.product,
details.owner,
details.radar-group,
details.relay-group {
    transition: border-color .15s ease, background .15s ease;
}

details.product:hover,
details.owner:hover,
details.radar-group:hover,
details.relay-group:hover {
    border-color: #3a4658;
}

summary {
    user-select: none;
}

.flash {
    border-radius: 9px;
    border: 1px solid rgba(122,162,255,.28);
    background: rgba(122,162,255,.10);
}

@media (max-width: 900px) {
    header {
        position: static;
        align-items: flex-start;
        gap: 14px;
    }

    header > .row {
        flex-wrap: wrap;
    }

    .top-nav {
        width: 100%;
        overflow-x: auto;
    }

    .compact-stats,
    .metric-grid,
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 620px) {
    main {
        padding: 16px;
    }

    .compact-stats,
    .metric-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .profile-hero {
        align-items: flex-start;
    }

    .profile-avatar {
        width: 54px;
        height: 54px;
        flex-basis: 54px;
        border-radius: 14px;
    }

    .toolbar {
        align-items: stretch;
    }

    .toolbar > * {
        width: 100%;
    }
}

/* Dashboard v10 additions: pagination + read-only user management */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(127,127,127,.22);
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-pill {
    display: inline-flex;
    min-width: 2.25rem;
    min-height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(127,127,127,.3);
    border-radius: .55rem;
    font-weight: 700;
}

.user-create-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

.user-create-grid label {
    display: grid;
    gap: .4rem;
}

.user-create-action {
    display: flex;
    align-items: end;
}

@media (max-width: 800px) {
    .user-create-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Dashboard v10 additions: pagination + read-only user management */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(127,127,127,.22);
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-pill {
    display: inline-flex;
    min-width: 2.25rem;
    min-height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(127,127,127,.3);
    border-radius: .55rem;
    font-weight: 700;
}

.user-create-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

.user-create-grid label {
    display: grid;
    gap: .4rem;
}

.user-create-action {
    display: flex;
    align-items: end;
}

@media (max-width: 800px) {
    .user-create-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Dashboard v11 additions: account + access security */
.fingerprint {
    display: inline-block;
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.ua-cell {
    max-width: 28rem;
    overflow-wrap: anywhere;
    font-size: .82rem;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-panel {
    width: min(28rem, 100%);
}

.login-panel form,
.login-panel label {
    display: grid;
    gap: .55rem;
}

.login-panel form {
    gap: 1rem;
}

/* Dashboard v10 additions: pagination + read-only user management */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(127,127,127,.22);
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-pill {
    display: inline-flex;
    min-width: 2.25rem;
    min-height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(127,127,127,.3);
    border-radius: .55rem;
    font-weight: 700;
}

.user-create-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

.user-create-grid label {
    display: grid;
    gap: .4rem;
}

.user-create-action {
    display: flex;
    align-items: end;
}

@media (max-width: 800px) {
    .user-create-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Dashboard v11 additions: account + access security */
.fingerprint {
    display: inline-block;
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.ua-cell {
    max-width: 28rem;
    overflow-wrap: anywhere;
    font-size: .82rem;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-panel {
    width: min(28rem, 100%);
}

.login-panel form,
.login-panel label {
    display: grid;
    gap: .55rem;
}

.login-panel form {
    gap: 1rem;
}

/* Dashboard v12 additions: shared navigation + account IP monitoring */
.top-nav {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

.warning-badge {
    font-weight: 700;
}

.ip-history {
    margin-top: .45rem;
}

.ip-history summary {
    cursor: pointer;
    font-size: .82rem;
}

.ip-history-list {
    display: grid;
    gap: .35rem;
    margin-top: .45rem;
    min-width: 17rem;
}
