:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #162033;
    --muted: #667085;
    --line: #d8dee9;
    --blue: #2563eb;
    --green: #149466;
    --orange: #c76a16;
    --purple: #7c3aed;
    --teal: #0f8f99;
    --pink: #c23b72;
    --red: #d43d3d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

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

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

.sidebar {
    background: #111827;
    color: #f9fafb;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #f7c948;
    color: #111827;
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: #b8c0cc;
    font-size: 13px;
    margin-top: 2px;
}

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

.nav-link {
    border-radius: 8px;
    color: #cdd5df;
    padding: 11px 12px;
    font-weight: 650;
}

.nav-link:hover,
.nav-link.active {
    background: #243045;
    color: #ffffff;
}

.main {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 22px;
}

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

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

h1 {
    font-size: 30px;
    line-height: 1.2;
    margin-bottom: 0;
}

h2 {
    font-size: 18px;
    margin-bottom: 0;
}

.timestamp {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: right;
}

.timestamp span {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.timestamp strong {
    display: block;
    font-size: 14px;
    margin-top: 2px;
}

.logout-form {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin: -2px 0 8px;
    padding-bottom: 8px;
}

.logout-form span {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.logout-form button,
.login-form button {
    background: #111827;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    font-weight: 750;
}

.logout-form button {
    padding: 7px 10px;
}

.logout-form button:hover,
.login-form button:hover {
    background: #243045;
}

.login-page {
    background: #f5f7fb;
}

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 20px 44px rgba(16, 24, 40, 0.12);
    max-width: 430px;
    padding: 28px;
    width: 100%;
}

.login-brand {
    margin-bottom: 24px;
}

.login-panel h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-copy {
    color: var(--muted);
    margin-bottom: 22px;
}

.login-alert {
    background: #eef4ff;
    border: 1px solid #bfd4ff;
    border-radius: 8px;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 650;
    margin-bottom: 16px;
    padding: 12px;
}

.login-alert.warning {
    background: #fff7e8;
    border-color: #fed7aa;
    color: #9a3412;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
}

.login-form input {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    padding: 12px;
}

.login-form input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.login-form button {
    margin-top: 8px;
    padding: 12px;
}

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

.metric {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--blue);
    border-radius: 8px;
    box-shadow: 0 12px 24px rgba(16, 24, 40, 0.06);
    display: flex;
    gap: 14px;
    padding: 18px;
}

.metric-icon {
    align-items: center;
    background: #eef4ff;
    border-radius: 8px;
    color: var(--blue);
    display: flex;
    flex: 0 0 44px;
    font-size: 20px;
    font-weight: 900;
    height: 44px;
    justify-content: center;
    width: 44px;
}

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

.metric strong {
    display: block;
    font-size: 30px;
    line-height: 1.15;
    margin-top: 8px;
}

.metric.green {
    border-left-color: var(--green);
}

.metric.green .metric-icon {
    background: #e8f6ef;
    color: var(--green);
}

.metric.orange {
    border-left-color: var(--orange);
}

.metric.orange .metric-icon {
    background: #fff3e6;
    color: var(--orange);
}

.metric.purple {
    border-left-color: var(--purple);
}

.metric.purple .metric-icon {
    background: #f1e9ff;
    color: var(--purple);
}

.metric.teal {
    border-left-color: var(--teal);
}

.metric.teal .metric-icon {
    background: #e6f7f8;
    color: var(--teal);
}

.metric.pink {
    border-left-color: var(--pink);
}

.metric.pink .metric-icon {
    background: #fdebf3;
    color: var(--pink);
}

.metric.red {
    border-left-color: var(--red);
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    min-width: 0;
    margin-bottom: 18px;
}

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

.plot-panel {
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.05);
}

.plot {
    height: 310px;
    width: 100%;
}

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

.panel-header p {
    color: var(--muted);
    font-size: 14px;
    margin: 4px 0 0;
}

.panel-header a {
    color: var(--blue);
    font-size: 14px;
    font-weight: 700;
}

.search {
    display: flex;
    gap: 8px;
}

.search input {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 240px;
    padding: 10px 12px;
}

.search button {
    background: var(--blue);
    border: 0;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: 700;
    padding: 10px 14px;
}

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

table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    max-width: 260px;
    overflow: hidden;
    padding: 11px 10px;
    text-align: left;
    text-overflow: ellipsis;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: #344054;
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fafc;
}

.empty {
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    margin: 0;
    padding: 20px;
}

.notice {
    background: #e8f6ef;
    border: 1px solid #b7e1ca;
    border-radius: 8px;
    color: #116146;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.bar-chart {
    align-items: end;
    display: flex;
    gap: 16px;
    min-height: 230px;
    overflow-x: auto;
    padding: 16px 4px 2px;
}

.bar-item {
    align-items: center;
    display: grid;
    flex: 1 0 56px;
    gap: 6px;
    justify-items: center;
    min-width: 56px;
}

.bar-track {
    align-items: end;
    background: repeating-linear-gradient(
        to top,
        #eef2f7,
        #eef2f7 1px,
        transparent 1px,
        transparent 32px
    );
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    height: 170px;
    justify-content: center;
    overflow: hidden;
    width: 34px;
}

.bar-track span {
    background: linear-gradient(180deg, #4f8cff, #2563eb);
    border-radius: 999px 999px 0 0;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.28);
    display: block;
    width: 100%;
}

.bar-item strong {
    font-size: 13px;
}

.bar-item small {
    color: var(--muted);
    font-size: 11px;
    max-width: 76px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trend-chart {
    display: grid;
    gap: 12px;
}

.trend-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 56px 1fr 42px;
}

.trend-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.trend-row strong {
    text-align: right;
}

.trend-line {
    background: #eef2f7;
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.trend-line i {
    background: linear-gradient(90deg, #149466, #22c55e);
    border-radius: 999px;
    display: block;
    height: 100%;
    min-width: 10px;
}

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

.user-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.user-card-head,
.chapter-title,
.actions-row {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.user-card-head strong,
.user-card-head span {
    display: block;
}

.user-card-head span,
.meta-line {
    color: var(--muted);
    font-size: 12px;
}

.badge {
    background: #fff3e6;
    border: 1px solid #ffd3a6;
    border-radius: 999px;
    color: #a34d00;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 6px 9px;
    white-space: nowrap;
}

.badge.ok {
    background: #e8f6ef;
    border-color: #b7e1ca;
    color: #116146;
}

.stack-form,
.editor-form,
.filter-grid {
    display: grid;
    gap: 11px;
}

.stack-form {
    margin-top: 14px;
}

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

label {
    color: #344054;
    display: grid;
    font-size: 12px;
    font-weight: 800;
    gap: 6px;
}

input,
select,
textarea {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    padding: 10px 11px;
    width: 100%;
}

textarea {
    line-height: 1.45;
    min-height: 110px;
    resize: vertical;
    white-space: pre-wrap;
}

textarea[readonly] {
    background: #f8fafc;
    color: #475467;
}

button {
    background: var(--blue);
    border: 0;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-weight: 800;
    padding: 10px 14px;
}

button.secondary {
    background: #eef2f7;
    color: #243045;
}

button.danger {
    background: var(--red);
}

.actions-row {
    margin-top: 12px;
}

.actions-row form {
    flex: 1;
}

.actions-row button {
    width: 100%;
}

.admin-table td {
    max-width: none;
}

.user-table {
    min-width: 1500px;
}

.user-table input,
.user-table select {
    min-width: 120px;
    padding: 8px 9px;
}

.table-actions {
    display: flex;
    gap: 7px;
    min-width: 245px;
}

.table-actions form {
    margin: 0;
}

.table-actions button {
    padding: 8px 10px;
    white-space: nowrap;
}

.toggle-form {
    margin: 0;
}

.toggle {
    align-items: center;
    background: #eef2f7;
    color: #344054;
    display: inline-flex;
    gap: 8px;
    min-width: 86px;
    padding: 7px 10px;
}

.toggle span {
    background: #98a2b3;
    border-radius: 999px;
    display: inline-block;
    height: 16px;
    position: relative;
    width: 30px;
}

.toggle span::after {
    background: white;
    border-radius: 50%;
    content: "";
    height: 12px;
    left: 2px;
    position: absolute;
    top: 2px;
    transition: left 0.15s ease;
    width: 12px;
}

.toggle.on {
    background: #e8f6ef;
    color: #116146;
}

.toggle.on span {
    background: var(--green);
}

.toggle.on span::after {
    left: 16px;
}

.otp-pill {
    background: #fff7d6;
    border: 1px solid #f0d36f;
    border-radius: 8px;
    color: #7a5200;
    display: inline-block;
    font-weight: 900;
    padding: 6px 9px;
}

.otp-expiry {
    color: var(--muted);
    display: block;
    font-size: 11px;
    margin-top: 4px;
}

.bpl-table {
    min-width: 1600px;
}

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

.status-pill {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 900;
    padding: 6px 9px;
    text-transform: capitalize;
}

.status-pill.pending {
    background: #fff3e6;
    color: #a34d00;
}

.status-pill.approved {
    background: #e8f6ef;
    color: #116146;
}

.status-pill.rejected {
    background: #fdecec;
    color: #b42318;
}

.reupload-pill {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 900;
    padding: 6px 9px;
}

.reupload-pill.required {
    background: #fff7d6;
    color: #8a5a00;
}

.reupload-pill.pending {
    background: #eaf2ff;
    color: #2563eb;
}

.reupload-pill.locked {
    background: #e8f6ef;
    color: #116146;
}

.reupload-pill.rejected {
    background: #fdecec;
    color: #b42318;
}

.file-link {
    background: #eef4ff;
    border: 1px solid #bfd3ff;
    border-radius: 8px;
    color: var(--blue);
    display: inline-flex;
    font-weight: 800;
    padding: 7px 9px;
}

.file-preview {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 210px;
}

.file-preview img,
.file-preview-placeholder {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 58px;
    object-fit: cover;
    width: 76px;
}

.file-preview-placeholder {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 12px;
    font-weight: 900;
    justify-content: center;
}

.file-buttons {
    display: flex;
    gap: 7px;
}

.decision-form {
    display: grid;
    gap: 8px;
    min-width: 300px;
}

.decision-form textarea {
    min-height: 58px;
}

.decision-form label {
    min-width: 300px;
}

.other-reason[hidden] {
    display: none;
}

.meta-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.filter-grid {
    align-items: end;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.chapter-list,
.prompt-list {
    display: grid;
    gap: 16px;
}

.chapter-card details,
.prompt-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 12px;
    padding: 12px;
}

summary {
    cursor: pointer;
    font-weight: 850;
}

details .editor-form {
    margin-top: 12px;
}

.prompt-card {
    background: #fbfcfe;
}

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

.details div {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

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

.details dd {
    font-size: 20px;
    font-weight: 800;
    margin: 6px 0 0;
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

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

    .metric-grid,
    .two-column,
    .plot-grid,
    .user-grid,
    .filter-grid,
    .details {
        grid-template-columns: 1fr;
    }

    .topbar,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .timestamp {
        text-align: left;
    }
}

@media (max-width: 560px) {
    .main {
        padding: 16px;
    }

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

    .search {
        flex-direction: column;
    }

    .search input {
        min-width: 0;
        width: 100%;
    }
}

.business-tabs {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
    overflow-x: auto;
    padding: 8px;
}

.business-tabs a {
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    padding: 10px 12px;
    white-space: nowrap;
}

.business-tabs a.active {
    background: #eaf2ff;
    color: #2563eb;
}

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

.business-heading h2 {
    color: var(--ink);
    font-size: 22px;
}

.business-heading p,
.business-panel-head p {
    color: var(--muted);
    margin: 4px 0 0;
}

.live-pill {
    background: #e8f6ef;
    border: 1px solid #b7e1ca;
    border-radius: 999px;
    color: #116146;
    font-size: 12px;
    font-weight: 900;
    padding: 6px 12px;
    text-transform: uppercase;
}

.business-kpis {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 28px;
}

.business-kpi {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.05);
    min-height: 156px;
    padding: 20px;
}

.business-kpi.green,
.business-kpi.teal {
    background: #ffffff;
    border-left: 5px solid var(--green);
}

.business-kpi.orange {
    background: #ffffff;
    border-left: 5px solid var(--orange);
}

.business-kpi.purple,
.business-kpi.blue {
    background: #ffffff;
    border-left: 5px solid var(--blue);
}

.business-kpi.pink,
.business-kpi.red {
    background: #ffffff;
    border-left: 5px solid var(--red);
}

.kpi-top {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.kpi-top strong {
    color: var(--green);
}

.kpi-icon {
    align-items: center;
    background: #eef4ff;
    border-radius: 50%;
    color: var(--blue);
    display: flex;
    font-weight: 900;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.business-kpi b {
    color: var(--green);
    display: block;
    font-size: 28px;
    line-height: 1;
    margin-top: 26px;
}

.business-kpi.orange b {
    color: var(--orange);
}

.business-kpi.purple b,
.business-kpi.blue b {
    color: var(--blue);
}

.business-kpi.pink b,
.business-kpi.red b {
    color: var(--red);
}

.business-kpi h3 {
    color: var(--ink);
    font-size: 13px;
    margin: 8px 0 0;
}

.business-kpi p {
    color: var(--muted);
    font-size: 12px;
    margin: 6px 0 0;
}

.business-chart-grid,
.business-table-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 24px;
}

.wide-table {
    grid-column: 1 / -1;
}

.link-button {
    background: transparent;
    color: var(--blue);
    padding: 0;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.46);
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    padding: 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
    max-height: 80vh;
    max-width: 820px;
    overflow: hidden;
    width: min(820px, 100%);
}

.modal-head {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 16px 18px;
}

.modal-head h2 {
    margin: 0;
}

.modal-close {
    background: #eef2f7;
    color: var(--ink);
}

.modal pre {
    background: #0f172a;
    color: #dbeafe;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    max-height: 62vh;
    overflow: auto;
    padding: 18px;
    white-space: pre-wrap;
}

.business-chart-grid .wide {
    grid-column: 1 / -1;
}

.business-panel {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.05);
    padding: 24px;
}

.business-panel-head {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.business-panel-head h2 {
    color: var(--ink);
    font-size: 20px;
}

.business-panel-head a {
    color: var(--blue);
    font-weight: 800;
}

.business-plot {
    height: 330px;
}

.admin-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    margin-top: 34px;
    padding: 18px 0 4px;
    text-align: center;
}

@media (max-width: 1180px) {
    .business-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .business-kpis,
    .business-chart-grid,
    .business-table-grid {
        grid-template-columns: 1fr;
    }

    .overview-page .sidebar {
        align-items: flex-start;
        flex-direction: column;
    }
}
