:root {
    color-scheme: dark;
    --bg: #111312;
    --surface: #181b1a;
    --surface-2: #202423;
    --border: #313735;
    --text: #f2f5f2;
    --muted: #9da8a2;
    --primary: #3ddc97;
    --primary-strong: #20b875;
    --accent: #63b3ed;
    --warning: #f5b84b;
    --danger: #f87171;
    --success: #36d399;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f7f6;
    --surface: #ffffff;
    --surface-2: #eef1ef;
    --border: #d9dfdc;
    --text: #1b211e;
    --muted: #63706a;
    --primary: #087f5b;
    --primary-strong: #04684a;
    --accent: #2563eb;
    --warning: #b7791f;
    --danger: #dc2626;
    --success: #059669;
    --shadow: 0 14px 36px rgba(27, 33, 30, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 22px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

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

.brand {
    flex-shrink: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(61, 220, 151, 0.55);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(61, 220, 151, 0.25), rgba(99, 179, 237, 0.2));
    color: var(--text);
    font-weight: 800;
}

.brand-mark.large {
    width: 56px;
    height: 56px;
    font-size: 18px;
}

.brand strong,
.user-chip strong {
    display: block;
}

.brand small,
.user-chip small,
td small,
.list-item span,
.metric-card small,
.page-heading p {
    color: var(--muted);
}

.nav-stack {
    display: grid;
    flex: 1 1 auto;
    grid-auto-rows: max-content;
    align-content: start;
    gap: 6px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
}

.nav-group {
    display: grid;
    gap: 4px;
}

.nav-group > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

.nav-group > summary::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.16s ease;
}

.nav-group[open] > summary::after {
    transform: rotate(45deg);
}

.nav-group > summary:hover,
.nav-group.active > summary {
    background: var(--surface-2);
    color: var(--text);
}

.nav-group.active > summary {
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-substack {
    display: grid;
    gap: 3px;
    margin-left: 13px;
    padding-left: 13px;
    border-left: 1px solid var(--border);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
}

.nav-substack .nav-link {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 14px;
}

.nav-link-root {
    margin-bottom: 2px;
}

.nav-link:hover,
.nav-link.active {
    background: var(--surface-2);
    color: var(--text);
}

.nav-link.active {
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
    display: grid;
    place-items: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(99, 179, 237, 0.14);
    color: var(--accent);
}

.nav-substack .nav-icon {
    flex-basis: 22px;
    width: 22px;
    height: 22px;
}

.nav-icon svg {
    display: block;
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.nav-substack .nav-icon svg {
    width: 14px;
    height: 14px;
}

.sidebar-footer {
    display: grid;
    gap: 12px;
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #08110d;
    font-weight: 800;
}

.main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(18px);
}

.global-search {
    flex: 1;
}

.global-search input,
.filter-bar input,
.filter-bar select,
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.form-field select[multiple] {
    min-height: 132px;
}

.multiselect-tools {
    display: grid;
    gap: 8px;
}

.multiselect-tools input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    background: var(--surface-2);
    color: var(--text);
}

.multiselect-counter {
    color: var(--muted);
    font-size: 12px;
}

.native-select-hidden {
    display: none !important;
}

.dual-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
}

.dual-list-pane {
    display: grid;
    grid-template-rows: auto auto minmax(180px, 260px);
    gap: 8px;
    min-width: 0;
}

.dual-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dual-list-heading strong {
    color: var(--text);
}

.dual-list-heading span,
.dual-list-empty {
    color: var(--muted);
    font-size: 12px;
}

.dual-list-pane input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    background: var(--surface-2);
    color: var(--text);
}

.dual-list-items {
    min-height: 180px;
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
}

.dual-list-item {
    display: block;
    width: 100%;
    min-height: 32px;
    margin: 0 0 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 7px 9px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.dual-list-item:hover {
    border-color: var(--border);
    background: var(--surface-2);
}

.dual-list-item.active {
    border-color: rgba(61, 220, 151, 0.5);
    background: rgba(61, 220, 151, 0.16);
}

.dual-list-controls {
    display: grid;
    align-content: center;
    gap: 8px;
}

.dual-list-controls button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    font-weight: 800;
}

.dual-list-controls button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.dual-list-empty {
    margin: 8px;
}

.extension-editor {
    display: grid;
    gap: 10px;
}

.extension-editor-add,
.extension-editor-tools {
    display: grid;
    gap: 10px;
    align-items: center;
}

.extension-editor-add {
    grid-template-columns: minmax(0, 1fr) auto;
}

.extension-editor-tools {
    grid-template-columns: minmax(0, 1fr) auto;
}

.extension-editor-count,
.extension-editor-hint {
    color: var(--muted);
    font-size: 12px;
}

.extension-editor-list {
    display: grid;
    gap: 6px;
    min-height: 132px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
}

.extension-editor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 6px 4px 10px;
    background: var(--surface-2);
}

.extension-editor-item span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.35;
}

.extension-editor-item .icon-button {
    width: 26px;
    min-width: 26px;
    min-height: 26px;
    padding: 0;
    color: var(--danger);
}

.extensions-summary-cell {
    width: 36%;
    max-width: 520px;
}

.extension-summary {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.extension-summary > strong {
    font-size: 13px;
}

.extension-summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-height: 72px;
    overflow: hidden;
}

.extension-summary-chip {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    line-height: 1.4;
}

.extension-summary-empty {
    color: var(--muted);
    font-size: 12px;
}

.default-policy-summary {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.default-policy-summary div {
    display: grid;
    gap: 4px;
}

.default-policy-summary strong {
    font-size: 12px;
    color: var(--muted);
}

.default-policy-summary span {
    color: var(--text);
}

.selection-panel {
    display: grid;
    grid-template-rows: auto auto;
    min-height: 0;
}

.selection-panel .form-field {
    min-height: 0;
}

.selection-panel .dual-list {
    min-height: 0;
}

.global-search input:focus,
.filter-bar input:focus,
.filter-bar select:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.15);
}

.content {
    padding: 28px;
}

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

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.page-heading h1,
.auth-panel h1 {
    margin: 0;
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1.08;
}

.page-heading p,
.auth-panel p {
    margin: 7px 0 0;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 800;
    color: var(--primary) !important;
}

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

.metric-card,
.panel,
.table-panel,
.form-panel,
.auth-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 12px;
}

.metric-card strong {
    font-size: 34px;
}

.metric-grid.compact {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
    margin-bottom: 10px;
}

.metric-grid.compact .metric-card {
    padding: 12px;
}

.metric-grid.compact .metric-card span {
    margin-bottom: 6px;
}

.metric-grid.compact .metric-card strong {
    font-size: 22px;
}

.metric-card.success strong {
    color: var(--success);
}

.metric-card.danger strong {
    color: var(--danger);
}

.metric-card.warning strong {
    color: var(--warning);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

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

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

.stat-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 1.8rem;
}

.span-2 {
    grid-column: span 2;
}

.panel {
    padding: 18px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.panel-heading h2 {
    margin: 0;
}

.panel-heading a {
    color: var(--primary);
    font-weight: 700;
}

.chart-list,
.stack-list,
.alert-list {
    display: grid;
    gap: 10px;
}

.chart-row {
    display: grid;
    grid-template-columns: minmax(86px, 1fr) minmax(120px, 3fr) 36px;
    gap: 10px;
    align-items: center;
}

.bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}

.bar span,
.mini-bars span {
    display: block;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.bar span {
    height: 100%;
}

.mini-bars {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    align-items: end;
    gap: 12px;
    min-height: 180px;
}

.mini-bars div {
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: end;
    height: 170px;
    gap: 8px;
}

.mini-bars span {
    width: 100%;
    min-height: 6px;
    border-radius: 6px 6px 0 0;
}

.mini-bars small {
    text-align: center;
    color: var(--muted);
}

.alert-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.alert-list li {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px;
    border-radius: 8px;
    background: var(--surface-2);
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
}

.dot.warning {
    background: var(--warning);
}

.dot.danger {
    background: var(--danger);
}

.list-item {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.list-item:hover {
    border-color: var(--primary);
}

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

.client-summary-item {
    display: grid;
    gap: 6px;
    min-height: 104px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
}

.client-summary-item:hover {
    border-color: var(--primary);
}

.client-summary-item span,
.client-summary-item small {
    color: var(--muted);
}

.client-summary-item strong {
    color: var(--text);
    font-size: 30px;
    line-height: 1;
}

.compact-details {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.compact-details summary,
.api-key-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}

.compact-details summary {
    min-height: 42px;
    padding: 10px 12px;
}

.compact-details summary::-webkit-details-marker,
.api-key-summary::-webkit-details-marker {
    display: none;
}

.compact-details summary::after,
.api-key-summary::after {
    content: "+";
    display: inline-grid;
    place-items: center;
    width: 24px;
    min-width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--primary);
    font-weight: 800;
}

.compact-details[open] > summary::after,
.api-key-details[open] > .api-key-summary::after {
    content: "-";
}

.compact-details summary span,
.api-key-summary strong {
    font-weight: 800;
}

.compact-details summary small {
    margin-left: auto;
    color: var(--muted);
}

.compact-details-body,
.api-key-details-body {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding: 12px;
}

.compact-checkbox-grid ul {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.api-key-details {
    padding: 0;
}

.api-key-summary {
    min-height: 58px;
    padding: 12px;
}

.api-key-summary-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-bar.single {
    grid-template-columns: minmax(0, 1fr) auto;
}

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

.table-panel.embedded {
    border: 0;
    box-shadow: none;
    background: transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1040px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

th .sort-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    color: var(--muted);
}

th .sort-link:hover,
th .sort-link.active {
    color: var(--text);
}

.sort-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    color: var(--primary);
}

td small {
    display: block;
    margin-top: 4px;
}

.machine-id {
    display: inline-block;
    max-width: min(100%, 260px);
    overflow-wrap: anywhere;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 6px;
    background: var(--surface-2);
    color: var(--accent);
    font-size: 12px;
    line-height: 1.35;
}

.path-text {
    display: inline-block;
    max-width: min(100%, 420px);
    overflow-wrap: anywhere;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
}

.path-text.large {
    max-width: 100%;
    margin: 0;
    color: var(--text);
    font-size: 14px;
}

.address-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    max-width: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 9px;
    background: var(--surface-2);
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
}

.address-button:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--surface-2) 82%, var(--accent));
}

.monitoring-cell {
    display: grid;
    grid-template-columns: minmax(112px, 1fr) minmax(96px, 0.9fr);
    gap: 10px;
    align-items: center;
    min-width: 220px;
}

.monitoring-cell div {
    display: grid;
    gap: 3px;
}

.monitoring-cell span,
.monitor-inline small {
    color: var(--muted);
    font-size: 12px;
}

.monitoring-cell strong,
.monitor-inline strong {
    color: var(--text);
    font-size: 13px;
    line-height: 1.2;
}

.monitoring-cell small {
    color: var(--muted);
    font-size: 12px;
}

.monitor-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-suspended-text {
    color: var(--warning) !important;
}

tr:last-child td {
    border-bottom: 0;
}

tr.is-danger {
    background: rgba(248, 113, 113, 0.06);
}

tr.is-warning {
    background: rgba(245, 184, 75, 0.08);
}

.strong-link {
    font-weight: 800;
}

.button-row,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.sync-action {
    display: grid;
    justify-items: end;
    gap: 6px;
}

.sync-action small {
    color: var(--muted);
    font-size: 12px;
}

.row-actions {
    width: 280px;
    min-width: 280px;
    text-align: right;
    white-space: nowrap;
}

.row-actions > * {
    margin-left: 8px;
}

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

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 9px 13px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    background: var(--primary);
    color: #07120d;
}

.primary-button:hover {
    background: var(--primary-strong);
}

.ghost-button,
.icon-button {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.danger-button {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.45);
    color: var(--danger);
}

.small {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 13px;
}

.full {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.status-active {
    color: var(--success);
    border-color: rgba(54, 211, 153, 0.4);
}

.status-new {
    color: var(--accent);
    border-color: rgba(99, 179, 237, 0.45);
}

.status-in_review {
    color: var(--warning);
    border-color: rgba(245, 184, 75, 0.45);
}

.status-resolved {
    color: var(--success);
    border-color: rgba(54, 211, 153, 0.4);
}

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

.status-expired,
.status-blocked,
.status-canceled {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.45);
}

.status-suspended {
    color: var(--warning);
    border-color: rgba(245, 184, 75, 0.45);
}

.status-pending,
.status-skipped {
    color: var(--warning);
    border-color: rgba(245, 184, 75, 0.45);
}

.status-sent {
    color: var(--success);
    border-color: rgba(54, 211, 153, 0.4);
}

.status-error {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.45);
}

.form-panel {
    padding: 20px;
}

.form-panel.narrow {
    max-width: 680px;
}

.embedded-form {
    border: 0;
    background: transparent;
    margin-bottom: 14px;
    padding: 14px;
    box-shadow: none;
}

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

.form-field {
    display: grid;
    gap: 7px;
}

.form-field label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.form-field textarea {
    resize: vertical;
}

.form-field input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
}

.form-table {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.form-table table {
    margin: 0;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    color: var(--text);
    font-weight: 800;
}

.inline-check input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.form-check {
    margin-top: 14px;
}

.checkbox-grid ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
}

.field-error {
    color: var(--danger);
}

.alert-settings-section {
    display: grid;
    gap: 14px;
    margin-bottom: 22px;
}

.alert-matrix {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.alert-matrix table {
    min-width: 820px;
}

.alert-matrix td,
.alert-matrix th {
    text-align: center;
}

.alert-matrix td:first-child,
.alert-matrix th:first-child {
    text-align: left;
}

.alert-matrix input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.alert-template-panel {
    margin-bottom: 16px;
}

.alert-template-list {
    display: grid;
    gap: 8px;
}

.alert-template-list-head,
.alert-template-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.05fr) minmax(280px, 1.8fr) minmax(180px, 0.9fr) minmax(90px, 0.55fr) minmax(145px, 0.75fr);
    gap: 12px;
    align-items: center;
}

.alert-template-list-head {
    padding: 0 14px 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.alert-template-row {
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.alert-template-row:hover,
.alert-template-row.active {
    border-color: rgba(61, 220, 151, 0.5);
    background: var(--surface-2);
}

.alert-template-row.active {
    box-shadow: inset 3px 0 0 var(--primary);
}

.alert-template-row span {
    color: var(--muted);
}

.alert-template-row strong {
    color: var(--text);
}

.template-channel-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.alert-template-editor {
    display: grid;
    gap: 18px;
}

.alert-template-body {
    display: grid;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface);
}

.panel-heading.compact {
    margin-bottom: 0;
}

.template-tabs,
.template-variable-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-variable-bar {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.template-tab-panel {
    display: none;
}

.template-tab-panel.active {
    display: grid;
    gap: 10px;
}

.alert-template-editor textarea {
    min-height: 360px;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.45;
    tab-size: 2;
}

.template-preview-subject {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
    font-weight: 800;
}

.template-preview-frame {
    width: 100%;
    min-height: 360px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.template-preview-code {
    min-height: 360px;
    overflow: auto;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: #1f2430;
    color: #f8fafc;
    white-space: pre-wrap;
}

.template-preview-error {
    color: #fecaca;
}

.template-teams-preview {
    display: none;
    min-height: 360px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    background: #f5f6fb;
    color: #252423;
}

.template-telegram-preview {
    display: none;
    min-height: 360px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    background: #e7f3ff;
    color: #17212b;
}

.telegram-message {
    width: min(100%, 620px);
    border-radius: 8px;
    padding: 12px 14px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.telegram-message-header {
    margin-bottom: 8px;
    color: #2aabee;
    font-size: 12px;
    font-weight: 800;
}

.telegram-message pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ac-card {
    display: grid;
    gap: 12px;
    max-width: 620px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 16px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.ac-container {
    display: grid;
    gap: 7px;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}

.ac-container.style-attention {
    border-left: 4px solid #c4314b;
    background: #fff1f2;
}

.ac-container.style-good {
    border-left: 4px solid #0f7b0f;
    background: #effaf0;
}

.ac-container.style-warning {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.ac-text {
    color: #252423;
    line-height: 1.35;
}

.ac-text.bolder {
    font-weight: 800;
}

.ac-text.subtle {
    color: #605e5c;
}

.ac-text.size-small {
    font-size: 12px;
}

.ac-text.size-medium {
    font-size: 16px;
}

.ac-text.size-large {
    font-size: 21px;
}

.ac-text.size-extralarge {
    font-size: 26px;
}

.ac-facts {
    display: grid;
    gap: 8px;
    margin: 0;
}

.ac-facts div {
    display: grid;
    grid-template-columns: minmax(100px, 0.35fr) minmax(0, 1fr);
    gap: 10px;
}

.ac-facts dt {
    color: #605e5c;
    font-weight: 800;
}

.ac-facts dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.ac-columns {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.ac-column {
    display: grid;
    flex: 1 1 0;
    gap: 8px;
    min-width: 0;
}

.ac-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.ac-image.align-center {
    margin-left: auto;
    margin-right: auto;
}

.ac-image.align-right {
    margin-left: auto;
}

.ac-image-fallback {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 34px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 7px 10px;
    background: #ffffff;
    color: #6b7280;
    font-size: 12px;
}

.ac-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.ac-action {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border-radius: 4px;
    padding: 8px 12px;
    background: #5b5fc7;
    color: #ffffff;
    font-weight: 800;
}

.ac-action.disabled {
    background: #e5e7eb;
    color: #605e5c;
}

.ac-unsupported {
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    padding: 8px;
    color: #605e5c;
    font-size: 12px;
}

.alert-history-panel {
    margin-top: 16px;
}

.mfa-qr {
    display: grid;
    place-items: center;
    width: min(100%, 248px);
    margin: 0 auto 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
}

.mfa-qr svg {
    display: block;
    width: 100%;
    height: auto;
}

.mfa-secret {
    display: block;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    color: var(--text);
    overflow-wrap: anywhere;
    text-align: center;
}

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

.recovery-code-grid code {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-2);
    color: var(--text);
    text-align: center;
    font-weight: 800;
}

.form-actions {
    margin-top: 20px;
}

.definition-list {
    display: grid;
    grid-template-columns: minmax(130px, 0.35fr) 1fr;
    gap: 12px;
    margin: 0;
}

.definition-list dt {
    color: var(--muted);
}

.definition-list dd {
    margin: 0;
}

.preline {
    white-space: pre-line;
    color: var(--muted);
}

.messages {
    display: grid;
    gap: 8px;
    padding: 0 28px;
}

.message {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--surface);
    overflow-wrap: anywhere;
}

.message.success {
    border-color: rgba(54, 211, 153, 0.45);
}

.message.error {
    border-color: rgba(248, 113, 113, 0.5);
    color: var(--danger);
}

.empty {
    color: var(--muted);
    padding: 12px 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    color: var(--muted);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(20px, 5vw, 56px);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px),
        linear-gradient(0deg, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px),
        var(--bg);
    background-size: 48px 48px;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 440px);
    width: min(100%, 1040px);
    min-height: min(640px, calc(100vh - 48px));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-showcase {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 32px;
    min-width: 0;
    padding: clamp(28px, 4vw, 48px);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 92%, var(--accent)), var(--surface)),
        var(--surface-2);
}

.auth-showcase-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-showcase-copy {
    align-self: center;
    max-width: 560px;
}

.auth-showcase h1 {
    margin: 0;
    font-size: clamp(42px, 6vw, 72px);
    line-height: 0.95;
}

.auth-showcase p {
    max-width: 430px;
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.5;
}

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

.auth-highlights div {
    display: grid;
    gap: 5px;
    min-height: 76px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.auth-highlights strong {
    color: var(--text);
}

.auth-highlights span {
    color: var(--muted);
    font-size: 13px;
}

.auth-panel {
    display: grid;
    align-content: center;
    width: 100%;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding: clamp(28px, 4vw, 46px);
    box-shadow: none;
}

.auth-panel-heading {
    margin-bottom: 18px;
}

.auth-panel-heading h2 {
    margin: 4px 0 0;
    font-size: 30px;
    line-height: 1.1;
}

.auth-form {
    display: grid;
    gap: 11px;
    margin-top: 0;
}

.auth-form.compact {
    margin-top: 0;
}

.auth-form label {
    color: var(--muted);
    font-weight: 800;
}

.auth-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--surface-2);
    color: var(--text);
}

.auth-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.15);
    outline: none;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin: 22px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    height: 1px;
    background: var(--border);
}

.microsoft-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 13px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.microsoft-button:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--surface-2) 82%, var(--accent));
}

.microsoft-mark {
    display: grid;
    grid-template-columns: repeat(2, 8px);
    grid-template-rows: repeat(2, 8px);
    gap: 2px;
}

.microsoft-mark span:nth-child(1) {
    background: #f25022;
}

.microsoft-mark span:nth-child(2) {
    background: #7fba00;
}

.microsoft-mark span:nth-child(3) {
    background: #00a4ef;
}

.microsoft-mark span:nth-child(4) {
    background: #ffb900;
}

.mobile-only {
    display: none;
}

@media (max-width: 1100px) {
    .metric-grid,
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-2 {
        grid-column: span 2;
    }
}

@media (max-width: 820px) {
    .auth-page {
        align-items: start;
        padding: 16px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .auth-showcase {
        gap: 12px;
        padding: 20px 22px;
    }

    .auth-showcase-copy {
        align-self: start;
    }

    .auth-showcase h1 {
        font-size: 32px;
    }

    .auth-showcase p {
        display: none;
    }

    .auth-highlights {
        display: none;
    }

    .auth-panel {
        border-left: 0;
        border-top: 1px solid var(--border);
        padding: 22px;
    }

    .auth-panel-heading {
        margin-bottom: 12px;
    }

    .auth-panel-heading h2 {
        font-size: 26px;
    }

    .auth-form {
        gap: 8px;
    }

    .auth-form input {
        min-height: 42px;
    }

    .auth-divider {
        margin: 16px 0;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        inset: 0 auto 0 0;
        width: min(86vw, 310px);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-only {
        display: inline-flex;
    }

    .content {
        padding: 20px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .page-heading,
    .button-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sync-action {
        justify-items: stretch;
    }

    .sync-action small {
        text-align: left;
    }

    .alert-template-list-head {
        display: none;
    }

    .alert-template-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .metric-grid,
    .dashboard-grid,
    .detail-grid,
    .client-summary-grid,
    .form-grid,
    .filter-bar,
    .dual-list,
    .extension-editor-add,
    .extension-editor-tools {
        grid-template-columns: 1fr;
    }

    .dual-list-controls {
        grid-template-columns: repeat(2, 42px);
        justify-content: center;
    }

    .span-2 {
        grid-column: auto;
    }

    .row-actions {
        justify-content: flex-start;
    }
}
