:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #d8e0ec;
    --border-strong: #b8c4d6;
    --text: #172033;
    --muted: #64748b;
    --primary: #1769e0;
    --primary-dark: #0f56bd;
    --danger: #c9332b;
    --ok: #148653;
    --warn: #9a6700;
    --shadow: 0 18px 45px rgba(22, 34, 51, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    background: #edf2f7;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: .9em;
}

.muted { color: var(--muted); }
.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 800;
    font-size: 18px;
    color: var(--text);
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 34px 24px 70px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
    text-decoration: none;
}

.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-ghost {
    background: #fff;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-ghost:hover {
    background: #eef4ff;
    border-color: #9bb8ec;
    color: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.link {
    background: none;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.inline { display: inline; }

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    align-items: center;
    gap: 44px;
    padding: 46px 0 28px;
}

.hero h1 {
    font-size: clamp(36px, 5vw, 58px);
    line-height: 1.03;
    margin: 0 0 16px;
}

.lead {
    font-size: 18px;
    color: var(--muted);
    max-width: 650px;
    margin: 0 0 28px;
}

.cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-visual {
    background: linear-gradient(135deg, #ffffff, #eef6ff);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.diagram-node {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    font-weight: 800;
}

.node-client { color: #155f9f; }
.node-token { color: #8a5a00; }
.node-db { color: #0f7a4b; }

.diagram-line {
    width: 2px;
    height: 28px;
    background: var(--border-strong);
    margin: 0 auto;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 34px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 10px 25px rgba(22, 34, 51, .05);
}

.card h3 { margin: 0 0 8px; }

.auth {
    max-width: 400px;
    margin: 34px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth h1 { margin-top: 0; }

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 16px 0;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 650;
}

.form input,
.create-form input,
textarea {
    background: #fff;
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    width: 100%;
}

.form input:focus,
.create-form input:focus,
textarea:focus {
    outline: 3px solid rgba(23, 105, 224, .16);
    border-color: var(--primary);
}

textarea {
    font-family: "Cascadia Code", Consolas, monospace;
    resize: vertical;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.flash-error {
    background: #fff5f3;
    border-color: #f1b5ad;
    color: #8f211a;
}

.flash-success {
    background: #effaf4;
    border-color: #9ad8b6;
    color: #0d663f;
}

.dash-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.dash-head h1 { margin: 0; }

.create-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.create-form input {
    width: min(320px, 54vw);
}

.empty {
    color: var(--muted);
    padding: 44px 0;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(22, 34, 51, .05);
}

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

.table th {
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
    background: var(--surface-soft);
}

.table tr:last-child td { border-bottom: 0; }
.right { text-align: right; }

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.kv {
    width: 100%;
    border-collapse: collapse;
}

.kv td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
}

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

.kv td:first-child {
    color: var(--muted);
    width: 170px;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge-active {
    background: #e8f7ef;
    color: var(--ok);
}

.badge-suspended {
    background: #fff0ed;
    color: var(--danger);
}

.token-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.action-card h3,
.action-card p {
    margin-top: 0;
}

.browse-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    align-items: end;
    gap: 20px;
    margin-bottom: 18px;
}

.browse-head h1 {
    margin: 0 0 8px;
}

.unlock-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 10px 25px rgba(22, 34, 51, .05);
}

.unlock-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.unlock-form input {
    background: #fff;
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    width: 100%;
}

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

.summary-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(22, 34, 51, .05);
}

.summary-item span {
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}

.summary-item strong {
    display: block;
    margin-top: 6px;
    font-size: 28px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.compact-table {
    margin-top: 12px;
    box-shadow: none;
}

.compact-table th,
.compact-table td {
    vertical-align: top;
}

.mini-badge {
    display: inline-flex;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #fff7df;
    color: #8a5a00;
    font-size: 11px;
    font-weight: 800;
}

.notes-row td {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}

.password-value {
    background: #fff7df;
    color: #5f3d00;
}

.secret-state {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.secret-source {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

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

.table-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.table-pill span {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.page-back {
    margin-bottom: 16px;
}

.browser-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.browser-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    align-items: end;
    gap: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #eef6ff 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.browser-hero h1 {
    margin: 0 0 8px;
    font-size: 34px;
}

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

.metric-strip div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px 16px;
}

.metric-strip span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric-strip strong {
    display: block;
    margin-top: 4px;
    font-size: 26px;
    line-height: 1;
}

.browser-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(22, 34, 51, .05);
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-title h2 {
    margin: 0;
    font-size: 19px;
}

.section-title span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.connection-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.connection-row {
    display: grid;
    grid-template-columns: minmax(260px, 1.35fr) minmax(120px, .55fr) minmax(180px, .8fr) minmax(130px, .6fr) minmax(190px, .9fr);
    gap: 14px;
    align-items: center;
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.connection-main {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.type-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #eaf2ff;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
}

.connection-name {
    color: var(--text);
    font-weight: 850;
    overflow-wrap: anywhere;
}

.connection-host {
    margin-top: 3px;
    color: var(--muted);
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.connection-meta,
.secret-box,
.credential-item > div {
    min-width: 0;
}

.connection-meta span,
.secret-box span,
.credential-item span {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.connection-meta strong,
.secret-box strong {
    display: block;
    color: var(--text);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.secret-box code,
.credential-item code {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.secret-box small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.connection-extra {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.connection-extra span {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.connection-extra p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

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

.credential-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.credential-item strong {
    display: block;
    overflow-wrap: anywhere;
}

.warn {
    color: var(--warn);
    font-size: 13px;
}

.footer {
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    color: var(--muted);
    text-align: center;
    background: #fff;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        padding: 14px 18px;
    }

    .container {
        padding: 26px 18px 56px;
    }

    .hero {
        grid-template-columns: 1fr;
        gap: 24px;
        padding-top: 28px;
    }

    .hero h1 {
        font-size: 38px;
    }

    .create-form,
    .cta,
    .action-card {
        width: 100%;
    }

    .action-card {
        align-items: stretch;
        flex-direction: column;
    }

    .create-form input,
    .create-form .btn,
    .cta .btn,
    .action-card .btn {
        width: 100%;
    }

    .browse-head,
    .browser-hero,
    .unlock-form,
    .summary-grid,
    .metric-strip,
    .connection-row {
        grid-template-columns: 1fr;
    }

    .browser-hero {
        padding: 18px;
    }

    .browser-hero h1 {
        font-size: 30px;
    }

    .connection-row {
        align-items: stretch;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
