:root {
    color-scheme: light;
    --crm-ink: #111827;
    --crm-paper: #f6f7fb;
    --crm-line: #d7dce5;
    --crm-sky: #0369a1;
    --crm-primary: #174ea6;
    --crm-navy: #0b2d5b;
    --crm-muted: #64748b;
    --crm-danger: #b91c1c;
}

* {
    box-sizing: border-box;
    border-radius: 0 !important;
}

html,
body {
    min-width: 360px;
    min-height: 100%;
    margin: 0;
    background: var(--crm-paper);
    color: var(--crm-ink);
    font-family: "Segoe UI", Arial, sans-serif;
}

button,
a,
label,
summary {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button,
a,
label[for] {
    cursor: pointer;
}

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

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

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(3, 105, 161, .07), transparent 42%),
        var(--crm-paper);
}

.auth-card {
    display: grid;
    width: min(100%, 880px);
    min-height: 440px;
    grid-template-columns: minmax(220px, .72fr) minmax(0, 1.45fr);
    border: 1px solid #dbe2ea;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: #071b35;
    padding: 36px;
    color: #fff;
}

.auth-brand span {
    color: #7dd3fc;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.auth-brand strong {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 900;
}

.auth-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(32px, 6vw, 64px);
}

.auth-content h1 {
    margin: 10px 0 0;
    color: #020617;
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 900;
    line-height: 1.08;
}

.auth-description {
    margin: 18px 0 0;
    color: #475569;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.65;
}

.auth-detail {
    margin-top: 22px;
    border-left: 4px solid var(--crm-sky);
    background: #f1f5f9;
    padding: 14px 16px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.55;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.auth-primary,
.auth-secondary {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 17px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.auth-primary {
    border: 1px solid #020617;
    background: #020617;
    color: #fff;
}

.auth-primary:hover {
    background: #172033;
}

.auth-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
}

.auth-secondary:hover {
    background: #f1f5f9;
}

.admin-shell,
.shell-body {
    min-height: 100vh;
}

.shell-body {
    display: flex;
}

.mobile-nav-toggle {
    position: fixed;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    width: 288px;
    height: 100vh;
    flex: 0 0 288px;
    border-right: 1px solid #e2e8f0;
    background: #fff;
}

.sidebar-inner {
    display: flex;
    height: 100%;
    flex-direction: column;
    gap: 32px;
    padding: 20px;
}

.brand-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.brand-eyebrow,
.eyebrow {
    color: var(--crm-sky);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.brand-title {
    margin-top: 8px;
    color: #020617;
    font-size: 25px;
    font-weight: 900;
}

.admin-navigation {
    display: grid;
    gap: 8px;
}

.admin-navigation a {
    padding: 10px 12px;
    color: #334155;
    font-size: 14px;
    font-weight: 800;
}

.admin-navigation a:hover {
    background: #f1f5f9;
}

.admin-navigation a.active {
    background: #020617;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

.signed-user {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.signed-user span {
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.signed-user strong {
    color: #334155;
    font-size: 13px;
}

.logout-button,
.button-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-weight: 800;
}

.logout-button {
    width: 100%;
    padding: 10px 12px;
    text-align: left;
}

.logout-button:hover,
.button-secondary:hover {
    background: #f1f5f9;
}

.admin-main {
    min-width: 0;
    flex: 1;
}

.admin-content {
    width: min(100%, 1440px);
    margin: 0 auto;
    padding: 24px 32px;
}

.mobile-header,
.mobile-close,
.mobile-nav-backdrop {
    display: none;
}

.admin-page {
    display: grid;
    gap: 20px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 16px;
}

.page-heading h1 {
    margin: 8px 0 0;
    color: #020617;
    font-size: clamp(28px, 3vw, 36px);
    font-weight: 900;
    line-height: 1.08;
}

.page-description {
    max-width: 820px;
    margin: 9px 0 0;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.55;
}

.button-secondary {
    flex: 0 0 auto;
    padding: 10px 16px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.alert-error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    padding: 13px 15px;
    color: var(--crm-danger);
    font-size: 14px;
    font-weight: 700;
}

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

.summary-card {
    display: grid;
    gap: 8px;
    min-width: 0;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 18px;
}

.summary-card span {
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.summary-card strong {
    overflow-wrap: anywhere;
    color: #020617;
    font-size: 26px;
    font-weight: 900;
}

.summary-card small {
    overflow-wrap: anywhere;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.panel {
    min-width: 0;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.panel-heading {
    display: flex;
    min-height: 70px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 16px;
}

.panel-heading h2 {
    margin: 0;
    color: #020617;
    font-size: 18px;
    font-weight: 900;
}

.panel-heading p {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.count-badge {
    flex: 0 0 auto;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 5px 8px;
    color: #334155;
    font-size: 12px;
    font-weight: 900;
}

.storage-overview {
    overflow: hidden;
}

.storage-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    background: #f1f5f9;
    padding: 14px;
}

.storage-card {
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 16px;
}

.storage-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.storage-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 900;
}

.storage-card p {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.storage-card-heading strong {
    color: var(--crm-navy);
    font-size: 17px;
    white-space: nowrap;
}

.storage-card dl,
.compact-metrics,
.entry-summary {
    display: grid;
    margin: 12px 0 0;
}

.storage-card dl {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.storage-card dl div,
.compact-metrics div,
.entry-summary div {
    display: grid;
    gap: 3px;
}

.storage-card dt,
.compact-metrics dt,
.entry-summary dt {
    color: #94a3b8;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.storage-card dd,
.compact-metrics dd,
.entry-summary dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
}

.index-workspace {
    display: grid;
    min-height: 620px;
    height: calc(100vh - 150px);
    grid-template-columns: minmax(290px, 390px) minmax(0, 1fr);
    gap: 16px;
}

.index-catalog,
.index-content {
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.virtual-scroll {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    background: #f1f5f9;
    padding: 12px;
}

.index-card {
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.index-card:hover {
    background: #f8fafc;
}

.index-card.selected {
    border-color: #020617;
    background: #f8fafc;
}

.index-select {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 14px;
    text-align: left;
}

.index-card-top,
.entry-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.min-width-zero {
    min-width: 0;
}

.index-title {
    overflow-wrap: anywhere;
    color: #020617;
    font-size: 14px;
    font-weight: 900;
}

.index-subtitle {
    margin-top: 4px;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
}

.compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    border-top: 1px solid #f1f5f9;
    padding-top: 10px;
}

.index-path {
    margin-top: 9px;
    overflow-wrap: anywhere;
    color: #64748b;
    font-family: Consolas, monospace;
    font-size: 10px;
}

.entry-card {
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 16px;
}

.entry-header {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.entry-header h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: #020617;
    font-size: 17px;
    font-weight: 900;
}

.entry-header p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.entry-header time {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
}

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

.hash-row {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 10px;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 8px 10px;
}

.hash-row span {
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
}

.hash-row code {
    min-width: 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 11px;
}

.entry-details {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    margin: 12px 0 0;
}

.entry-details dt,
.entry-details dd {
    border: 1px solid #e2e8f0;
    border-bottom: 0;
    padding: 7px 9px;
}

.entry-details dt:last-of-type,
.entry-details dd:last-of-type {
    border-bottom: 1px solid #e2e8f0;
}

.entry-details dt {
    background: #f8fafc;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.entry-details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.loading-card,
.empty-card {
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 18px;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

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

    .index-workspace {
        height: auto;
        grid-template-columns: 1fr;
    }

    .index-catalog,
    .index-content {
        min-height: 520px;
    }
}

@media (max-width: 900px) {
    .admin-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        max-width: calc(100vw - 48px);
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: 0 24px 48px rgba(15, 23, 42, .2);
    }

    .mobile-nav-toggle:checked ~ .shell-body .admin-sidebar {
        transform: translateX(0);
    }

    .mobile-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: block;
        background: rgba(15, 23, 42, .42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
    }

    .mobile-nav-toggle:checked ~ .shell-body .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-close {
        display: inline-flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border: 1px solid #cbd5e1;
        color: #334155;
        font-size: 22px;
        font-weight: 900;
    }

    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        height: 58px;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #e2e8f0;
        background: rgba(255, 255, 255, .96);
        padding: 8px 16px;
    }

    .mobile-header div {
        display: grid;
        gap: 2px;
    }

    .mobile-header strong {
        font-size: 13px;
        font-weight: 900;
    }

    .mobile-header span {
        color: #64748b;
        font-size: 11px;
        font-weight: 700;
    }

    .mobile-menu-button {
        display: inline-flex;
        height: 40px;
        align-items: center;
        border: 1px solid #cbd5e1;
        background: #fff;
        padding: 0 12px;
        color: #334155;
        font-size: 11px;
        font-weight: 900;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .admin-content {
        padding: 20px 16px;
    }
}

@media (max-width: 680px) {
    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        min-height: 150px;
        padding: 24px;
    }

    .auth-content {
        padding: 30px 24px;
    }

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

    .button-secondary {
        align-self: flex-start;
    }

    .summary-grid,
    .storage-grid {
        grid-template-columns: 1fr;
    }

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

    .entry-header {
        flex-direction: column;
    }

    .entry-details {
        grid-template-columns: 1fr;
    }

    .entry-details dt,
    .entry-details dd {
        border-bottom: 0;
    }

    .entry-details dd:last-of-type {
        border-bottom: 1px solid #e2e8f0;
    }
}
