:root {
    color-scheme: light;
    --brand: #f57c00;
    --brand-dark: #df6e00;
    --nav: #10212a;
    --nav-text: #d4dade;
    --nav-muted: #8c969c;
    --page: #f0f1f3;
    --surface: #fff;
    --surface-muted: #f6f6f7;
    --border: #d2d5d8;
    --text: #30373b;
    --muted: #687177;
    --success: #397347;
    --success-soft: #e8f3e6;
    --warning-soft: #fff3d1;
    --danger: #b63832;
    --focus: #126fc2;
    --radius: 8px;
    --shadow: 0 2px 10px rgb(16 33 42 / 6%);
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
    margin: 0;
}

body {
    background: var(--page);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: inherit;
}

button, input {
    font: inherit;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

h1:focus-visible {
    outline: none;
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    align-items: center;
    background: var(--brand);
    color: #fff;
    display: flex;
    height: 54px;
    justify-content: space-between;
    padding: 0 24px;
}

.brand {
    align-items: center;
    color: inherit;
    display: inline-flex;
    font-size: 17px;
    font-weight: 700;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: rgb(255 255 255 / 20%);
    border: 1px solid rgb(255 255 255 / 58%);
    border-radius: 7px;
    display: inline-flex;
    font-size: 15px;
    height: 30px;
    justify-content: center;
    width: 30px;
}

.header-meta {
    align-items: center;
    display: flex;
    font-size: 13px;
    gap: 20px;
    opacity: .96;
}

.header-signout {
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-decoration-color: rgb(255 255 255 / 55%);
    text-underline-offset: 3px;
}

.header-signout:hover { color: #ead3b3; }

.local-badge {
    align-items: center;
    background: rgb(255 255 255 / 16%);
    border: 1px solid rgb(255 255 255 / 28%);
    border-radius: 99px;
    display: inline-flex;
    gap: 7px;
    padding: 4px 10px;
}

.status-dot, .nav-footer-dot {
    background: #b6ecc2;
    border-radius: 50%;
    display: inline-block;
    height: 8px;
    width: 8px;
}

.app-body {
    display: flex;
    min-height: calc(100vh - 54px);
}

.sidebar {
    background: var(--nav);
    color: var(--nav-text);
    flex: 0 0 260px;
    min-height: calc(100vh - 54px);
    position: sticky;
    top: 0;
}

.navigation {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 54px);
    padding: 26px 14px 18px;
}

.nav-section-title {
    border-top: 1px solid rgb(255 255 255 / 12%);
    color: var(--nav-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    margin: 18px 8px 9px;
    padding-top: 18px;
}

.nav-section-title:first-child {
    border: 0;
    margin-top: 0;
    padding-top: 0;
}

.navigation .nav {
    gap: 3px;
}

.navigation .nav-link {
    align-items: center;
    border-left: 3px solid transparent;
    border-radius: 4px;
    color: var(--nav-text);
    display: flex;
    font-size: 14px;
    gap: 12px;
    min-height: 42px;
    padding: 8px 10px;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.navigation .nav-link:hover {
    background: rgb(255 255 255 / 8%);
    color: #fff;
}

.navigation .nav-link.active {
    background: rgb(245 124 0 / 18%);
    border-left-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

.nav-icon {
    align-items: center;
    color: #abb6bb;
    display: inline-flex;
    font-size: 17px;
    height: 20px;
    justify-content: center;
    width: 20px;
}

.nav-link.active .nav-icon {
    color: #ffb463;
}

.nav-footer {
    align-items: center;
    border-top: 1px solid rgb(255 255 255 / 12%);
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding: 18px 8px 0;
}

.nav-footer strong, .nav-footer small {
    display: block;
}

.nav-footer strong {
    color: #e8edef;
    font-size: 12px;
}

.nav-footer small {
    color: var(--nav-muted);
    font-size: 11px;
    margin-top: 2px;
}

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

.main-topbar {
    align-items: center;
    background: rgb(255 255 255 / 72%);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    font-size: 12px;
    height: 48px;
    justify-content: space-between;
    padding: 0 30px;
}

.main-topbar-right {
    color: #8a9297;
}

.content {
    margin: 0 auto;
    max-width: 1600px;
    padding: 30px;
}

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

.eyebrow {
    color: #7d878c;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    margin: 0 0 6px;
}

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

h1, h2, p {
    margin-top: 0;
}

h1 {
    font-size: clamp(25px, 3vw, 32px);
    font-weight: 650;
    letter-spacing: -.025em;
    line-height: 1.2;
    margin: 0;
}

h2 {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -.01em;
    line-height: 1.3;
    margin: 0;
}

.heading-subtitle {
    color: var(--muted);
    font-size: 14px;
    margin: 8px 0 0;
}

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 600;
    gap: 8px;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.button-primary {
    background: var(--brand);
    color: #fff;
}

.button-primary:hover {
    background: var(--brand-dark);
    color: #fff;
}

.button-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.button-secondary:hover:not(:disabled) {
    background: var(--surface-muted);
    border-color: #afb5b9;
}

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

.button-small {
    background: var(--nav);
    color: #fff;
    min-height: 34px;
    padding: 6px 12px;
}

.button-small:hover {
    background: #203b49;
}

.readonly-badge {
    background: #edf4ee;
    border: 1px solid #d3e6d6;
    border-radius: 99px;
    color: #356542;
    font-size: 12px;
    font-weight: 650;
    padding: 6px 11px;
}

.panel, .metric-card {
    background: var(--surface);
    border: 1px solid #e0e2e4;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
}

.metrics-grid {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.metric-card {
    min-height: 130px;
    padding: 19px 20px;
}

.metric-card-accent {
    border-top: 3px solid var(--brand);
    padding-top: 17px;
}

.metric-label, .metric-foot {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.metric-value {
    display: block;
    font-size: 29px;
    font-weight: 650;
    letter-spacing: -.03em;
    line-height: 1.2;
    margin: 8px 0 5px;
}

.metric-foot {
    color: #8a9297;
    font-size: 11px;
}

.dashboard-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, .85fr);
}

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

.panel-heading .eyebrow {
    margin-bottom: 5px;
}

.text-link {
    color: #a75200;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

.shortcut-list {
    border-top: 1px solid #ebedef;
}

.shortcut-row {
    align-items: center;
    border-bottom: 1px solid #ebedef;
    display: flex;
    gap: 13px;
    min-height: 67px;
    padding: 10px 3px;
    text-decoration: none;
}

.shortcut-row:last-child {
    border-bottom: 0;
}

.shortcut-row:hover strong {
    color: #a75200;
}

.shortcut-icon, .table-card-icon {
    align-items: center;
    background: #fff4e9;
    border-radius: 7px;
    color: #bd6200;
    display: inline-flex;
    flex: 0 0 36px;
    font-size: 17px;
    height: 36px;
    justify-content: center;
}

.shortcut-row strong, .shortcut-row small {
    display: block;
}

.shortcut-row strong {
    font-size: 13px;
}

.shortcut-row small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.shortcut-arrow {
    color: #9aa1a5;
    margin-left: auto;
}

.info-panel {
    background: #fffdfa;
}

.info-panel h2 {
    max-width: 260px;
}

.info-panel > p:not(.eyebrow) {
    color: var(--muted);
    font-size: 13px;
    margin: 12px 0 0;
}

.info-separator {
    border-top: 1px solid #ece8e2;
    margin: 20px 0;
}

.file-meta {
    align-items: flex-start;
    display: flex;
    gap: 10px;
}

.file-meta .status-dot {
    background: var(--success);
    margin-top: 5px;
}

.file-meta strong, .file-meta small {
    display: block;
}

.file-meta strong {
    font-size: 13px;
}

.file-meta small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.setup-panel {
    align-items: flex-start;
    display: flex;
    gap: 16px;
}

.setup-panel p, .empty-state p {
    color: var(--muted);
    margin: 7px 0 12px;
}

.panel-icon {
    align-items: center;
    background: var(--warning-soft);
    border-radius: 50%;
    color: #8b6405;
    display: flex;
    flex: 0 0 34px;
    font-weight: 700;
    height: 34px;
    justify-content: center;
}

pre {
    background: #f4f5f6;
    border: 1px solid #e4e6e8;
    border-radius: 5px;
    color: #31383c;
    font-size: 13px;
    margin: 10px 0 0;
    overflow-x: auto;
    padding: 10px 12px;
}

.loading-state, .empty-inline {
    color: var(--muted);
    padding: 30px;
    text-align: center;
}

.database-panel, .table-panel {
    padding: 0;
}

.database-toolbar {
    align-items: center;
    border-bottom: 1px solid #e8eaec;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 68px;
    padding: 14px 20px;
}

.database-toolbar > div {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.database-toolbar strong {
    font-size: 13px;
}

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

.table-search {
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: #92999d;
    display: flex;
    gap: 8px;
    max-width: 360px;
    min-width: 240px;
    padding: 4px 6px 4px 10px;
}

.table-search:focus-within {
    border-color: var(--focus);
    box-shadow: 0 0 0 2px rgb(18 111 194 / 12%);
}

.table-search input {
    background: transparent;
    border: 0;
    color: var(--text);
    min-width: 0;
    outline: 0;
    padding: 5px 0;
    width: 100%;
}

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

.table-card {
    align-items: center;
    border: 1px solid #e5e7e9;
    border-radius: 7px;
    display: flex;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    text-decoration: none;
    transition: border-color .15s ease, background-color .15s ease;
}

.table-card:hover {
    background: #fffaf5;
    border-color: #efbf91;
}

.table-card-content {
    min-width: 0;
}

.table-card-content strong, .table-card-content small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-card-content strong {
    font-size: 12px;
}

.table-card-content small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.table-title {
    overflow-wrap: anywhere;
}

.table-panel {
    overflow: hidden;
}

.schema-panel {
    border-bottom: 1px solid #e8eaec;
    padding: 12px 20px;
}

.schema-panel summary {
    color: #485258;
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
}

.schema-panel summary span {
    color: var(--muted);
    font-weight: 400;
    margin-left: 5px;
}

.schema-list {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    padding: 14px 0 3px;
}

.schema-column {
    align-items: center;
    background: var(--surface-muted);
    border-radius: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px 9px;
    padding: 8px 10px;
}

.schema-column strong {
    font-size: 11px;
}

.schema-column span, .schema-column small, .schema-column em {
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
}

.schema-column em {
    color: #a75200;
}

.data-table-wrap {
    max-height: calc(100vh - 390px);
    min-height: 260px;
    overflow: auto;
    width: 100%;
}

.data-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    min-width: 100%;
    white-space: nowrap;
}

.data-table th, .data-table td {
    border-bottom: 1px solid #e8eaec;
    max-width: 320px;
    overflow: hidden;
    padding: 9px 11px;
    text-align: left;
    text-overflow: ellipsis;
    vertical-align: top;
}

.data-table th {
    background: #f7f8f9;
    color: #596268;
    font-size: 10px;
    font-weight: 700;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:hover {
    background: #fffaf5;
}

.details-column {
    background: inherit;
    left: 0;
    position: sticky;
    z-index: 2;
}

.data-table th.details-column {
    z-index: 3;
}

.text-button {
    background: none;
    border: 0;
    color: #9b4d00;
    cursor: pointer;
    font-size: 11px;
    font-weight: 650;
    padding: 0;
}

.text-button:hover {
    text-decoration: underline;
}

.binary-cell {
    color: #737d82;
    font-style: italic;
}

.pagination {
    align-items: center;
    border-top: 1px solid #e8eaec;
    color: var(--muted);
    display: flex;
    font-size: 12px;
    gap: 14px;
    justify-content: center;
    padding: 14px;
}

.pagination .button {
    min-height: 32px;
}

.record-panel {
    margin-top: 18px;
}

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

.record-field {
    border-top: 1px solid #eceef0;
    min-width: 0;
    padding: 10px 0;
}

.record-field dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}

.record-field dd {
    font-size: 12px;
    margin: 4px 0 0;
    max-height: 220px;
    overflow: auto;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.error-panel {
    border-color: #f0c7c3;
    color: var(--danger);
}

.error-panel p {
    color: var(--muted);
    margin: 7px 0 0;
}

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

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

@media (max-width: 760px) {
    .app-header {
        padding: 0 14px;
    }

    .header-meta > span:nth-child(2), .main-topbar-right {
        display: none;
    }

    .app-body {
        display: block;
    }

    .sidebar {
        min-height: auto;
        position: static;
        width: 100%;
    }

    .navigation {
        min-height: auto;
        padding: 8px 10px;
    }

    .nav-section-title, .nav-footer {
        display: none;
    }

    .navigation .nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .navigation .nav-link {
        border-bottom: 2px solid transparent;
        border-left: 0;
        flex: 0 0 auto;
        min-height: 40px;
        padding: 7px 10px;
    }

    .navigation .nav-link.active {
        border-bottom-color: var(--brand);
        border-left-color: transparent;
    }

    .main-topbar {
        height: 38px;
        padding: 0 16px;
    }

    .content {
        padding: 22px 14px;
    }

    .page-heading {
        align-items: flex-start;
    }

    .table-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .database-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-search {
        max-width: none;
        min-width: 0;
        width: 100%;
    }

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

    .data-table-wrap {
        max-height: calc(100vh - 430px);
    }
}

@media (max-width: 520px) {
    .metrics-grid {
        gap: 9px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card {
        min-height: 110px;
        padding: 14px;
    }

    .metric-value {
        font-size: 24px;
    }

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

    .page-heading > .button, .page-heading > .readonly-badge {
        align-self: flex-start;
    }

    .panel {
        padding: 16px;
    }

    .database-panel, .table-panel {
        padding: 0;
    }

    .pagination {
        gap: 8px;
    }

    .pagination .button {
        padding-inline: 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
