:root {
    --bg: #090c10;
    --bg-soft: #11161c;
    --panel: #0d131a;
    --panel-border: #1f2a35;
    --text: #d5e2ee;
    --muted: #87a0b6;
    --accent: #3fd97b;
    --accent-strong: #2db266;
    --warm: #d5b04a;
    --danger: #e16464;
    --shadow: none;
    --sidebar-bg: #0a1117;
    --sidebar-border: #1e2a34;
    --surface-soft: rgba(255, 255, 255, 0.04);
    --surface-soft-strong: rgba(255, 255, 255, 0.06);
    --control-bg: #0a1219;
    --control-border: rgba(168, 191, 205, 0.18);
    --thead-bg: rgba(255, 255, 255, 0.04);
    --soft-border: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
    --bg: #e8edf2;
    --bg-soft: #d9e0e8;
    --panel: #f5f8fb;
    --panel-border: #b8c6d6;
    --text: #13212d;
    --muted: #4f667d;
    --accent: #0b8a46;
    --accent-strong: #0a6b37;
    --warm: #896f20;
    --danger: #b94646;
    --shadow: none;
    --sidebar-bg: #eef3f8;
    --sidebar-border: #c3d0de;
    --surface-soft: #edf3f8;
    --surface-soft-strong: #ffffff;
    --control-bg: #ffffff;
    --control-border: #b7c5d4;
    --thead-bg: #e4edf5;
    --soft-border: #d8e1ea;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "IBM Plex Mono", "Consolas", "Menlo", "DejaVu Sans Mono", monospace;
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(63, 217, 123, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63, 217, 123, 0.03) 1px, transparent 1px);
    background-size: 16px 16px;
    color: var(--text);
    overflow-x: hidden;
}

.admin-body,
.admin-login-body {
    background-color: var(--bg);
    background-image: none;
}

.portal-body,
.portal-preview-theme {
    background-color: var(--portal-bg-color, var(--bg));
    background-image: none;
    background-position: center;
}

.portal-bg-grid {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 22px 22px;
}

.portal-bg-dots {
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.16) 1.2px, transparent 1.2px),
        radial-gradient(circle, rgba(63, 217, 123, 0.11) 1.1px, transparent 1.1px);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;
}

.portal-bg-diagonal {
    background-image: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.055) 0,
        rgba(255, 255, 255, 0.055) 2px,
        transparent 2px,
        transparent 18px
    );
}

.portal-bg-gradient {
    background-image:
        radial-gradient(circle at 14% 18%, rgba(63, 217, 123, 0.22), transparent 32%),
        radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.1), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(2, 10, 18, 0.28));
}

.portal-bg-none {
    background-image: none;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.portal-shell,
.admin-shell,
.bridge-shell,
.login-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
}

.portal-body,
.admin-body,
.bridge-body,
.admin-login-body {
    padding: 2rem 0 4rem;
}

.admin-body {
    padding: 0;
}

.admin-app {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1rem;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: none;
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 1.3rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.sidebar-section {
    margin-top: 0.35rem;
    display: grid;
    gap: 0.42rem;
}

.sidebar-label {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.25rem;
}

.sidebar-nav a {
    padding: 0.5rem 0.62rem;
    border-radius: 4px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
}

.sidebar-subnav {
    display: grid;
    gap: 0.35rem;
    margin-left: 0.6rem;
    border-left: 1px solid rgba(168, 191, 205, 0.18);
    padding-left: 0.55rem;
}

.sidebar-subnav a {
    display: block;
    width: 100%;
    padding: 0.52rem 0.62rem;
    font-size: 0.92rem;
    border-radius: 4px;
}

.sidebar-section:has(.sidebar-subnav a.active) .sidebar-label {
    color: var(--accent);
}

.sidebar-section:has(.sidebar-subnav a.active) .sidebar-subnav {
    border-left-color: rgba(61, 224, 197, 0.38);
}

.sidebar-nav a.active {
    border-color: rgba(61, 224, 197, 0.34);
    background: rgba(61, 224, 197, 0.14);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(168, 191, 205, 0.14);
}

.sidebar-logout {
    display: block;
    padding: 0.58rem 0.62rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 122, 102, 0.24);
    background: rgba(255, 122, 102, 0.08);
    color: var(--text);
    font-size: 0.9rem;
}

.admin-content {
    width: 100%;
    max-width: 1900px;
    margin: 0;
    padding: 0.9rem 1.1rem 1.7rem;
}

.portal-shell {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.5rem;
    align-items: stretch;
}

.portal-shell-form {
    align-items: stretch;
}

.brand-panel,
.portal-card,
.panel,
.bridge-card,
.login-card,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    backdrop-filter: none;
}

.admin-body .panel,
.admin-body .stat-card,
.admin-body .admin-sidebar,
.admin-login-body .login-card {
    border-radius: 4px;
    box-shadow: none;
    backdrop-filter: none;
}

.brand-panel,
.portal-card,
.bridge-card,
.login-card,
.panel {
    padding: 2rem;
}

.eyebrow {
    margin: 0 0 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(1.25rem, 2.4vw, 2rem);
    line-height: 1.08;
    margin-bottom: 0.45rem;
}

h2 {
    font-size: clamp(1.02rem, 1.8vw, 1.35rem);
    margin-bottom: 0.35rem;
}

.lead,
.muted,
.fact-card span {
    color: var(--muted);
}

.brand-facts,
.stats-grid,
.admin-grid,
.meta-grid {
    display: grid;
    gap: 1rem;
}

.brand-facts {
    margin: 2rem 0;
}

/* Compact portal layout for 1024x768 and similar displays */
@media (max-width: 1200px), (max-height: 820px) {
    .portal-body {
        padding: 0.75rem 0 1rem;
    }

    .portal-shell {
        width: min(1040px, calc(100% - 1rem));
        gap: 0.8rem;
        grid-template-columns: 1fr 1fr;
    }

    .brand-panel,
    .portal-card {
        padding: 1rem 1.05rem;
        border-radius: 4px;
    }

    .brand-facts {
        margin: 0.9rem 0;
        gap: 0.6rem;
    }

    .fact-card,
    .terms-box {
        padding: 0.65rem 0.75rem;
        border-radius: 4px;
    }

    .logo-frame {
        margin-top: 0.7rem;
        padding: 0.55rem;
        border-radius: 4px;
    }

    .logo-frame img {
        max-height: 54px;
    }

    h1 {
        font-size: clamp(1.35rem, 2.5vw, 1.9rem);
        margin-bottom: 0.45rem;
    }

    h2 {
        font-size: clamp(1.05rem, 2vw, 1.3rem);
    }

    .eyebrow {
        margin-bottom: 0.35rem;
        font-size: 0.67rem;
        letter-spacing: 0.1em;
    }

    .lead,
    .muted,
    .fact-card span,
    .terms-box p,
    label span {
        font-size: 0.85rem;
    }

    .stack-form {
        gap: 0.65rem;
    }

    input,
    textarea,
    select,
    button {
        padding: 0.52rem 0.62rem;
        font-size: 0.84rem;
        border-radius: 4px;
    }

    .inline-checkbox {
        padding: 0.65rem 0.75rem;
        border-radius: 4px;
    }

    .alert {
        padding: 0.6rem 0.7rem;
        margin-bottom: 0.6rem;
        border-radius: 4px;
        font-size: 0.85rem;
    }
}

.fact-card,
.terms-box,
.alert,
.filter-tabs a,
.ghost-button,
.danger-button,
.primary-button,
input,
textarea,
select,
table {
    border-radius: 4px;
}

.fact-card,
.terms-box {
    padding: 1rem 1.1rem;
    background: var(--surface-soft);
    border: 1px solid var(--soft-border);
}

.terms-link-button {
    display: inline-flex;
    align-items: center;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    justify-content: flex-start;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    cursor: pointer;
}

.terms-link-button:hover,
.terms-link-button:focus {
    color: var(--accent-strong);
}

.logo-frame {
    margin-top: 2rem;
    padding: 1.2rem;
    background: var(--surface-soft-strong);
    border-radius: 22px;
}

.logo-frame img {
    max-height: 96px;
    object-fit: contain;
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.portal-card .stack-form {
    gap: 0.62rem;
}

.portal-card.stack-form {
    gap: 0.62rem;
}

.portal-card label span {
    margin-bottom: 0.25rem;
    font-size: 0.84rem;
}

.portal-card input,
.portal-card select,
.portal-card textarea,
.portal-card button {
    padding: 0.58rem 0.72rem;
    font-size: 0.9rem;
    border-radius: 4px;
}

.portal-card .inline-checkbox {
    padding: 0.58rem 0.72rem;
    border-radius: 4px;
}

.portal-card .terms-link-button {
    padding: 0;
    border-radius: 0;
}

.portal-card .terms-box {
    margin-top: 0.2rem;
    padding: 0.62rem 0.72rem;
    border-radius: 4px;
}

.portal-card .terms-box h3 {
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

.portal-card .terms-box p {
    margin-bottom: 0;
    font-size: 0.84rem;
}

label span {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.94rem;
}

input,
textarea,
select,
button {
    width: 100%;
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    color: var(--text);
    padding: 0.52rem 0.62rem;
    font: inherit;
    font-size: 0.86rem;
    line-height: 1.2;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}

select,
option {
    color: var(--text);
    background: var(--control-bg);
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(61, 224, 197, 0.35);
    border-color: rgba(61, 224, 197, 0.7);
}

.inline-checkbox {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    background: var(--surface-soft);
    border: 1px solid var(--soft-border);
}

.inline-checkbox input {
    width: auto;
    margin-top: 0.15rem;
}

.primary-button,
.ghost-button,
.danger-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
    width: auto;
    white-space: nowrap;
    padding: 0.42rem 0.64rem;
    font-size: 0.82rem;
    line-height: 1.15;
}

.admin-body .primary-button,
.admin-body .ghost-button,
.admin-body .danger-button,
.admin-body input,
.admin-body select,
.admin-body textarea,
.admin-login-body .primary-button,
.admin-login-body input,
.admin-login-body select,
.admin-login-body textarea {
    border-radius: 8px;
}

.primary-button {
    background: rgba(63, 217, 123, 0.08);
    border: 1px solid rgba(63, 217, 123, 0.34);
    color: var(--accent);
}

.ghost-button {
    background: transparent;
    border: 1px solid rgba(168, 191, 205, 0.22);
    color: var(--text);
}

.danger-button {
    background: rgba(255, 122, 102, 0.12);
    border: 1px solid rgba(255, 122, 102, 0.38);
    color: #ffd8d2;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
    transform: none;
}

.alert {
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(255, 122, 102, 0.12);
    border-color: rgba(255, 122, 102, 0.32);
}

.alert-success {
    background: rgba(61, 224, 197, 0.12);
    border-color: rgba(61, 224, 197, 0.26);
}

.alert-info {
    background: rgba(255, 199, 106, 0.12);
    border-color: rgba(255, 199, 106, 0.28);
}

.bridge-shell,
.login-shell {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 6rem);
}

.bridge-card,
.login-card {
    width: min(560px, 100%);
}

.admin-topbar,
.panel-header,
.toolbar,
.actions-row,
.row-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.topbar-actions {
    display: flex;
    gap: 0.7rem;
    align-items: center;
}

.admin-topbar {
    margin-bottom: 1rem;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.radius-log-shell {
    width: min(100%, calc(100% - 0.2rem));
}

.compact-stats {
    gap: 0.75rem;
}

.compact-stats .stat-card {
    padding: 0.62rem 0.82rem;
    border-radius: 4px;
}

.compact-stats .stat-card strong {
    font-size: 1.15rem;
    margin-top: 0.1rem;
}

.compact-stats .stat-card span {
    font-size: 0.82rem;
}

.stat-card {
    padding: 1.3rem 1.4rem;
}

.stat-card span {
    display: block;
    color: var(--muted);
}

.stat-card strong {
    font-size: 2rem;
    margin-top: 0.3rem;
    display: block;
}

.admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1.5rem;
}

.admin-grid-clients {
    grid-template-columns: minmax(340px, 0.88fr) minmax(0, 1.38fr);
    align-items: start;
}

.panel {
    margin-bottom: 0.9rem;
}

.meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.meta-grid div {
    padding: 0.9rem 1rem;
    background: var(--surface-soft);
    border-radius: 18px;
}

.meta-grid strong,
.meta-grid span {
    display: block;
}

.meta-grid span {
    color: var(--muted);
    margin-top: 0.35rem;
}

.toolbar {
    margin: 1rem 0;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.filter-tabs a {
    padding: 0.75rem 1rem;
    background: var(--surface-soft);
    border: 1px solid var(--soft-border);
}

.filter-tabs a.active {
    background: rgba(61, 224, 197, 0.16);
    border-color: rgba(61, 224, 197, 0.34);
}

.search-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-form input {
    min-width: 220px;
}

.log-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.9rem;
    margin: 1rem 0 1.4rem;
    align-items: end;
}

.log-filters button {
    height: 3.3rem;
}

.log-filters-compact {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(190px, 1fr) minmax(120px, 0.7fr) minmax(240px, 1.7fr) minmax(90px, 0.5fr) auto auto auto;
    gap: 0.65rem;
    margin: 0.9rem 0 1rem;
    align-items: center;
}

.log-filters-compact input,
.log-filters-compact select,
.log-filters-compact button,
.log-filters-compact .ghost-button {
    height: 2.05rem;
}

.log-filters-compact .ghost-button {
    display: inline-flex;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
}

.log-filters-compact .primary-button {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
}

.log-filters-compact select {
    min-width: 0;
    text-overflow: clip;
}

.log-reason {
    max-width: 420px;
    color: var(--muted);
    font-size: 0.9rem;
}

.pagination-row,
.pagination-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.pagination-row {
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-accept {
    background: rgba(61, 224, 197, 0.12);
    border-color: rgba(61, 224, 197, 0.32);
}

.stat-reject {
    background: rgba(255, 122, 102, 0.12);
    border-color: rgba(255, 122, 102, 0.32);
}

.log-status-accept {
    color: var(--accent);
}

.log-status-reject,
.log-status-client_error,
.log-status-key_mismatch,
.log-status-invalid_authenticator,
.log-status-unknown_client {
    color: var(--danger);
}

.log-status-challenge {
    color: var(--warm);
}

.log-status-unanswered {
    color: var(--muted);
}

.raw-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.raw-meta div {
    padding: 0.8rem;
    border-radius: 14px;
    background: var(--surface-soft);
}

.raw-meta strong,
.raw-meta span {
    display: block;
}

.raw-meta span {
    color: var(--muted);
    margin-top: 0.28rem;
}

.raw-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.raw-split article {
    background: var(--surface-soft);
    border: 1px solid var(--soft-border);
    border-radius: 18px;
    padding: 1rem;
}

.raw-split h3 {
    margin-bottom: 0.7rem;
}

.raw-split pre {
    margin: 0;
    background: rgba(4, 14, 22, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 0.9rem;
    overflow-x: auto;
    color: #d6f5ff;
    white-space: pre-wrap;
    word-break: break-word;
}

.table-wrap {
    overflow-x: auto;
    min-width: 0;
}

.table-wrap > table {
    min-width: 100%;
}

.log-row-accept {
    background: rgba(61, 224, 197, 0.08);
}

.log-row-reject,
.log-row-client_error,
.log-row-key_mismatch,
.log-row-unknown_client,
.log-row-invalid_authenticator {
    background: rgba(255, 122, 102, 0.1);
}

.log-row-challenge {
    background: rgba(255, 199, 106, 0.09);
}

.radius-log-table {
    table-layout: auto;
    min-width: 1180px;
}

.radius-log-table th,
.radius-log-table td {
    padding: 0.62rem 0.55rem;
    font-size: 0.86rem;
    vertical-align: top;
}

.radius-log-table .log-reason {
    max-width: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    table-layout: auto;
}

thead {
    background: var(--thead-bg);
}

th,
td {
    padding: 0.52rem 0.58rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.84rem;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: anywhere;
}

th {
    white-space: nowrap;
}

td code {
    white-space: nowrap;
}

.clients-table th,
.clients-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clients-table {
    table-layout: fixed;
}

.clients-table td code {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clients-table th:nth-child(1),
.clients-table td:nth-child(1) {
    width: 14%;
}

.clients-table th:nth-child(2),
.clients-table td:nth-child(2) {
    width: 14%;
}

.clients-table th:nth-child(3),
.clients-table td:nth-child(3) {
    width: 23%;
}

.clients-table th:nth-child(4),
.clients-table td:nth-child(4) {
    width: 9%;
}

.clients-table th:nth-child(5),
.clients-table td:nth-child(5) {
    width: 8%;
}

.clients-table th:nth-child(6),
.clients-table td:nth-child(6) {
    width: 8%;
}

.clients-table th:nth-child(7),
.clients-table td:nth-child(7) {
    width: 24%;
    min-width: 170px;
    overflow-wrap: normal;
    word-break: normal;
}

.clients-table .row-actions {
    gap: 0.45rem;
    flex-wrap: nowrap;
}

.clients-table .row-actions .ghost-button,
.clients-table .row-actions .danger-button {
    white-space: nowrap;
    flex: 0 0 auto;
    min-width: 58px;
    line-height: 1.1;
}

.row-actions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0.4rem;
}

.row-actions > * {
    flex: 0 0 auto;
}

.row-actions form {
    margin: 0;
    display: inline-flex;
}

.row-actions .primary-button,
.row-actions .ghost-button,
.row-actions .danger-button {
    padding: 0.34rem 0.52rem;
    font-size: 0.78rem;
    line-height: 1.05;
}

.row-actions select {
    width: auto;
    min-width: 74px;
}

.clients-table-full {
    width: 100%;
}

.admin-table,
.user-admin-table,
.tenant-overview-table,
.tickets-table {
    table-layout: auto;
}

.user-admin-table {
    min-width: 760px;
}

.tenant-overview-table {
    min-width: 980px;
}

.tickets-table {
    min-width: 1320px;
}

.cell-fit,
.cell-actions,
td.row-actions {
    width: 1%;
    white-space: nowrap;
}

.cell-count {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

th.cell-count {
    text-align: right;
}

.nad-table {
    table-layout: auto;
    min-width: 980px;
}

.nad-table th,
.nad-table td {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.nad-table th.cell-fit,
.nad-table td.cell-fit,
.nad-table th.cell-actions,
.nad-table td.cell-actions {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}

.nad-table th:last-child,
.nad-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

.nad-table .row-actions {
    gap: 0.45rem;
    flex-wrap: nowrap;
}

.nad-table .row-actions form {
    display: inline-flex;
}

.block-sort-title {
    margin: 0 0 0.45rem;
    font-size: 0.92rem;
}

.wysiwyg-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.wysiwyg-editor {
    min-height: 110px;
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    color: var(--text);
    padding: 0.55rem 0.62rem;
    line-height: 1.35;
}

.wysiwyg-editor:focus {
    outline: 2px solid rgba(61, 224, 197, 0.35);
    border-color: rgba(61, 224, 197, 0.7);
}

.block-sort-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.block-sort-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    align-items: start;
}

.portal-editor-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-block-list {
    display: grid;
    gap: 0.85rem;
}

.editor-block-card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--soft-border);
    background: var(--surface-soft);
    border-radius: 8px;
}

.editor-block-card-header {
    display: grid;
    gap: 0.2rem;
}

.editor-block-card-header .eyebrow {
    margin-bottom: 0;
}

.editor-block-card-header h3 {
    margin: 0;
    font-size: 1rem;
}

.editor-block-card .logo-frame {
    margin-top: 0;
}

.block-controls {
    margin-bottom: 0.45rem;
    display: flex;
    justify-content: flex-end;
}

.portal-design-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.portal-design-grid input[type="color"] {
    min-height: 2.7rem;
    padding: 0.2rem;
}

.config-generator-card {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    border: 1px solid var(--soft-border);
    background: var(--surface-soft);
    border-radius: 8px;
}

.config-generator-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
}

.config-output {
    min-height: 22rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    white-space: pre;
    line-height: 1.4;
}

.block-sort-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid var(--control-border);
    background: var(--surface-soft);
    padding: 0.45rem 0.58rem;
    cursor: move;
}

.block-sort-item.dragging {
    opacity: 0.55;
}

.drag-handle {
    color: var(--muted);
}

.spacer-input {
    width: 74px;
    margin-left: auto;
    padding: 0.26rem 0.34rem;
    text-align: right;
}

.portal-preview-frame {
    width: 100%;
    min-height: 680px;
    border: 1px solid var(--panel-border);
    background: #fff;
}

.preview-panel-actions {
    justify-content: flex-end;
}

.preview-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem;
    border: 1px solid var(--soft-border);
    border-radius: 999px;
    background: var(--surface-soft);
}

.preview-mode-toggle .ghost-button {
    border: 0;
    background: transparent;
    padding: 0.38rem 0.72rem;
    border-radius: 999px;
}

.preview-mode-toggle .ghost-button.is-active {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
}

.preview-wysiwyg-toolbar {
    margin-bottom: 0;
}

.portal-preview-shell {
    margin-top: 0.85rem;
    padding: 1rem;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--bg-soft);
}

.portal-preview-surface {
    min-height: 680px;
}

.portal-preview-theme {
    position: relative;
    min-height: 680px;
    padding: 1rem 0 2rem;
    border-radius: 6px;
    overflow: hidden;
}

.portal-preview-surface .portal-shell {
    width: min(1100px, 100%);
    margin: 0 auto;
}

.portal-preview-surface .portal-layout-preview {
    display: grid;
    width: min(1100px, 100%);
    margin: 0 auto;
    gap: 1.5rem;
    align-items: stretch;
}

.portal-preview-shell.is-desktop .portal-layout-preview {
    width: min(1100px, 100%);
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) !important;
}

.portal-preview-shell.is-mobile .portal-layout-preview {
    width: min(420px, 100%);
    grid-template-columns: 1fr !important;
}

.portal-preview-shell.is-mobile .brand-panel,
.portal-preview-shell.is-mobile .portal-card {
    padding: 1rem 1.05rem;
}

.portal-preview-shell.is-mobile .portal-preview-theme {
    padding: 0.75rem 0 1rem;
}

.preview-editable {
    outline: none;
    border-bottom: 1px dashed rgba(168, 191, 205, 0.4);
    transition: border-color 120ms ease, background 120ms ease;
}

.preview-editable:hover,
.preview-editable:focus {
    border-bottom-color: var(--accent);
    background: rgba(63, 217, 123, 0.05);
}

.preview-editable-rich {
    min-height: 1.6rem;
}

.preview-button-surface {
    cursor: default;
}

.preview-button-surface .preview-editable {
    display: inline-block;
    min-width: 2ch;
}

.preview-logo-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
    border: 1px dashed var(--control-border);
}

.portal-soft-modal[hidden] {
    display: none;
}

.portal-soft-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.portal-preview-theme .portal-soft-modal {
    position: absolute;
}

.portal-soft-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 10, 18, 0.68);
    backdrop-filter: blur(5px);
}

.portal-soft-modal-dialog {
    position: relative;
    width: min(720px, calc(100% - 1.4rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    margin: 1rem auto;
    padding: 1rem 1.1rem;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.portal-preview-theme .portal-soft-modal-dialog {
    max-height: calc(100% - 2rem);
}

.portal-soft-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.portal-soft-modal-header h3 {
    margin: 0;
}

.portal-soft-modal-header .ghost-button {
    width: auto;
}

.portal-soft-modal-body {
    line-height: 1.5;
}

.portal-soft-modal-body > :last-child {
    margin-bottom: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0;
    font-size: 0.84rem;
    font-weight: 700;
    border-radius: 0;
    border: 0;
    background: transparent;
}

.status-active {
    color: var(--accent);
}

.status-not_active {
    color: var(--warm);
}

.status-expired {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--muted);
}

.raw-modal[hidden] {
    display: none;
}

.raw-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.raw-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 10, 18, 0.68);
    backdrop-filter: blur(5px);
}

.raw-modal-dialog {
    position: relative;
    width: min(1420px, calc(100% - 1.4rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 6px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.soft-modal-dialog {
    width: min(680px, calc(100% - 1.4rem));
    padding: 1.1rem 1.2rem;
}

.raw-modal-header,
.raw-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.raw-modal-header {
    margin-bottom: 0.9rem;
}

.raw-modal-header h2 {
    margin: 0;
}

.raw-close-x {
    width: auto;
    min-width: 3.2rem;
}

.raw-meta .raw-meta-wide {
    grid-column: span 4;
}

.raw-modal-footer {
    margin-top: 1rem;
    justify-content: flex-end;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 960px) {
    .admin-app {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
    }

    .admin-content {
        width: min(100%, calc(100% - 1rem));
        padding: 1rem 0.5rem 1.4rem;
    }

    .portal-shell,
    .admin-grid,
    .admin-grid-clients,
    .portal-editor-grid,
    .stats-grid,
    .meta-grid {
        grid-template-columns: 1fr;
    }

    .admin-topbar,
    .toolbar,
    .search-form,
    .panel-header,
    .actions-row,
    .topbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .log-filters,
    .log-filters-compact,
    .raw-meta,
    .raw-split {
        grid-template-columns: 1fr;
    }

    .raw-meta .raw-meta-wide {
        grid-column: auto;
    }

    .pagination-row,
    .pagination-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ghost-button,
    .danger-button,
    .search-form button {
        width: 100%;
    }

    .block-sort-grid {
        grid-template-columns: 1fr;
    }

    .portal-design-grid {
        grid-template-columns: 1fr;
    }

    .config-generator-grid {
        grid-template-columns: 1fr;
    }
}

.scope-switcher-wrap {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.scope-switcher {
    display: grid;
    gap: 0.25rem;
    min-width: 220px;
}

.scope-switcher span {
    font-size: 0.8rem;
    color: var(--muted);
}

.scope-switcher select {
    min-width: 220px;
}

.scope-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-end;
}

.theme-toggle-floating {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--muted);
    flex: 0 0 auto;
}

.theme-toggle-floating svg {
    width: 1rem;
    height: 1rem;
}

.theme-toggle-floating:hover {
    color: var(--text);
    border-color: rgba(63, 217, 123, 0.34);
}

.scope-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.32rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.scope-badge-global {
    background: rgba(31, 102, 255, 0.16);
    color: #7fb0ff;
}

.scope-badge-tenant {
    background: rgba(31, 196, 123, 0.16);
    color: #7de6b2;
}

.topbar-actions-wide {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.compact-toolbar,
.compact-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.compact-toolbar {
    justify-content: space-between;
}

.compact-toolbar form {
    margin: 0;
}

.compact-toolbar select {
    width: auto;
    min-width: 220px;
}

.toolbar-button {
    min-width: 9.5rem;
    justify-content: center;
}

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

@media (max-width: 960px) {
    .scope-meta {
        align-items: flex-start;
    }

    .compact-toolbar,
    .compact-toolbar-group {
        align-items: stretch;
        flex-direction: column;
    }

    .scope-switcher,
    .scope-switcher select {
        min-width: 100%;
    }
}
