:root {
    --navy: #0b1f3a;
    --navy-soft: #132f55;
    --blue: #2563eb;
    --surface: #ffffff;
    --page: #f3f6fb;
    --line: #dce4ef;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --shadow: 0 18px 45px rgba(11, 31, 58, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: #172033;
    font-family: Arial, Helvetica, sans-serif;
}

a {
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 34%),
        linear-gradient(135deg, #081a31 0%, #0d2748 48%, #f3f6fb 48%, #f3f6fb 100%);
}

.login-card {
    width: min(100%, 430px);
    padding: 34px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.company-select-panel {
    width: min(100%, 980px);
    padding: 34px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

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

.company-select-card {
    display: grid;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.company-select-card h2 {
    margin: 0 0 6px;
    color: var(--navy);
    font-size: 1.08rem;
    font-weight: 800;
}

.company-select-card p {
    margin: 0;
    color: var(--muted);
}

.company-select-logo {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    font-weight: 800;
}

.company-select-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    border-radius: inherit;
    background: #fff;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, var(--navy), var(--blue));
}

.login-brand span,
.sidebar-brand span,
.metric-label,
.branch-meta,
.table-muted {
    color: var(--muted);
}

.portal-layout {
    min-height: 100vh;
    display: flex;
}

.portal-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 278px;
    padding: 24px;
    color: #fff;
    background: linear-gradient(180deg, var(--navy), #07182d);
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    gap: 13px;
    align-items: center;
    margin-bottom: 34px;
}

.sidebar-brand span,
.sidebar-footer span {
    display: block;
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.85rem;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    color: rgba(255, 255, 255, 0.78);
    border-radius: 12px;
}

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

.nav-icon {
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-switch {
    display: inline-flex;
    margin-top: 10px;
    color: #fff;
    font-size: 0.86rem;
    font-weight: 700;
}

.portal-main {
    width: 100%;
    margin-left: 278px;
    padding: 26px;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 26px rgba(11, 31, 58, 0.08);
}

.mobile-menu {
    display: none;
}

.page-kicker {
    color: var(--blue);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.page-title {
    margin: 4px 0 0;
    color: var(--navy);
    font-weight: 800;
}

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

.dashboard-summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.payment-summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-card,
.content-card,
.branch-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 34px rgba(11, 31, 58, 0.06);
}

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


.metric-card .metric-label {
    font-size: 0.92rem;
    line-height: 1.25;
}

.metric-card strong {
    display: block;
    color: var(--navy);
    font-size: clamp(1.35rem, 2.15vw, 1.75rem);
    line-height: 1.08;
    margin-top: 10px;
}

.metric-change {
    display: inline-flex;
    margin-top: 12px;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--success);
    background: rgba(22, 163, 74, 0.11);
    font-size: 0.78rem;
    font-weight: 700;
}

.highlight-card strong {
    font-size: clamp(1rem, 1.6vw, 1.2rem);
}

.filter-chips {
    display: flex;
    gap: 10px;
    margin: 0 0 22px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 14px;
    color: var(--navy);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.filter-chip.active,
.filter-chip:hover {
    color: #fff;
    background: var(--navy);
    border-color: var(--navy);
}

.content-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 18px;
}

.content-card {
    padding: 22px;
}

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

.card-heading h2 {
    margin: 0;
    color: var(--navy);
    font-size: 1.1rem;
    font-weight: 800;
}

.chart-bars {
    display: grid;
    gap: 15px;
}

.chart-row {
    display: grid;
    grid-template-columns: 92px 1fr 92px;
    gap: 12px;
    align-items: center;
    font-size: 0.92rem;
}

.bar-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef7;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--navy-soft));
}

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

.branch-card {
    padding: 20px;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.branch-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.branch-card h2,
.branch-card h3 {
    margin: 0 0 8px;
    color: var(--navy);
    font-size: 1.05rem;
    font-weight: 800;
}

.branch-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.branch-stats div {
    padding: 12px;
    border-radius: 14px;
    background: #f4f7fb;
}

.branch-stats span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
}

.branch-stats strong {
    color: var(--navy);
    font-size: 0.95rem;
}

.premium-table {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.premium-table.table-responsive {
    overflow-x: auto;
}

.premium-table .table {
    min-width: 860px;
}

.table {
    margin: 0;
}

.table thead th {
    color: var(--muted);
    background: #f7f9fc;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.badge-soft {
    color: var(--navy);
    background: #e8eef7;
}

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

.student-search {
    display: flex;
    gap: 10px;
    min-width: min(100%, 520px);
}

.student-search .form-control {
    min-width: 180px;
}

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

.payment-history-table {
    min-width: 780px;
}

.comparison-progress {
    width: 100%;
    min-width: 150px;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef7;
}

.comparison-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--success));
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 18px;
    align-items: start;
}

.settings-side {
    display: grid;
    gap: 18px;
}

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

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

.settings-full,
.settings-actions {
    grid-column: 1 / -1;
}

.logo-upload-card {
    overflow: hidden;
}

.logo-preview {
    display: grid;
    place-items: center;
    min-height: 180px;
    margin-bottom: 18px;
    border: 1px dashed #b9c7da;
    border-radius: 18px;
    background: linear-gradient(180deg, #f8fbff, #eef4fb);
}

.logo-preview img {
    max-width: 220px;
    max-height: 140px;
    object-fit: contain;
}

.logo-placeholder {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    color: var(--muted);
    border-radius: 24px;
    background: #fff;
    border: 1px solid var(--line);
    font-weight: 800;
}

.branch-manage-table .table {
    min-width: 1120px;
}

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

.sync-log-table .table {
    min-width: 1180px;
}

.api-key-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.api-key-box code {
    display: inline-flex;
    max-width: 260px;
    overflow: hidden;
    color: var(--navy);
    background: #f4f7fb;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 9px;
    text-overflow: ellipsis;
}

.sync-filter-form {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.api-test-form {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: end;
}

.api-test-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.json-result {
    margin: 0;
    padding: 18px;
    color: #dbeafe;
    background: #07182d;
    border-radius: 14px;
    overflow-x: auto;
}

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

.branch-manage-cards {
    display: none;
}

.branch-manage-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(11, 31, 58, 0.06);
}

.branch-manage-card h3 {
    margin: 0 0 8px;
    color: var(--navy);
    font-size: 1.05rem;
    font-weight: 800;
}

.branch-manage-card dl {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}

.branch-manage-card dl div {
    display: grid;
    gap: 2px;
}

.branch-manage-card dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.branch-manage-card dd {
    margin: 0;
    color: var(--navy);
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .portal-sidebar {
        transform: translateX(-100%);
    }

    .portal-sidebar.open {
        transform: translateX(0);
    }

    .portal-main {
        margin-left: 0;
        padding: 18px;
    }

    .mobile-menu {
        display: inline-flex;
    }

    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(6, 16, 31, 0.48);
        z-index: 1030;
    }

    .summary-grid,
    .dashboard-summary-grid,
    .payment-summary-grid,
    .content-grid,
    .branch-list,
    .company-select-grid {
        grid-template-columns: 1fr;
    }

    .student-heading,
    .student-search {
        width: 100%;
    }

    .student-heading {
        display: grid;
    }

    .settings-grid,
    .settings-form,
    .branch-manage-form,
    .sync-filter-form,
    .api-test-form {
        grid-template-columns: 1fr;
    }

    .branch-manage-table {
        display: none;
    }

    .branch-manage-cards {
        display: grid;
        gap: 14px;
    }
}

@media (max-width: 575.98px) {
    .login-card {
        padding: 26px 20px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        align-self: stretch;
        justify-content: space-between;
    }

    .branch-stats,
    .chart-row {
        grid-template-columns: 1fr;
    }

    .chart-row strong {
        text-align: left !important;
    }

    .student-search {
        display: grid;
    }

    .filter-chips {
        margin-left: -18px;
        margin-right: -18px;
        padding-left: 18px;
        padding-right: 18px;
    }
}

.form-help{
    margin-top:6px;
    font-size:12px;
    color:#64748b;
    line-height:1.45;
}
.company-structure-note{
    margin-top:12px;
    padding:12px 14px;
    border-radius:14px;
    background:#f8fafc;
    border:1px solid #e2e8f0;
    color:#475569;
    font-size:13px;
}
