:root {
    color-scheme: light;
    --background: #f3f6fa;
    --surface: #ffffff;
    --primary: #0f4c81;
    --primary-dark: #0a355a;
    --text: #1d2733;
    --muted: #5b6875;
    --border: #d9e2ec;
    --success: #20744a;
    --warning: #8a5a00;
    --danger: #9a2c2c;
}

* {
    box-sizing: border-box;
}

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

.topbar {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar__inner,
.container {
    width: min(1080px, calc(100% - 32px));
    margin-inline: auto;
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 64px;
}

.topbar__actions,
.topnav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topnav a {
    color: var(--primary-dark);
    font-weight: 650;
    text-decoration: none;
}

.topnav a:hover {
    text-decoration: underline;
}

.brand {
    color: var(--primary-dark);
    font-size: 1.25rem;
    font-weight: 750;
    letter-spacing: .02em;
    text-decoration: none;
}

.container {
    padding-block: 64px;
}

.panel {
    max-width: 760px;
    padding: 36px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 10px 30px rgb(15 76 129 / 8%);
}

.panel--auth,
.panel--narrow {
    max-width: 520px;
    margin-inline: auto;
}

.panel--wide {
    max-width: none;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: .78rem;
    font-weight: 750;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.muted,
.logout__user {
    color: var(--muted);
}

h1 {
    margin: 0 0 16px;
    color: var(--primary-dark);
    font-size: clamp(1.8rem, 4vw, 2.7rem);
}

h2 {
    margin: 28px 0 12px;
    color: var(--primary-dark);
    font-size: 1.3rem;
}

h3 {
    margin: 28px 0 10px;
    color: var(--primary-dark);
    font-size: 1.05rem;
}

p {
    line-height: 1.65;
}

form {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

label {
    margin-top: 8px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

fieldset {
    margin: 18px 0 4px;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 10px;
    font-weight: 700;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgb(15 76 129 / 15%);
}

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

.form-grid > div {
    display: grid;
    gap: 8px;
}

.field-help,
.table-note {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.4;
}

.search-form {
    max-width: 720px;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-row button {
    flex: 0 0 auto;
    margin: 0;
}

.empty-state,
.note-card,
.record-card,
.inline-editor,
.danger-zone {
    margin-top: 24px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.empty-state {
    background: var(--background);
}

.empty-state h2,
.note-card p,
.record-card h3,
.record-card p {
    margin-top: 0;
}

.record-card__heading,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.record-card h3 {
    margin-bottom: 8px;
}

.record-note {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.record-note p {
    margin: 6px 0 0;
}

.inline-editor summary,
.danger-zone summary {
    color: var(--primary-dark);
    font-weight: 750;
    cursor: pointer;
}

.danger-zone {
    margin-top: 40px;
    border-color: #e5aaaa;
    background: #fffafa;
}

.actions--flush {
    margin-top: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

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

button {
    width: fit-content;
    min-height: 44px;
    margin-top: 16px;
    padding: 10px 20px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

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

.logout {
    display: flex;
    grid-auto-flow: column;
    align-items: center;
    gap: 14px;
    margin: 0;
}

.button--quiet {
    min-height: 38px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary-dark);
}

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

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

.button--danger:hover {
    background: #711f1f;
}

.button-link {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.button-link--secondary {
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--primary-dark);
}

.notice {
    margin-block: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.notice--success {
    border-color: #9bcbb3;
    background: #edf8f2;
    color: #145235;
}

.notice--error {
    border-color: #e5aaaa;
    background: #fff2f2;
    color: #7a1d1d;
}

.notice--warning {
    border-color: #e3c27d;
    background: #fff8e7;
    color: #684300;
}

.actions,
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.actions {
    justify-content: flex-start;
    margin-top: 28px;
}

.module-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0 32px;
}

.inline-form {
    display: block;
    margin-top: 12px;
}

.inline-form button {
    min-height: 36px;
    margin: 0;
    padding: 7px 12px;
}

.choice-list--columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.page-heading h1 {
    margin-bottom: 0;
}

.table-wrap {
    margin-top: 24px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

.badge--success {
    background: #e4f4eb;
    color: #145235;
}

.badge--muted {
    background: #edf1f5;
    color: var(--muted);
}

.badge--standard {
    background: #e4f4eb;
    color: #145235;
}

.badge--sensitive {
    background: #fff1cd;
    color: #684300;
}

.badge--critical,
.badge--danger {
    background: #ffe5e5;
    color: #7a1d1d;
}

.credential-grid {
    display: grid;
    gap: 20px;
    margin-top: 28px;
}

.credential-card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.credential-card h2 {
    margin: 16px 0;
}

.credential-card .facts {
    grid-template-columns: minmax(130px, max-content) minmax(0, 1fr);
}

.masked-secret {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    letter-spacing: .12em;
}

.break-anywhere,
.revealed-secret code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.record-description {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.reveal-control {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #e3c27d;
    border-radius: 8px;
    background: #fffdf7;
}

.reveal-control summary {
    color: var(--warning);
    font-weight: 750;
    cursor: pointer;
}

.secret-entry {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #e3c27d;
    border-radius: 8px;
    background: #fffdf7;
}

.secret-entry label {
    display: block;
    margin-top: 0;
}

.revealed-secret {
    margin: 20px 0;
    padding: 18px;
    border: 2px solid var(--warning);
    border-radius: 8px;
    background: #161d26;
    color: #fff;
}

.revealed-secret pre {
    max-height: 45vh;
    margin: 0;
    overflow: auto;
    white-space: pre-wrap;
}

.revealed-secret code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 1rem;
}

.copy-status {
    min-height: 1.5em;
    margin: 4px 0 0;
    color: var(--muted);
}

.choice-list,
.permission-list,
.card-list {
    display: grid;
    gap: 10px;
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 400;
}

.choice input {
    width: auto;
    min-height: auto;
    margin-top: 4px;
}

.choice span,
.choice small {
    display: block;
}

.choice small {
    margin-top: 3px;
    color: var(--muted);
    line-height: 1.4;
}

.choice--inline {
    align-items: center;
    width: fit-content;
    margin-top: 16px;
}

.permission-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission code {
    display: block;
    margin-top: 3px;
    color: var(--primary);
    font-size: .8rem;
}

.role-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.role-card h2,
.role-card p {
    margin: 0 0 6px;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr);
    gap: 40px;
}

.admin-sidebar {
    padding-left: 28px;
    border-left: 1px solid var(--border);
}

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 14px;
}

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

.facts dd {
    margin: 0;
}

.secret-box {
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
}

.secret-box code,
.recovery-codes code {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .08em;
}

.code-wrap {
    display: block;
    margin-top: 10px;
    overflow-wrap: anywhere;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.recovery-codes code {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    text-align: center;
}

.status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.status__item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.status__label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
}

.status__value {
    overflow-wrap: anywhere;
    color: var(--success);
    font-weight: 700;
}

@media (max-width: 640px) {
    .container {
        padding-block: 32px;
    }

    .panel {
        padding: 24px;
    }

    .status {
        grid-template-columns: 1fr;
    }

    .logout__user {
        display: none;
    }

    .topbar__inner {
        flex-wrap: wrap;
        padding-block: 10px;
    }

    .topbar__actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .topnav {
        flex-wrap: wrap;
        gap: 10px;
        font-size: .9rem;
    }

    .actions,
    .page-heading,
    .role-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .permission-list,
    .choice-list--columns,
    .admin-grid,
    .recovery-codes,
    .form-grid,
    .record-grid,
    .customer-summary {
        grid-template-columns: 1fr;
    }

    .search-row {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-sidebar {
        padding: 0;
        border: 0;
    }
}
