:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --dark: #020617;
    --blue: #2563eb;
    --blue-soft: #eff6ff;
    --green: #047857;
    --green-soft: #ecfdf5;
    --amber: #b45309;
    --amber-soft: #fffbeb;
    --red: #b91c1c;
    --red-soft: #fef2f2;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select {
    font: inherit;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
    font-size: clamp(42px, 5vw, 64px);
    line-height: .98;
    letter-spacing: -.04em;
    margin-bottom: 18px;
}

p {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

.shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px 72px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    background: var(--dark);
    color: white;
    border-radius: 16px;
    font-weight: 800;
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-title {
    font-weight: 750;
    font-size: 14px;
    line-height: 1.1;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.topbar-nav,
.topbar-actions,
.actions,
.filters,
.vault-list,
.review-head,
.panel-head,
.plan-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-nav {
    gap: 8px;
    color: #334155;
}

.topbar-nav a {
    padding: 8px 12px;
    border-radius: 12px;
}

.topbar-nav a:hover {
    background: #f1f5f9;
}

.topbar-actions form { margin: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.badge-secret {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.badge-blue {
    background: var(--blue-soft);
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.badge-success {
    background: var(--green-soft);
    border-color: #a7f3d0;
    color: var(--green);
}

.button {
    border: 0;
    border-radius: 14px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 650;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { background: var(--dark); color: white; }
.button-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.button-block { width: 100%; }

.panel,
.stat-card,
.feature-card,
.plan-card,
.review-item,
.summary-grid,
.toolbar,
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 36px;
    align-items: center;
    padding: 60px 0 40px;
}

.hero-copy { padding: 14px 0; }

.stats-grid,
.features-grid,
.pricing-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 28px;
    max-width: 560px;
}

.stat-card {
    padding: 18px;
    text-align: center;
}

.stat-card strong {
    font-size: 28px;
    display: block;
}

.stat-card span,
.muted,
.panel-subtitle,
.login-form-panel p {
    color: var(--muted);
}

.preview-panel {
    padding: 18px;
    box-shadow: var(--shadow);
}

.eyebrow {
    font-size: 14px;
    font-weight: 750;
}

.panel-subtitle {
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: white;
}

.compact-table { margin-top: 14px; }

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table-wrap th {
    background: #f1f5f9;
    text-align: left;
    font-weight: 750;
    color: #334155;
}

.table-wrap th,
.table-wrap td {
    padding: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table-wrap tr:last-child td { border-bottom: 0; }

.dark-note,
.warning-box {
    margin-top: 16px;
    background: var(--dark);
    color: #e2e8f0;
    border-radius: 18px;
    padding: 18px;
    font-size: 14px;
}

.dark-note .muted,
.warning-box {
    color: #cbd5e1;
}

.features-grid {
    grid-template-columns: repeat(3, 1fr);
    padding-bottom: 24px;
}

.feature-card,
.plan-card {
    padding: 22px;
}

.feature-icon {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    background: #f1f5f9;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
}

.feature-card h2,
.plan-card h2,
.login-form-panel h2,
.dashboard-head h1,
.page-header h1,
.hero-copy h1 {
    margin-bottom: 12px;
}

.login-wrap {
    min-height: calc(100vh - 92px);
    display: grid;
    place-items: center;
    padding: 40px 0 56px;
}

.login-card {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.login-aside {
    background: var(--dark);
    color: white;
    padding: 34px;
}

.login-aside p {
    color: #cbd5e1;
}

.secure-list {
    display: grid;
    gap: 12px;
    margin-top: 28px;
}

.secure-list div {
    background: rgba(255,255,255,.1);
    border-radius: 16px;
    padding: 14px;
}

.login-form-panel {
    padding: 34px;
}

.profile-head {
    margin: 44px 0 22px;
}

.profile-summary,
.profile-roles,
.profile-claims {
    padding: 18px;
    margin-bottom: 18px;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.profile-grid article {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
    padding: 12px;
    display: grid;
    gap: 6px;
}

.role-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.form-row { margin-bottom: 16px; }

label {
    display: block;
    font-size: 14px;
    font-weight: 650;
    margin-bottom: 7px;
}

input, select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
    background: white;
}

input:focus, select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px #dbeafe;
}

.page-header {
    max-width: 760px;
    margin-bottom: 36px;
}

.pricing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-card {
    position: relative;
}

.plan-highlighted {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px #dbeafe;
}

.plan-card strong {
    display: block;
    font-size: 36px;
    margin: 18px 0;
}

.plan-card li { margin: 10px 0; color: #334155; }

.dashboard-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: start;
    margin: 44px 0 22px;
}

.summary-grid {
    min-width: 420px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
    text-align: center;
}

.summary-grid strong { display: block; font-size: 26px; }

.mode-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.toolbar {
    padding: 16px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.vault-list {
    flex-wrap: wrap;
}

.vault-pill {
    display: flex;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
    padding: 10px 12px;
}

.resource-picker-panel {
    padding: 18px;
    margin-bottom: 18px;
}

.resource-picker-form {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.resource-picker-form select {
    min-width: 320px;
}

.access-panel {
    padding: 18px;
    margin-bottom: 18px;
}

.access-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.access-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: white;
    padding: 12px;
}

.access-ok {
    border-color: #a7f3d0;
    background: #f0fdf4;
}

.access-missing {
    border-color: #fecaca;
    background: #fff7f7;
}

.access-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.permission-warning {
    margin-top: 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}

.permission-warning p,
.permission-warning .muted {
    color: #7c2d12;
}

.missing-permission-list {
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.missing-permission-item {
    background: white;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 10px;
}

.filters input {
    min-width: 260px;
}

.table-panel,
.review-panel {
    padding: 0;
    overflow: hidden;
}

.dashboard-table table {
    min-width: 980px;
}

.dashboard-table th:first-child,
.dashboard-table td:first-child {
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
}

.dashboard-table th:first-child {
    background: #f1f5f9;
}

.cell-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.cell-value {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: #f8fafc;
}

.matrix-reveal-btn {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    position: relative;
    z-index: 5;
    pointer-events: auto;
    cursor: pointer;
}

.matrix-reveal-btn[data-loading="true"] {
    opacity: .75;
    cursor: wait;
}

.matrix-reveal-btn[data-loading="true"]::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    margin-right: 6px;
    animation: matrix-reveal-spin .7s linear infinite;
}

@keyframes matrix-reveal-spin {
    to {
        transform: rotate(360deg);
    }
}

.cell-changed {
    background: #eff6ff;
}

.status {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.status-configured {
    background: #dcfce7;
    color: #15803d;
}

.status-placeholder {
    background: #fef3c7;
    color: #b45309;
}

.status-missing {
    background: #fee2e2;
    color: #b91c1c;
}

.review-panel { margin-top: 18px; }

.review-head {
    justify-content: space-between;
    padding: 18px 18px 0;
}

.review-list {
    padding: 18px;
}

.review-item + .review-item {
    margin-top: 12px;
}

.review-item {
    padding: 14px;
}

.diff-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.diff-box {
    background: white;
    border-radius: 12px;
    padding: 10px;
    border: 1px solid var(--border);
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    word-break: break-word;
}

.savebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 16px 18px 18px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.live-api-panel {
    margin-top: 18px;
    padding: 18px;
}

.live-api-grid {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.live-api-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: #fff;
}

.live-api-card h3 {
    margin-bottom: 10px;
}

.live-form-row {
    margin-bottom: 10px;
}

.config-form textarea {
    width: 100%;
    min-height: 220px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    resize: vertical;
}

.config-form textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.2);
    border-color: #2563eb;
}

.live-inline-fields {
    display: flex;
    align-items: end;
    gap: 10px;
}

.live-inline-fields > div {
    flex: 1;
}

.live-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 600;
    color: #334155;
}

.live-check input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.live-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.secret-value {
    margin-top: 6px;
    font-size: 12px;
    word-break: break-word;
}

.access-summary-panel {
    margin-top: 18px;
    padding: 18px;
}

.access-meta-grid {
    margin: 12px 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.access-meta-grid article {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: #f8fafc;
}

.access-meta-grid strong {
    display: block;
    margin-top: 4px;
    word-break: break-word;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .55);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 60;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(560px, 100%);
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.modal-card h3 {
    margin-bottom: 8px;
}

@media (max-width: 920px) {
    .hero-grid,
    .login-card,
    .pricing-grid,
    .features-grid,
    .dashboard-head {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        min-width: 0;
        width: 100%;
    }

    .topbar-nav {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .diff-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .access-grid {
        grid-template-columns: 1fr;
    }

    .live-api-grid {
        grid-template-columns: 1fr;
    }

    .live-inline-fields {
        flex-direction: column;
        align-items: stretch;
    }

    .access-meta-grid {
        grid-template-columns: 1fr;
    }

    .resource-picker-form {
        flex-direction: column;
        align-items: stretch;
    }

    .resource-picker-form select,
    .resource-picker-form .button {
        width: 100%;
    }

    .savebar,
    .review-head,
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}
