:root {
    --bd-ink: #172033;
    --bd-muted: #667085;
    --bd-line: #dbe3ef;
    --bd-blue: #1d4ed8;
    --bd-cyan: #0e7490;
    --bd-green: #15803d;
    --bd-orange: #c2410c;
    --bd-pink: #be185d;
    --bd-violet: #6d28d9;
    --bd-soft: #f5f7fb;
}

body {
    font-family: "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;
    color: var(--bd-ink);
}

.app-sidebar {
    background: #172033;
}

.sidebar-brand {
    height: 64px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-link {
    gap: 10px;
    min-width: 0;
}

.brand-logo {
    width: 38px;
    height: 38px;
    display: block;
    border-radius: 8px;
    background: #ffffff;
    object-fit: contain;
    padding: 3px;
}

.brand-link .brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-menu .nav-link {
    border-radius: 8px;
    margin: 2px 10px;
}

.sidebar-menu .nav-link.active {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.topbar-title strong {
    font-size: 1rem;
}

.topbar-title span {
    color: var(--bd-muted);
    font-size: 0.83rem;
}

.page-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    color: var(--bd-blue);
    font-weight: 700;
    margin: 0 0 4px;
    font-size: 0.78rem;
    letter-spacing: 0;
}

.page-toolbar h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 2rem);
    font-weight: 800;
}

.dashboard-banner {
    margin: 0;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(23, 32, 51, 0.08);
    overflow: hidden;
}

.dashboard-banner img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 1;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
}

.filter-bar label {
    display: grid;
    gap: 4px;
    min-width: 140px;
}

.filter-bar span {
    font-size: 0.76rem;
    color: var(--bd-muted);
}

.filter-bar .form-select,
.filter-bar .btn {
    min-height: 38px;
}

.insight-strip {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px;
    margin-bottom: 16px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #ffffff;
}

.insight-strip span {
    color: var(--bd-muted);
    font-size: 0.82rem;
}

.insight-strip strong {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
}

.insight-strip p {
    color: var(--bd-muted);
    margin: 2px 0 0;
}

.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.83rem;
    border: 1px solid var(--bd-line);
}

.status-pill.ready {
    background: #ecfdf3;
    color: #067647;
    border-color: #abefc6;
}

.status-pill.waiting {
    background: #f8fafc;
    color: #667085;
}

.metric-card {
    height: 126px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.05);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--tone, var(--bd-blue));
}

.metric-label {
    display: block;
    color: var(--bd-muted);
    font-size: 0.86rem;
    margin-bottom: 6px;
}

.metric-card strong {
    display: block;
    font-size: clamp(1.55rem, 2.4vw, 2.2rem);
    line-height: 1.1;
    font-weight: 850;
    word-break: break-word;
}

.metric-card small {
    display: block;
    color: var(--bd-muted);
    margin-top: 6px;
}

.metric-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--tone, var(--bd-blue));
    background: color-mix(in srgb, var(--tone, var(--bd-blue)) 12%, #fff);
    flex: 0 0 auto;
    font-size: 1.35rem;
}

.tone-blue { --tone: var(--bd-blue); }
.tone-cyan { --tone: var(--bd-cyan); }
.tone-green { --tone: var(--bd-green); }
.tone-orange { --tone: var(--bd-orange); }
.tone-pink { --tone: var(--bd-pink); }
.tone-muted { --tone: #64748b; }

.panel-card {
    height: 100%;
    padding: 16px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.04);
}

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

.panel-heading h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
}

.panel-heading h2 i {
    color: var(--bd-blue);
}

.panel-heading span {
    color: var(--bd-muted);
    font-size: 0.85rem;
}

.panel-heading-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.chart-box {
    position: relative;
    height: 320px;
    min-height: 280px;
}

.chart-box-wide {
    height: 360px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-head span,
.section-head strong {
    color: var(--bd-muted);
    font-size: 0.85rem;
}

.section-head h2 {
    margin: 2px 0 0;
    font-size: 1.12rem;
    font-weight: 850;
}

.school-table {
    min-width: 1120px;
}

.school-table th,
.school-table td {
    white-space: nowrap;
}

.school-table tfoot th,
.school-grade-table tfoot th {
    background: #eef4ff;
    color: var(--bd-ink);
    font-weight: 850;
}

.school-grade-table {
    min-width: 560px;
}

.school-name-link {
    display: grid;
    gap: 2px;
    color: var(--bd-ink);
    text-decoration: none;
}

.school-name-link span {
    font-weight: 800;
}

.school-name-link small {
    color: var(--bd-muted);
}

.school-name-link:hover span {
    color: var(--bd-blue);
}

.school-detail-hero .btn {
    white-space: nowrap;
}

.school-grade-grid,
.school-report-grid {
    display: grid;
    gap: 12px;
}

.school-grade-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.school-report-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.school-grade-card,
.school-report-card {
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.04);
}

.school-grade-card {
    padding: 14px;
}

.school-grade-card > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.school-grade-card span {
    color: var(--bd-muted);
}

.school-grade-card strong {
    font-size: 1.35rem;
    font-weight: 850;
}

.school-grade-card ul {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.school-grade-card li,
.report-mini-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.school-grade-card li strong,
.report-mini-list b {
    font-size: 0.95rem;
}

.school-report-card {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.school-report-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.school-report-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: var(--bd-blue);
    background: color-mix(in srgb, var(--bd-blue) 12%, #fff);
}

.school-report-card h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 850;
}

.school-report-card span,
.school-report-card p {
    color: var(--bd-muted);
}

.school-report-card > strong {
    font-size: 1.55rem;
    line-height: 1;
    font-weight: 850;
}

.school-report-card p {
    margin: 0;
}

.school-report-chart {
    position: relative;
    height: 240px;
    min-height: 220px;
}

.school-basic-table-wrap {
    overflow: hidden;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
}

.school-basic-table th {
    color: var(--bd-muted);
    font-size: 0.82rem;
    font-weight: 800;
    background: #f8fafc;
}

.school-basic-table td,
.school-basic-table th {
    padding: 10px 12px;
}

.report-mini-list {
    display: grid;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--bd-line);
}

.report-table {
    min-width: 760px;
}

.report-table i {
    color: var(--bd-blue);
    margin-right: 8px;
}

.source-card {
    height: 100%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border-radius: 8px;
    border: 1px solid var(--bd-line);
    background: #fff;
}

.source-card.ready {
    border-color: #abefc6;
}

.source-card.waiting {
    background: #f8fafc;
}

.source-card span,
.source-card p {
    color: var(--bd-muted);
}

.source-card h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 3px 0;
}

.source-card strong {
    white-space: nowrap;
    color: var(--bd-blue);
}

.empty-state {
    min-height: 360px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 40px 16px;
    border: 1px dashed #b9c5d8;
    border-radius: 8px;
    background: #fff;
}

.empty-state i {
    font-size: 3rem;
    color: var(--bd-blue);
}

.empty-state h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 10px 0 4px;
}

.empty-state p {
    color: var(--bd-muted);
    margin: 0;
}

.bd-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--bd-line);
    background: #fff;
    color: var(--bd-muted);
    font-size: 0.86rem;
}

.bd-footer strong {
    color: var(--bd-ink);
    font-weight: 700;
}

.bd-footer-version {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 12px;
    white-space: nowrap;
}

.admin-footer {
    margin-top: auto;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: center;
    justify-items: center;
    padding: 20px;
    background:
        linear-gradient(135deg, rgba(29, 78, 216, 0.09), rgba(21, 128, 61, 0.06)),
        #f4f7fb;
}

.login-footer {
    width: min(920px, 100%);
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.04);
}

.login-card {
    width: min(420px, 100%);
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(23, 32, 51, 0.12);
    padding: 24px;
}

.login-card h1 {
    font-size: 1.35rem;
    font-weight: 850;
    margin: 8px 0 4px;
}

.login-card p {
    color: var(--bd-muted);
}

.login-logo {
    width: 82px;
    height: 82px;
    margin-bottom: 12px;
    border: 1px solid var(--bd-line);
    box-shadow: 0 12px 28px rgba(23, 32, 51, 0.08);
}

.admin-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bd-soft);
}

.admin-header {
    background: #fff;
    border-bottom: 1px solid var(--bd-line);
}

.admin-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-title-logo {
    width: 52px;
    height: 52px;
    display: block;
    flex: 0 0 auto;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
    padding: 4px;
}

.upload-drop {
    border: 1px dashed #9fb0c7;
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.deploy-paths {
    display: grid;
    gap: 8px;
}

.deploy-paths div {
    display: grid;
    gap: 2px;
    padding: 10px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #f8fafc;
}

.deploy-paths span {
    color: var(--bd-muted);
    font-size: 0.78rem;
}

.deploy-paths strong {
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

.deploy-log {
    max-height: 420px;
    margin: 0;
    padding: 14px;
    overflow: auto;
    border: 1px solid #233047;
    border-radius: 8px;
    background: #111827;
    color: #d1fae5;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.settings-preview {
    display: grid;
    gap: 14px;
}

.settings-brand-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #f8fafc;
}

.settings-brand-preview img {
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
    padding: 4px;
}

.settings-brand-preview strong,
.settings-brand-preview span {
    display: block;
}

.settings-brand-preview strong {
    font-size: 1.05rem;
    font-weight: 850;
}

.settings-brand-preview span {
    color: var(--bd-muted);
}

.settings-banner-preview {
    margin: 0;
    border: 1px solid var(--bd-line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.settings-banner-preview img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 1;
    object-fit: cover;
}

@media (max-width: 991.98px) {
    .page-toolbar,
    .insight-strip {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-bar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .status-pills {
        justify-content: flex-start;
    }

    .bd-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .bd-footer-version {
        justify-content: flex-start;
        white-space: normal;
    }

    .chart-box {
        height: 280px;
    }
}

@media (max-width: 575.98px) {
    .topbar-title span {
        display: none;
    }

    .metric-card {
        height: auto;
        min-height: 112px;
    }
}
