:root {
    --portal-bg-start: #edf4ff;
    --portal-bg-end: #dcecff;
    --portal-primary: #0d6efd;
    --portal-primary-dark: #084bb4;
    --portal-surface: rgba(255, 255, 255, 0.84);
    --portal-border: rgba(13, 110, 253, 0.12);
    --portal-text: #10325a;
    --portal-btn-min-height: 2.4rem;
    --portal-btn-padding-y: 0.42rem;
    --portal-btn-font-size: 0.95rem;
    --portal-btn-line-height: 1.2;
}

body.portal-body {
    min-height: 100vh;
    margin: 0;
    font-family: "Noto Sans", "DejaVu Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--portal-text);
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.18), transparent 34%),
        radial-gradient(circle at bottom right, rgba(13, 202, 240, 0.18), transparent 28%),
        linear-gradient(135deg, var(--portal-bg-start), var(--portal-bg-end));
}

.portal-body .btn {
    /* Normalize button height across the portal (Bootstrap uses CSS variables for sizing). */
    --bs-btn-padding-y: var(--portal-btn-padding-y);
    --bs-btn-font-size: var(--portal-btn-font-size);
    --bs-btn-line-height: var(--portal-btn-line-height);

    min-height: var(--portal-btn-min-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.portal-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--portal-border);
}

.portal-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.portal-header-meta,
.portal-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
}

.portal-header-actions form {
    margin: 0;
}

.portal-footer {
    background: rgba(10, 37, 64, 0.88);
    color: rgba(255, 255, 255, 0.8);
}

.db-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(13, 110, 253, 0.16);
    color: var(--portal-text);
    box-shadow: 0 12px 24px rgba(13, 110, 253, 0.08);
}

.release-status-badge {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.6rem 1rem;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(13, 110, 253, 0.16);
    color: var(--portal-text);
    box-shadow: 0 12px 24px rgba(13, 110, 253, 0.08);
    line-height: 1.15;
}

.release-status-line {
    font-size: 0.86rem;
    white-space: nowrap;
}

.db-status-dot {
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    box-shadow: 0 0 0 0.28rem rgba(25, 135, 84, 0.16);
    background: #198754;
    flex: 0 0 auto;
}

.db-status-badge-disconnected .db-status-dot {
    background: #dc3545;
    box-shadow: 0 0 0 0.28rem rgba(220, 53, 69, 0.16);
}

.hero-card,
.info-panel,
.placeholder-panel {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
}

.readonly-pill {
    display: inline-flex;
    align-items: center;
    min-height: var(--portal-btn-min-height);
    padding: 0.35rem 0.95rem;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.06);
    border: 1px solid rgba(13, 110, 253, 0.14);
    font-weight: 600;
}

.menu-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.12);
    color: var(--portal-primary-dark);
    font-weight: 700;
}

.menu-logout-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 249, 255, 0.92));
}

.menu-card-actions {
    display: grid;
    gap: 0.75rem;
    width: min(100%, 16rem);
}

.menu-card-actions form {
    margin: 0;
}

.account-action-stack {
    display: inline-flex;
    flex-direction: column;
    gap: 0.55rem;
}

.settings-action-stack {
    display: inline-grid;
    grid-template-columns: minmax(max-content, 1fr);
    gap: 1rem;
    max-width: 100%;
}

.settings-action-stack .btn {
    width: 100%;
}

.settings-form-actions {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
}

.settings-sidebar {
    position: sticky;
    top: 1.5rem;
}

.company-list-item {
    border: 1px solid rgba(13, 110, 253, 0.1);
    background: rgba(255, 255, 255, 0.78);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.company-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(13, 110, 253, 0.08);
}

.company-list-item-active {
    border-color: rgba(13, 110, 253, 0.35);
    box-shadow: 0 14px 28px rgba(13, 110, 253, 0.12);
}

.import-progress {
    height: 1.2rem;
    background: rgba(13, 110, 253, 0.08);
}

.metric-card {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(13, 110, 253, 0.1);
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #4e6d93;
}

.metric-value {
    font-size: 1.55rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

.job-current-record,
.job-events-window {
    min-height: 8rem;
    max-height: 20rem;
    overflow: auto;
    background: rgba(10, 37, 64, 0.94);
    color: rgba(255, 255, 255, 0.92);
    border-radius: 1.5rem;
}

.job-current-record {
    white-space: pre-wrap;
    font-size: 0.92rem;
}

.job-event {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.92rem;
}

.job-event:last-child {
    border-bottom: 0;
}

.job-event-time {
    color: rgba(255, 255, 255, 0.58);
    flex: 0 0 auto;
}

.job-event-warning {
    color: #ffe08a;
}

.job-event-error {
    color: #ff9898;
}

.generator-summary-card {
    background:
        linear-gradient(135deg, rgba(13, 110, 253, 0.08), rgba(13, 202, 240, 0.08)),
        rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(13, 110, 253, 0.14);
}

.generator-metric-value {
    font-size: 1.35rem;
}

.generator-period-pill {
    display: inline-flex;
    align-items: center;
    min-height: var(--portal-btn-min-height);
    padding: 0.35rem 0.95rem;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.08);
    border: 1px solid rgba(13, 110, 253, 0.12);
    font-weight: 600;
    color: #36557b;
}

.generator-period-pill-active {
    background: rgba(13, 110, 253, 0.16);
    border-color: rgba(13, 110, 253, 0.28);
    color: #0d4fb1;
    box-shadow: 0 10px 24px rgba(13, 110, 253, 0.08);
}

.generator-console {
    min-height: 18rem;
    max-height: 30rem;
    overflow: auto;
    background:
        radial-gradient(circle at top right, rgba(32, 201, 151, 0.16), transparent 28%),
        linear-gradient(180deg, rgba(7, 22, 39, 0.97), rgba(13, 33, 56, 0.97));
    color: rgba(231, 243, 255, 0.96);
    border: 1px solid rgba(32, 201, 151, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.generator-console-empty {
    border-color: rgba(13, 110, 253, 0.14);
}

.generator-console-line {
    padding: 0.35rem 0.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    white-space: pre-wrap;
    word-break: break-word;
}

.generator-console-line:last-child {
    border-bottom: 0;
}

.generator-console-line-warning {
    color: #ffe08a;
}

.generator-console-line-error {
    color: #ff9898;
}

.dashboard-filter-card {
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.12), transparent 36%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 249, 255, 0.94));
}

.dashboard-chart-card {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(13, 110, 253, 0.12);
    box-shadow: 0 18px 30px rgba(13, 110, 253, 0.08);
}

.dashboard-chart-surface {
    position: relative;
    min-height: 22rem;
    padding: 1rem;
    border-radius: 1.75rem;
    background:
        linear-gradient(180deg, rgba(247, 251, 255, 0.96), rgba(238, 246, 255, 0.96)),
        rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(13, 110, 253, 0.08);
}

.dashboard-chart-surface canvas {
    width: 100% !important;
    height: 100% !important;
}

.placeholder-box {
    min-height: 5rem;
    border: 1px dashed rgba(13, 110, 253, 0.28);
    border-radius: 1.5rem;
    background: rgba(13, 110, 253, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    color: #5a6e88;
    font-weight: 500;
}

.scanner-shell {
    max-width: 42rem;
    margin: 0 auto;
}

.scanner-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
}

.scanner-company-picker {
    width: min(100%, 18rem);
}

.scanner-camera-panel {
    position: relative;
    overflow: hidden;
    min-height: 18rem;
    border-radius: 1.5rem;
    background: rgba(10, 37, 64, 0.94);
    border: 1px solid rgba(13, 110, 253, 0.16);
}

.scanner-video {
    display: block;
    width: 100%;
    min-height: 18rem;
    max-height: 62vh;
    object-fit: cover;
}

.scanner-camera-state {
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--portal-text);
    font-weight: 600;
    text-align: center;
}

.scanner-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.scanner-manual,
.scanner-reading-form,
.scanner-result {
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(13, 110, 253, 0.12);
}

.scanner-result-success {
    color: #0f5132;
    background: rgba(209, 231, 221, 0.9);
    border-color: rgba(25, 135, 84, 0.25);
}

.scanner-result-warning {
    color: #664d03;
    background: rgba(255, 243, 205, 0.92);
    border-color: rgba(255, 193, 7, 0.28);
}

.scanner-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.scanner-choice-card {
    min-height: 5.25rem;
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 1rem;
    background: #fff;
    color: var(--portal-text);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    justify-content: center;
    padding: 0.9rem 1rem;
    width: 100%;
}

.scanner-choice-card:hover,
.scanner-choice-card:focus,
.scanner-choice-card.is-selected {
    border-color: rgba(13, 110, 253, 0.55);
    box-shadow: 0 10px 22px rgba(13, 110, 253, 0.12);
}

.scanner-choice-title {
    font-weight: 700;
    line-height: 1.25;
}

.scanner-choice-meta {
    color: #5a6e88;
    font-size: 0.9rem;
    line-height: 1.3;
}

.scanner-mode-note {
    color: #5a6e88;
    font-size: 0.86rem;
    font-weight: 600;
}

.scanner-machine-section {
    border: 1px solid rgba(13, 110, 253, 0.16);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.78);
    padding: 1rem;
}

.scanner-machine-section-title {
    color: var(--portal-text);
    font-weight: 700;
}

.scanner-machine-section-meta {
    color: #5a6e88;
    font-size: 0.9rem;
    line-height: 1.3;
}

.card,
.btn,
.form-control,
.table {
    border-color: var(--portal-border);
}

.btn-primary {
    background: linear-gradient(135deg, var(--portal-primary), #3291ff);
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(13, 110, 253, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--portal-primary-dark), var(--portal-primary));
}

.btn-outline-primary {
    border-width: 2px;
}

.btn-pill-compact {
    /* Compact only in width, keep consistent height. */
    --bs-btn-padding-x: 0.9rem;
}

.btn-pill-xs {
    /* XS only in width, keep consistent height. */
    --bs-btn-padding-x: 0.7rem;
}

.table > :not(caption) > * > * {
    background: transparent;
}

@media (max-width: 767.98px) {
    .menu-card-actions {
        width: 100%;
    }

    .portal-header-right {
        align-items: stretch;
    }

    .portal-header-meta,
    .portal-header-actions {
        justify-content: flex-start;
    }

    .portal-header .btn,
    .portal-header form {
        width: 100%;
    }

    .settings-sidebar {
        position: static;
    }

    .scanner-topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .scanner-company-picker {
        width: 100%;
    }

    .scanner-choice-grid {
        grid-template-columns: 1fr;
    }
}
