:root {
    color-scheme: light;
    --bg: #f7f5ff;
    --surface: #ffffff;
    --surface-muted: #f0ecff;
    --text: #1f1738;
    --muted: #675c81;
    --border: #ddd4fb;
    --primary: #450ec7;
    --primary-hover: #360aa0;
    --danger: #b42318;
    --danger-hover: #8f1c13;
    --success-bg: #e7f7ee;
    --success-text: #146c43;
    --error-bg: #fdecec;
    --error-text: #a61b16;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
}

button,
input,
textarea,
select {
    font: inherit;
}

.loading-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
    background: var(--surface);
}

.auth-visual {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 42px;
    background: #3A12A7;
    overflow: hidden;
}

.auth-visual img {
    display: block;
    width: min(92%, 900px);
    max-height: 76vh;
    object-fit: contain;
}

.auth-panel {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 32px;
    background: linear-gradient(180deg, #ffffff 0%, #f7f5ff 100%);
}

.auth-form-shell {
    width: min(420px, 100%);
}

.auth-heading {
    margin-bottom: 26px;
}

.auth-heading h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.12;
}

.auth-form {
    display: grid;
}

.auth-submit {
    width: 100%;
    min-height: 46px;
}

.auth-secondary-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

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

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: #1b0b43;
    color: #fff;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 76px;
    height: 58px;
    overflow: hidden;
}

.brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #ded5ff;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
}

.nav-link i {
    width: 18px;
    flex: 0 0 18px;
    text-align: center;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav-section {
    display: grid;
    gap: 4px;
}

.nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.nav-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.nav-toggle-icon {
    color: #b9a8ff;
    font-size: 0.7rem;
}

.nav-sublist {
    display: grid;
    gap: 4px;
}

.nav-sub-link {
    padding-left: 24px;
}

.nav-session {
    display: grid;
    gap: 8px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    color: #ded5ff;
}

.nav-session span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
}

.main {
    min-width: 0;
}

.content {
    width: min(1180px, calc(100vw - 48px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0;
    font-size: 2rem;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

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

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

.summary-item,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.summary-item {
    display: grid;
    gap: 8px;
    padding: 22px;
    text-decoration: none;
}

.summary-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--primary);
}

.summary-item:hover {
    border-color: var(--primary);
}

.summary-label {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar-wide {
    grid-template-columns: minmax(180px, 0.8fr) minmax(180px, 0.8fr) minmax(260px, 1fr) auto;
}

.lookup-toolbar {
    grid-template-columns: 160px minmax(240px, 1fr) auto;
    margin-bottom: 0;
}

.docs-grid {
    display: grid;
    gap: 18px;
}

.endpoint-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
}

.http-method {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 5px;
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.code-block {
    display: block;
    overflow-x: auto;
    padding: 14px;
    border-radius: 6px;
    background: #101827;
    color: #eef6ff;
    line-height: 1.5;
}

.docs-list {
    margin: 8px 0 0;
    padding-left: 20px;
}

.panel {
    padding: 18px;
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

.input:focus {
    outline: 3px solid rgba(69, 14, 199, 0.16);
    border-color: var(--primary);
}

.textarea {
    min-height: 96px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}

.btn i,
.auth-secondary-link i {
    flex: 0 0 auto;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-link {
    background: transparent;
    color: var(--primary);
    padding-inline: 4px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    font-weight: 600;
}

.field-hint {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 18px;
}

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

.actions-wrap {
    flex-wrap: wrap;
}

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

.billing-filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.billing-filter-panel {
    margin-bottom: 18px;
}

.readings-query-panel {
    margin-bottom: 18px;
}

.readings-filter-selects {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr) minmax(190px, 0.8fr);
    gap: 12px;
}

.readings-filter-selects-custom {
    grid-template-columns: minmax(240px, 1.3fr) minmax(190px, 1fr) minmax(170px, 0.8fr) minmax(140px, 0.65fr) minmax(140px, 0.65fr);
}

.readings-search-row {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.readings-search-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin-bottom: 14px;
    white-space: nowrap;
}

.billing-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.dashboard-period-field {
    width: min(280px, 100%);
    margin-bottom: 0;
}

.dashboard-period-select {
    min-width: 220px;
}

.dashboard-highlight-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(150px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-revenue-card,
.dashboard-metric {
    display: grid;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.dashboard-revenue-card {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.dashboard-revenue-card span,
.dashboard-metric span {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.dashboard-revenue-card span,
.dashboard-revenue-card small {
    color: #e8e0ff;
}

.dashboard-revenue-card strong {
    font-size: 2.2rem;
    line-height: 1.05;
}

.dashboard-metric strong {
    font-size: 1.8rem;
    line-height: 1.1;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.chart-panel {
    min-height: 340px;
}

.bar-list {
    display: grid;
    gap: 14px;
    max-height: 430px;
    overflow-y: auto;
    padding-right: 4px;
}

.bar-row {
    display: grid;
    gap: 6px;
}

.bar-row-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.bar-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.bar-subtitle {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.88rem;
}

.bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-muted);
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
}

.bar-fill-primary {
    background: var(--primary);
}

.bar-fill-accent {
    background: #5b21b6;
}

.bar-fill-secondary {
    background: #7c3aed;
}

.quick-links-header {
    margin: 0 0 14px;
}

.quick-links-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.table-description {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 3px;
}

.actions-col {
    width: 240px;
}

.editable-table {
    min-width: 940px;
}

.table-input {
    min-width: 110px;
    min-height: 36px;
    padding: 7px 9px;
}

.number-input {
    min-width: 96px;
}

code {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 5px;
    background: var(--surface-muted);
    color: var(--text);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9rem;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-inactive {
    background: var(--surface-muted);
    color: var(--muted);
}

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.details-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 18px;
    width: min(680px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
}

.details-list dt {
    color: var(--muted);
    font-weight: 700;
}

.details-list dd {
    margin: 0;
}

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

.lookup-results {
    display: grid;
    gap: 14px;
}

.lookup-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.lookup-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.lookup-card-header h3 {
    margin: 0 0 4px;
    font-size: 1.1rem;
}

.lookup-card-header p {
    margin: 0;
}

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

.lookup-details dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.lookup-details dd {
    margin: 4px 0 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(15, 23, 42, 0.55);
    z-index: 900;
}

.modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 44px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    padding: 20px;
}

.modal-wide {
    width: min(920px, 100%);
}

.modal-header,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header {
    margin-bottom: 18px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.secret-field {
    min-height: 110px;
    font-family: Consolas, "Courier New", monospace;
    word-break: break-all;
}

.pricing-table th:first-child,
.pricing-table td:first-child {
    min-width: 220px;
}

.pricing-table th:not(:first-child),
.pricing-table td:not(:first-child) {
    min-width: 170px;
}

.price-input {
    width: 132px;
    min-height: 38px;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 16px 16px 16px;
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #f6b7b3;
    border-radius: 6px;
    padding: 12px 16px;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
    margin-left: 16px;
}

@media (max-width: 860px) {
    .auth-page {
        grid-template-columns: 1fr;
        background: var(--surface);
    }

    .auth-visual {
        min-height: 34vh;
        padding: 24px 18px;
    }

    .auth-visual img {
        width: min(92%, 560px);
        max-height: 28vh;
    }

    .auth-panel {
        min-height: 66vh;
        padding: 28px 18px 36px;
    }

    .auth-heading h1 {
        font-size: 1.72rem;
    }

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

    .sidebar {
        padding: 16px;
    }

    .brand {
        margin-bottom: 14px;
    }

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

    .nav-link {
        justify-content: center;
        text-align: center;
    }

    .nav-section {
        grid-column: 1 / -1;
    }

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

    .nav-sub-link {
        padding-left: 12px;
    }

    .nav-toggle {
        justify-content: center;
        gap: 8px;
    }

    .nav-session {
        margin-top: 16px;
    }

    .content {
        width: min(100% - 28px, 1180px);
        padding-top: 22px;
    }

    .page-header,
    .toolbar,
    .summary-grid,
    .grid-two,
    .dashboard-highlight-grid,
    .dashboard-charts,
    .compact-grid,
    .readings-filter-selects,
    .readings-filter-selects-custom,
    .readings-search-row,
    .lookup-details {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: stretch;
    }

    .readings-search-actions {
        justify-content: flex-start;
    }
}

@media print {
    @page {
        margin: 8mm;
    }

    :root {
        --bg: #ffffff;
        --surface: #ffffff;
        --surface-muted: #f1f5f9;
        --text: #111827;
        --muted: #475569;
        --border: #cbd5e1;
        --primary: #450ec7;
    }

    html,
    body {
        min-height: auto;
        background: #ffffff;
        color: var(--text);
        font-size: 10px;
        line-height: 1.25;
    }

    .no-print,
    .sidebar,
    #blazor-error-ui {
        display: none !important;
    }

    .shell {
        display: block;
        min-height: auto;
    }

    .main,
    .content {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .page-header {
        align-items: flex-start;
        border-bottom: 2px solid var(--primary);
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .page-header h1 {
        font-size: 1.35rem;
    }

    .eyebrow {
        margin-bottom: 2px;
        font-size: 0.68rem;
    }

    .docs-grid {
        display: block;
    }

    .panel {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid var(--border);
        border-radius: 4px;
        box-shadow: none;
        margin-bottom: 6px;
        padding: 8px;
    }

    .panel-header {
        margin-bottom: 6px;
    }

    .panel-header h2,
    .panel h2 {
        font-size: 1rem;
    }

    .panel h3 {
        margin: 7px 0 3px;
        font-size: 0.84rem;
    }

    .panel p {
        margin: 4px 0 6px;
    }

    .endpoint-title {
        break-after: avoid;
        page-break-after: avoid;
        gap: 6px;
        margin-bottom: 5px;
    }

    .endpoint-title span:last-child {
        font-size: 0.96rem;
    }

    .http-method {
        min-height: 18px;
        padding: 1px 5px;
        border-radius: 3px;
        font-size: 0.64rem;
        background: var(--primary) !important;
        color: #ffffff !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .code-block {
        overflow: visible;
        white-space: pre-wrap;
        word-break: break-word;
        padding: 6px;
        border-radius: 4px;
        background: #f1f5f9 !important;
        color: #111827 !important;
        border: 1px solid var(--border);
        font-size: 0.72rem;
        line-height: 1.18;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    pre {
        margin: 4px 0 6px;
    }

    .docs-list {
        margin-top: 4px;
        padding-left: 14px;
    }

    .docs-list li {
        margin-bottom: 2px;
    }

    a {
        text-decoration: none;
    }
}
