:root {
    --sidebar: #082a4d;
    --sidebar-2: #0b3765;
    --sidebar-hover: rgba(255,255,255,.12);
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #122033;
    --muted: #607188;
    --border: #dbe4f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --shadow: 0 12px 28px rgba(15, 23, 42, .08);
    --chart-prev: #60a5fa;
    --chart-prev-soft: #dbeafe;
    --chart-target: #f59e0b;
    --chart-target-soft: #fef3c7;
    --chart-actual: #10b981;
    --chart-actual-soft: #d1fae5;
}

* { box-sizing: border-box; }
html { font-size: clamp(14px, .35vw + 12.5px, 16px); }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Roboto, Arial, "Helvetica Neue", sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: clamp(220px, 17vw, 280px);
    flex: 0 0 clamp(220px, 17vw, 280px);
    background: linear-gradient(180deg, var(--sidebar), #061a32);
    color: #fff;
    padding: clamp(16px, 2vw, 26px) 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 8px 0 22px rgba(8,42,77,.18);
}
.brand {
    display: block;
    color: #fff;
    font-size: clamp(1.05rem, .8vw + .85rem, 1.45rem);
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: .01em;
    padding: 10px 4px 22px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 7px; }
.sidebar a {
    color: rgba(255,255,255,.92);
    display: flex;
    align-items: center;
    min-height: 42px;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 650;
    letter-spacing: .005em;
    transition: background .18s ease, transform .18s ease;
}
.sidebar a:hover, .sidebar a:focus {
    background: var(--sidebar-hover);
    color: #fff;
    transform: translateX(2px);
}

.main { flex: 1; min-width: 0; }
.topbar {
    min-height: 64px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px clamp(16px, 2vw, 28px);
    font-size: clamp(1.05rem, .55vw + .9rem, 1.35rem);
    font-weight: 760;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 6px 18px rgba(15,23,42,.04);
}
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: .92rem; font-weight: 500; color: var(--muted); }
.language-switch, .auth-language-switch { display: inline-flex; align-items: center; gap: 4px; background: #eef4ff; border: 1px solid #cfddfb; border-radius: 999px; padding: 3px; }
.language-switch a, .auth-language-switch a { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 28px; border-radius: 999px; font-weight: 800; font-size: .78rem; color: #244566; }
.language-switch a.active, .auth-language-switch a.active { background: var(--sidebar); color: #fff; box-shadow: 0 3px 10px rgba(11,47,91,.22); }
.auth-language-switch { margin: 8px 0 16px; }

.content { padding: clamp(14px, 2.1vw, 26px); max-width: 1680px; margin: 0 auto; }
.card, .auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: clamp(16px, 1.4vw, 22px);
    box-shadow: var(--shadow);
    padding: clamp(14px, 1.6vw, 22px);
    margin-bottom: 20px;
}
.auth-card { max-width: 460px; margin: 7vh auto; padding: clamp(24px, 3vw, 34px); }
.auth-logo { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; background: #eef4ff; color: #0b2f5b; font-weight: 800; padding: 8px 12px; margin-bottom: 14px; }

h1, h2, h3 { margin: 0; color: #0b1f3a; letter-spacing: .005em; }
h1 { font-size: clamp(1.35rem, 1vw + 1rem, 1.85rem); line-height: 1.25; margin-bottom: 13px; }
h2 { font-size: clamp(1.05rem, .45vw + .95rem, 1.28rem); line-height: 1.3; margin-bottom: 11px; }
h3 { font-size: 1rem; line-height: 1.35; }
.muted { color: var(--muted); }
.subtext { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.help-text { display: block; color: var(--muted); font-size: .82rem; margin-top: 5px; }

label { display: block; margin-bottom: 6px; color: #263b57; font-weight: 720; }
input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 11px;
    background: #fff;
    color: var(--text);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.14); }
input[readonly] { background: #f8fafc; color: #64748b; }

.btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 12px;
    min-height: 40px;
    padding: 8px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    font-weight: 780;
    font-size: .92rem;
    box-shadow: 0 4px 12px rgba(15,23,42,.04);
    transition: border-color .16s ease, color .16s ease, transform .16s ease, background .16s ease;
}
.btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: #f8fafc; }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.full { width: 100%; }

.alert, .toast { border-radius: 14px; padding: 12px 14px; margin: 12px 0; font-weight: 650; }
.alert.error, .toast.error { background: #fee2e2; color: #991b1b; }
.toast.success { background: #dcfce7; color: #166534; }
.toast.info { background: #dbeafe; color: #1e40af; }
.toast.warning { background: #fef3c7; color: #92400e; }
.toast { animation: fadeOut 7s forwards; }
@keyframes fadeOut { 0%,80% { opacity: 1; } 100% { opacity: .16; } }

.filter-row { display: flex; flex-wrap: wrap; align-items: end; gap: 11px; margin-bottom: 18px; }
.filter-row label { margin: 0; }
.filter-row input, .filter-row select { width: auto; min-width: clamp(140px, 12vw, 230px); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 15px; }
.full-row { grid-column: 1 / -1; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-header h2 { margin-bottom: 0; }
.no-margin { margin-bottom: 0; }
.compact-card { padding: 13px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 15px; margin-bottom: 20px; }
.kpi-grid.compact { grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: clamp(14px, 1.4vw, 18px); box-shadow: 0 10px 24px rgba(15,23,42,.05); }
.kpi-card span { display: block; color: var(--muted); font-size: .86rem; margin-bottom: 8px; font-weight: 700; }
.kpi-card strong { display: block; font-size: clamp(1.15rem, .75vw + .95rem, 1.55rem); line-height: 1.25; color: #0b2f5b; word-break: break-word; }
.kpi-card.highlight { border-color: #bfdbfe; background: #eff6ff; }

.table-responsive { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1100px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: 9px 10px; text-align: left; vertical-align: middle; }
.data-table th { background: #f3f7fb; font-size: .78rem; text-transform: uppercase; color: #475569; position: sticky; top: 0; z-index: 2; letter-spacing: .02em; }
.data-table td input, .data-table td select { min-width: 120px; }
.data-table tr.locked td { background: #f8fafc; }
.readonly-money, .strong-money { text-align: right; white-space: nowrap; }
.strong-money { font-weight: 800; color: #0f766e; }
.num { text-align: right; }
.rate { max-width: 105px; text-align: right; }

.status-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 5px 10px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status-pill.ok { background: #dcfce7; color: #166534; }
.status-pill.bad { background: #fee2e2; color: #991b1b; }
.status-pill.neutral { background: #e2e8f0; color: #475569; }
.status-pill.lock { background: #e2e8f0; color: #334155; }

.chart-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    gap: 10px;
    margin: 0 0 18px;
}
.legend-item {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 9px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
    padding: 9px 11px;
}
.legend-item strong { font-size: .9rem; color: #0b1f3a; }
.legend-item em { grid-column: 2; font-style: normal; color: var(--muted); font-size: .78rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 999px; display: inline-block; }
.legend-dot.prev { background: var(--chart-prev); }
.legend-dot.req { background: var(--chart-target); }
.legend-dot.act { background: var(--chart-actual); }
.chart-wrap { display: flex; flex-direction: column; gap: 14px; }
.chart-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf2f7;
}
.chart-label { font-weight: 800; color: #0b1f3a; }
.bar-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.bar-line { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 9px; align-items: center; }
.bar-name { color: var(--muted); font-size: .8rem; font-weight: 700; }
.bar-track { height: 22px; border-radius: 999px; background: #eef2f7; overflow: hidden; min-width: 0; }
.bar { height: 100%; border-radius: 999px; min-width: 3px; position: relative; transition: width .35s ease; box-shadow: inset 0 -1px 0 rgba(0,0,0,.08); }
.bar span { position: absolute; left: 9px; top: 2px; font-size: .72rem; white-space: nowrap; color: #0f172a; font-weight: 760; }
.bar.prev { background: linear-gradient(90deg, var(--chart-prev-soft), var(--chart-prev)); }
.bar.req { background: linear-gradient(90deg, var(--chart-target-soft), var(--chart-target)); }
.bar.act { background: linear-gradient(90deg, var(--chart-actual-soft), var(--chart-actual)); }

.lock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 11px; }
.lock-form { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 16px; padding: 9px; background: #fff; }
.role-box { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 7px 11px; font-weight: 650; background: #f8fafc; }
.check input { width: auto; min-height: auto; }
.small-checks { min-width: 260px; }
.user-list { display: flex; flex-direction: column; gap: 12px; }
.user-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; align-items: end; border: 1px solid var(--border); border-radius: 18px; padding: 14px; background: #fff; }
.user-row .full-row { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 13px; }
.resend-form { margin-top: 10px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.permission-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 13px; }
.permission-group { border: 1px solid var(--border); border-radius: 16px; padding: 13px; background: #f8fafc; }
.permission-group h3 { font-size: .96rem; margin: 0 0 9px 0; color: #0b2f5b; }
.role-edit-list { display: flex; flex-direction: column; gap: 13px; }
.role-edit-card { border: 1px solid var(--border); border-radius: 18px; padding: 15px; background: #fff; display: grid; gap: 13px; }
.role-edit-card > div:first-child { max-width: 430px; }
.setup-card { max-width: 660px; }
.setup-grid { display: grid; grid-template-columns: 1fr 155px; gap: 12px; }
.setup-check { align-self: flex-start; }
.field-error { display: block; color: var(--danger); font-size: .78rem; margin-top: 5px; }
.otp-input { text-align: center; font-size: clamp(1.35rem, 2vw, 1.7rem); font-weight: 800; letter-spacing: .45em; }

@media (max-width: 1024px) {
    .app-shell { display: block; }
    .sidebar { position: relative; width: 100%; height: auto; padding: 14px; }
    .brand { margin-bottom: 8px; padding-bottom: 10px; }
    .sidebar nav { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 4px; }
    .sidebar a { white-space: nowrap; min-height: 38px; }
    .topbar { position: relative; height: auto; min-height: 58px; align-items: flex-start; gap: 10px; flex-direction: column; }
    .topbar-right { flex-wrap: wrap; }
}

@media (max-width: 760px) {
    .content { padding: 14px; }
    .filter-row { display: grid; grid-template-columns: 1fr; }
    .filter-row input, .filter-row select, .filter-row .btn { width: 100%; }
    .card-header { align-items: stretch; flex-direction: column; }
    .chart-row { grid-template-columns: 40px 1fr; align-items: start; }
    .chart-row .status-pill { grid-column: 2; justify-self: flex-start; }
    .bar-line { grid-template-columns: 72px minmax(0, 1fr); }
    .bar span { font-size: .68rem; }
    .lock-form { grid-template-columns: 1fr; }
    .auth-card { margin: 18px auto; }
    .permission-groups { grid-template-columns: 1fr; }
    .pager { justify-content: flex-start; flex-wrap: wrap; }
    .compact-card .filter-row { display: grid; grid-template-columns: 1fr; }
    .compact-card input[type=file] { width: 100%; }
    .setup-grid { grid-template-columns: 1fr; }
    .setup-card { max-width: 100%; margin: 12px auto; }
}

@media (max-width: 480px) {
    .auth-card { padding: 22px; }
    .bar-line { grid-template-columns: 1fr; gap: 4px; }
    .chart-row { grid-template-columns: 1fr; }
    .chart-row .status-pill { grid-column: 1; }
    .otp-input { letter-spacing: .25em; }
}

/* V1.1.6 responsive KPI and department tracking */
.dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.kpi-card {
    min-width: 0;
}
.kpi-card strong {
    font-size: clamp(1.05rem, .62vw + .9rem, 1.32rem);
    line-height: 1.18;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    overflow-wrap: normal;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
}
.kpi-grid.compact .kpi-card strong {
    font-size: clamp(1rem, .55vw + .88rem, 1.24rem);
}
.department-summary-table {
    min-width: 980px;
}
.department-table {
    min-width: 760px;
}
.code-text {
    display: block;
    margin-top: 2px;
    font-size: .76rem;
}
.form-action-cell {
    display: flex;
    align-items: end;
}
.form-action-cell .btn {
    width: 100%;
}
@media (min-width: 1400px) {
    .dashboard-kpis {
        grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
    }
}
@media (max-width: 760px) {
    .dashboard-kpis {
        grid-template-columns: 1fr;
    }
    .kpi-card strong {
        font-size: clamp(1rem, 5vw, 1.32rem);
    }
}

/* V1.1.7: whole-company reference mode and monthly achievement */
.info-note {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 14px;
    padding: 10px 13px;
    margin: 0 0 15px;
    font-weight: 650;
    font-size: .92rem;
}
.reference-kpis .kpi-card.highlight,
.reference-kpis .kpi-card {
    background: #fff;
}
.monthly-achievement-table {
    min-width: 1080px;
}
.monthly-reference-table {
    min-width: 860px;
}
.chart-row .status-pill {
    min-width: 76px;
}
@media (max-width: 760px) {
    .info-note {
        font-size: .86rem;
    }
}

/* V1.1.8: collapsible side menu and sticky horizontal input scrollbar */
.sidebar {
    transition: width .18s ease, flex-basis .18s ease, padding .18s ease;
}
.sidebar-toggle {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 12px;
    background: rgba(255,255,255,.10);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 900;
    font-size: 1.05rem;
    margin: 0 0 12px 2px;
    transition: background .18s ease, transform .18s ease;
}
.sidebar-toggle:hover,
.sidebar-toggle:focus {
    background: rgba(255,255,255,.18);
    outline: none;
}
.sidebar-toggle .toggle-open { display: none; }
.sidebar-toggle .toggle-close { display: inline; font-size: 1.45rem; line-height: 1; }
.nav-mark {
    display: none;
    min-width: 34px;
    height: 34px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .02em;
}
.nav-text,
.brand-text {
    min-width: 0;
}
.app-shell.sidebar-collapsed .sidebar {
    width: 76px;
    flex-basis: 76px;
    padding: 16px 9px;
}
.app-shell.sidebar-collapsed .brand {
    padding: 4px 0 10px;
    min-height: 8px;
}
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-text {
    display: none;
}
.app-shell.sidebar-collapsed .sidebar nav {
    align-items: center;
}
.app-shell.sidebar-collapsed .sidebar a {
    justify-content: center;
    width: 46px;
    min-height: 46px;
    padding: 6px;
    border-radius: 15px;
}
.app-shell.sidebar-collapsed .sidebar a:hover,
.app-shell.sidebar-collapsed .sidebar a:focus {
    transform: none;
}
.app-shell.sidebar-collapsed .nav-mark {
    display: inline-flex;
}
.app-shell.sidebar-collapsed .sidebar-toggle {
    margin-left: 10px;
}
.app-shell.sidebar-collapsed .sidebar-toggle .toggle-open { display: inline; }
.app-shell.sidebar-collapsed .sidebar-toggle .toggle-close { display: none; }
.table-card {
    overflow: visible;
}
.table-responsive.sticky-x-source {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.table-responsive.sticky-x-source::-webkit-scrollbar {
    width: 0;
    height: 0;
}
.sticky-x-scroll {
    position: fixed;
    bottom: 0;
    z-index: 90;
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 26px rgba(15,23,42,.10);
    padding-top: 2px;
}
.sticky-x-scroll-inner {
    height: 1px;
}
.sticky-x-scroll.is-hidden {
    display: none;
}
@media (max-width: 1024px) {
    .sidebar-toggle { display: none; }
    .app-shell.sidebar-collapsed .sidebar {
        width: 100%;
        flex-basis: auto;
        padding: 14px;
    }
    .app-shell.sidebar-collapsed .brand-text,
    .app-shell.sidebar-collapsed .nav-text {
        display: inline;
    }
    .app-shell.sidebar-collapsed .nav-mark {
        display: none;
    }
    .app-shell.sidebar-collapsed .sidebar nav {
        align-items: stretch;
    }
    .app-shell.sidebar-collapsed .sidebar a {
        width: auto;
        min-height: 38px;
        padding: 10px 12px;
        justify-content: flex-start;
    }
}

.action-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.action-cell form { margin: 0; }
.info-box {
    display: grid;
    gap: 5px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    background: #eff6ff;
    color: #0f3765;
    margin: 12px 0 18px;
}
.stack-form { display: grid; gap: 20px; }
.permission-section {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: #fff;
}
.permission-section h3 { margin: 0 0 12px; font-size: 1.02rem; }
.role-box.separated { gap: 10px; }
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.scope-all { margin-bottom: 4px; }
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.disabled-block {
    opacity: .55;
    pointer-events: none;
}

/* V1.1.11: cleaner auth screens, logo, and data-scope behavior */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-logo {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 14px;
    object-fit: contain;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.18);
    padding: 5px;
}
.app-shell.sidebar-collapsed .brand {
    justify-content: center;
}
.app-shell.sidebar-collapsed .brand-logo {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
}
.auth-page {
    min-height: calc(100vh - 56px);
    display: grid;
    grid-template-columns: minmax(280px, .9fr) minmax(360px, 520px);
    gap: clamp(18px, 4vw, 56px);
    align-items: center;
    justify-content: center;
    padding: clamp(18px, 4vw, 54px);
}
.auth-hero {
    min-height: 430px;
    border-radius: 32px;
    background:
        radial-gradient(circle at 20% 20%, rgba(96,165,250,.38), transparent 30%),
        radial-gradient(circle at 80% 75%, rgba(16,185,129,.28), transparent 30%),
        linear-gradient(135deg, #082a4d, #0b3765 48%, #0f766e);
    box-shadow: 0 24px 60px rgba(8,42,77,.22);
    display: flex;
    align-items: flex-end;
    padding: clamp(20px, 3vw, 32px);
    overflow: hidden;
    position: relative;
}
.auth-hero::before,
.auth-hero::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
}
.auth-hero::before { width: 220px; height: 220px; right: -60px; top: -60px; }
.auth-hero::after { width: 140px; height: 140px; left: 38px; top: 62px; }
.auth-hero-card {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    display: grid;
    gap: 14px;
    color: #fff;
}
.auth-hero-card img {
    width: 74px;
    height: 74px;
    border-radius: 22px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.22);
    padding: 8px;
    object-fit: contain;
}
.auth-hero-card strong {
    font-size: clamp(1.8rem, 2vw + 1rem, 3rem);
    line-height: 1.12;
    letter-spacing: .01em;
}
.auth-hero-card span {
    color: rgba(255,255,255,.82);
    font-size: 1rem;
    max-width: 36ch;
}
.auth-card-modern {
    max-width: 520px;
    width: 100%;
    margin: 0;
    padding: clamp(24px, 3vw, 36px);
    border-radius: 28px;
    box-shadow: 0 24px 65px rgba(15,23,42,.10);
}
.auth-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}
.auth-brand img {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    object-fit: contain;
    background: #eef4ff;
    border: 1px solid #cfddfb;
    padding: 7px;
    flex: 0 0 58px;
}
.auth-brand div {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.auth-brand span {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 750;
}
.auth-brand strong {
    color: #0b1f3a;
    font-size: clamp(1.5rem, 1.2vw + 1rem, 2rem);
    line-height: 1.12;
}
.auth-intro {
    margin: 0 0 18px;
    font-size: 1rem;
}
.otp-card {
    margin: 0 auto;
}
.otp-input {
    min-height: 62px;
    border-radius: 18px;
    letter-spacing: .55em;
    font-size: clamp(1.45rem, 2.8vw, 2.1rem);
    background: #fbfdff;
}
@media (max-width: 980px) {
    .auth-page {
        grid-template-columns: 1fr;
        padding: 18px;
    }
    .auth-hero {
        display: none;
    }
    .auth-card-modern {
        margin: 5vh auto;
    }
}
@media (max-width: 520px) {
    .auth-page { padding: 12px; }
    .auth-card-modern { padding: 22px; border-radius: 22px; }
    .auth-head { flex-direction: column; }
    .auth-language-switch { margin: 0; }
    .auth-brand img { width: 50px; height: 50px; flex-basis: 50px; }
    .otp-input { letter-spacing: .28em; }
}

/* V1.1.12: smaller OTP field hint and logo upload/selector */
.otp-input {
    min-height: 56px;
    letter-spacing: .28em;
    font-size: clamp(1.18rem, 1.6vw, 1.55rem);
}
.otp-input::placeholder {
    color: #8a97a8;
    font-size: 1rem;
    letter-spacing: 0;
    font-weight: 650;
}
.settings-logo-panel {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #f8fbff;
    padding: 16px;
}
.settings-logo-preview {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid #cfddfb;
    overflow: hidden;
}
.settings-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}
.settings-logo-fields h3 {
    margin: 0 0 4px;
}
.logo-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 14px;
    margin-top: 12px;
}
input[type="file"] {
    padding: 9px;
    min-height: 44px;
}
@media (max-width: 560px) {
    .settings-logo-panel {
        grid-template-columns: 1fr;
    }
    .settings-logo-preview {
        width: 76px;
        height: 76px;
    }
}


/* V1.1.13: show logo as the main identity; remove large app-name text from auth/sidebar */
.brand.brand-logo-only {
    justify-content: flex-start;
    padding: 8px 4px 22px;
}
.brand.brand-logo-only .brand-logo {
    width: min(100%, 156px);
    height: 58px;
    flex: 0 1 156px;
    border-radius: 14px;
    padding: 6px;
    background: rgba(255,255,255,.08);
    object-fit: contain;
}
.app-shell.sidebar-collapsed .brand.brand-logo-only {
    justify-content: center;
    padding: 5px 0 12px;
}
.app-shell.sidebar-collapsed .brand.brand-logo-only .brand-logo {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    padding: 5px;
}
.auth-hero {
    align-items: center;
    justify-content: center;
}
.auth-hero-card.logo-only {
    width: min(84%, 560px);
    place-items: center;
    gap: 0;
}
.auth-hero-card.logo-only img {
    width: 100%;
    max-width: 460px;
    height: auto;
    max-height: 240px;
    border-radius: 26px;
    padding: clamp(14px, 2vw, 22px);
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.24);
    object-fit: contain;
}
.auth-brand {
    align-items: center;
}
.auth-brand img {
    width: clamp(76px, 8vw, 126px);
    height: clamp(46px, 5vw, 72px);
    flex: 0 0 auto;
    border-radius: 14px;
    padding: 6px;
    background: #f8fbff;
}
.auth-brand div {
    gap: 0;
}
.auth-brand span {
    display: none;
}
.auth-brand strong {
    font-size: clamp(1.45rem, 1.1vw + 1rem, 1.95rem);
}
@media (max-width: 520px) {
    .auth-brand img {
        width: 92px;
        height: 54px;
        flex-basis: auto;
    }
    .brand.brand-logo-only .brand-logo {
        width: 132px;
        height: 52px;
    }
}

.setup-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 180px);
    min-height: 72px;
    border-radius: 18px;
    background: #f8fbff;
    border: 1px solid #cfddfb;
    padding: 10px;
    margin-bottom: 16px;
}
.setup-logo img {
    max-width: 100%;
    max-height: 84px;
    object-fit: contain;
}

/* V1.1.14: centered auth screen and popup notifications */
.auth-page {
    min-height: calc(100vh - 2 * clamp(14px, 2.1vw, 26px));
    display: grid;
    grid-template-columns: minmax(0, min(100%, 560px));
    place-items: center;
    justify-content: center;
    align-content: center;
    padding: clamp(12px, 3vw, 28px);
}
.auth-hero { display: none !important; }
.auth-card-modern,
.otp-card {
    width: min(100%, 560px);
    max-width: 560px;
    margin: 0 auto;
}
.auth-card-modern {
    padding: clamp(22px, 3vw, 34px);
}
.auth-head {
    align-items: center;
}
.auth-intro {
    margin-top: 2px;
}
.toast-stack {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    width: min(460px, calc(100vw - 28px));
    display: grid;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
    transform: translate(-50%, -50%);
}
.toast-stack .toast {
    margin: 0;
    border: 1px solid rgba(255,255,255,.72);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
    pointer-events: auto;
    animation: toastLife 6.5s ease forwards;
    text-align: center;
    font-size: .96rem;
    line-height: 1.45;
}
.toast-stack .toast.success { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.toast-stack .toast.info { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.toast-stack .toast.warning { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.toast-stack .toast.error { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }
.page-toast-stack {
    top: 50%;
    left: 50%;
    right: auto;
}
@keyframes toastLife {
    0% { opacity: 0; transform: translateY(-8px) scale(.98); }
    9%, 82% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-8px) scale(.98); }
}
@media (max-width: 980px) {
    .auth-page {
        grid-template-columns: minmax(0, min(100%, 560px));
        min-height: calc(100vh - 28px);
        padding: 14px;
    }
    .auth-card-modern {
        margin: 0 auto;
    }
}
@media (max-width: 560px) {
    .auth-page {
        min-height: calc(100vh - 24px);
        padding: 12px;
    }
    .auth-card-modern {
        width: 100%;
        border-radius: 22px;
        padding: 20px;
    }
    .auth-head {
        flex-direction: row;
        gap: 10px;
    }
    .auth-brand {
        gap: 10px;
    }
    .auth-brand img {
        width: 82px;
        height: 50px;
    }
    .auth-brand strong {
        font-size: clamp(1.45rem, 7vw, 1.85rem);
    }
    .toast-stack,
    .page-toast-stack {
        top: 50%;
        left: 50%;
        right: auto;
        width: calc(100vw - 24px);
        transform: translate(-50%, -50%);
    }
}
.auth-head .auth-language-switch { margin: 0; flex: 0 0 auto; }

/* V1.1.15: cleaner sidebar logo and Excel template action */
.brand.brand-logo-only {
    justify-content: center;
    padding: 6px 0 18px;
}
.brand.brand-logo-only .brand-logo {
    width: min(150px, 86%);
    height: auto;
    max-height: 52px;
    flex: 0 0 auto;
    display: block;
    object-fit: contain;
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: none;
}
.app-shell.sidebar-collapsed .brand.brand-logo-only {
    padding: 5px 0 12px;
}
.app-shell.sidebar-collapsed .brand.brand-logo-only .brand-logo {
    width: 42px;
    height: 42px;
    max-height: 42px;
    object-fit: contain;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 12px;
    padding: 3px;
}
.compact-card .filter-row .btn.ghost {
    white-space: nowrap;
}
@media (max-width: 1024px) {
    .brand.brand-logo-only {
        justify-content: flex-start;
        padding: 4px 0 10px;
    }
    .brand.brand-logo-only .brand-logo {
        width: min(150px, 52vw);
        max-height: 50px;
    }
}

/* V1.1.16: transparent logo handling */
.settings-logo-preview {
    background:
        linear-gradient(45deg, rgba(148,163,184,.12) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(148,163,184,.12) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(148,163,184,.12) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(148,163,184,.12) 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
    background-color: #f8fafc;
}
.settings-logo-preview img { background: transparent; }
.inline-check.clean-logo-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 7px 10px;
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    font-size: .88rem;
    font-weight: 700;
    color: #31445d;
}
.inline-check.clean-logo-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
}
.brand.brand-logo-only .brand-logo,
.app-shell.sidebar-collapsed .brand.brand-logo-only .brand-logo {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}
.auth-brand img,
.setup-logo img {
    background: transparent;
}


/* V1.1.17: remove ImageSharp NU1902/NU1903 by package update and make sidebar logo cleaner */
.brand.brand-logo-only {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px 0 20px;
}
.brand.brand-logo-only .brand-logo {
    width: min(176px, 84%);
    height: 72px;
    max-height: 72px;
    object-fit: contain;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .14);
}
.app-shell.sidebar-collapsed .brand.brand-logo-only {
    padding: 6px 0 14px;
}
.app-shell.sidebar-collapsed .brand.brand-logo-only .brand-logo {
    width: 46px;
    height: 46px;
    max-height: 46px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .96);
}
.settings-logo-preview img,
.auth-brand img,
.setup-logo img {
    image-rendering: auto;
}
@media (max-width: 1024px) {
    .brand.brand-logo-only {
        justify-content: center;
        padding: 6px 0 14px;
    }
    .brand.brand-logo-only .brand-logo {
        width: min(168px, 82%);
        height: 68px;
        max-height: 68px;
    }
}

/* V1.1.18: quarterly same-period comparison and better tablet/mobile layout */
.quarter-card {
    margin-top: 18px;
}
.quarter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}
.quarter-item {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    padding: 15px;
    display: grid;
    gap: 13px;
    min-width: 0;
}
.quarter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.quarter-head > strong {
    font-size: clamp(1.05rem, .5vw + .95rem, 1.25rem);
    color: #092848;
}
.quarter-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.quarter-values span {
    min-width: 0;
    border-radius: 14px;
    background: #f1f5f9;
    padding: 9px 10px;
}
.quarter-values em {
    display: block;
    font-style: normal;
    color: #64748b;
    font-weight: 700;
    font-size: .76rem;
    margin-bottom: 3px;
}
.quarter-values b {
    display: block;
    color: #0b2f5b;
    font-size: clamp(.9rem, .4vw + .82rem, 1.05rem);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.quarter-bars {
    display: grid;
    gap: 8px;
}
.quarter-bar-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}
.quarter-bar-row > span {
    color: #64748b;
    font-size: .78rem;
    font-weight: 800;
}
.quarter-bar-row .bar-track {
    height: 12px;
}
.quarter-bar-row .bar {
    height: 12px;
    min-width: 0;
}

@media (min-width: 1025px) and (max-width: 1320px) {
    .content {
        padding: 20px;
    }
    .filter-row {
        grid-template-columns: auto minmax(150px, 220px) auto minmax(180px, 260px) auto;
        gap: 10px 12px;
    }
    .dashboard-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .quarter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    body {
        overflow-x: hidden;
    }
    .content {
        padding: 14px;
    }
    .page-title,
    .topbar h1 {
        font-size: clamp(1.05rem, 4.2vw, 1.4rem);
        line-height: 1.25;
    }
    .filter-row,
    .compact-card .filter-row {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 9px;
    }
    .filter-row label {
        margin-top: 2px;
    }
    .filter-row input,
    .filter-row select,
    .filter-row .btn,
    .compact-card .filter-row input,
    .compact-card .filter-row select,
    .compact-card .filter-row .btn {
        width: 100%;
    }
    .kpi-grid,
    .dashboard-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .kpi-card {
        padding: 13px;
        border-radius: 16px;
    }
    .kpi-card strong {
        font-size: clamp(.98rem, 3.6vw, 1.18rem);
    }
    .card {
        border-radius: 18px;
        padding: 14px;
    }
    .quarter-grid {
        grid-template-columns: 1fr;
    }
    .quarter-values {
        grid-template-columns: 1fr 1fr;
    }
    .chart-legend {
        grid-template-columns: 1fr;
    }
    .chart-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px 0;
    }
    .chart-label {
        font-size: .95rem;
    }
    .bar-line {
        grid-template-columns: 74px minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .content {
        padding: 10px;
    }
    .topbar {
        padding: 10px 12px;
    }
    .topbar-right {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }
    .user-email {
        max-width: 44vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .kpi-grid,
    .dashboard-kpis {
        grid-template-columns: 1fr;
    }
    .kpi-card span {
        font-size: .76rem;
    }
    .quarter-item {
        padding: 13px;
        border-radius: 16px;
    }
    .quarter-values {
        grid-template-columns: 1fr;
    }
    .quarter-bar-row {
        grid-template-columns: 68px minmax(0, 1fr);
    }
    .status-pill {
        min-width: auto;
        padding: 6px 10px;
        font-size: .78rem;
    }
    .data-table th,
    .data-table td {
        padding: 10px 9px;
        font-size: .84rem;
    }
    .bar-line {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    .bar-name {
        font-size: .76rem;
    }
    .bar span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* V1.1.19: compact quarterly figures and mobile drawer menu */
body.no-scroll {
    overflow: hidden;
}
.topbar {
    background: #fff;
    z-index: 30;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--sidebar);
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 900;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .06);
    cursor: pointer;
}
.sidebar-backdrop {
    display: none;
}
.quarter-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.quarter-item {
    gap: 11px;
}
.quarter-values {
    grid-template-columns: 1fr;
    gap: 7px;
}
.quarter-values span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
}
.quarter-values em {
    margin: 0;
    flex: 0 0 auto;
    max-width: 45%;
}
.quarter-values b {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
    font-size: clamp(.78rem, .28vw + .72rem, .94rem);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: normal;
}
.quarter-head .status-pill {
    flex: 0 0 auto;
}
.bar span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 1025px) and (max-width: 1380px) {
    .quarter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .app-shell {
        display: flex;
    }
    .mobile-menu-toggle {
        display: inline-flex;
        flex: 0 0 auto;
    }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(310px, 84vw);
        height: 100dvh;
        z-index: 70;
        padding: 16px 14px;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 18px 0 40px rgba(8, 42, 77, .24);
    }
    .app-shell.mobile-menu-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 60;
        display: block;
        background: rgba(2, 8, 23, .48);
        opacity: 0;
        pointer-events: none;
        transition: opacity .18s ease;
    }
    .app-shell.mobile-menu-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    .sidebar-toggle {
        display: inline-flex;
    }
    .brand.brand-logo-only {
        justify-content: flex-start;
        padding: 2px 4px 18px;
    }
    .brand.brand-logo-only .brand-logo {
        width: 160px;
        max-width: 78%;
        height: auto;
        max-height: 76px;
    }
    .sidebar nav {
        flex-direction: column;
        overflow: visible;
        gap: 8px;
        padding-bottom: 0;
    }
    .sidebar a {
        white-space: normal;
        min-height: 42px;
    }
    .nav-mark {
        display: inline-flex;
    }
    .nav-text {
        display: inline;
    }
    .topbar {
        position: sticky;
        top: 0;
        min-height: 58px;
        flex-direction: row;
        align-items: center;
        padding: 9px 12px;
    }
    .topbar-right {
        margin-left: auto;
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }
    .topbar-right > span {
        max-width: 26vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .language-switch a {
        min-width: 30px;
        min-height: 26px;
    }
    .topbar .btn.small {
        min-height: 34px;
        padding: 7px 10px;
    }
}

@media (max-width: 620px) {
    .topbar-title {
        max-width: 42vw;
        font-size: 1rem;
    }
    .topbar-right {
        gap: 6px;
    }
    .topbar-right > span {
        display: none;
    }
    .quarter-head {
        align-items: flex-start;
    }
    .quarter-values span {
        align-items: flex-start;
    }
    .quarter-values em {
        max-width: 48%;
    }
    .quarter-bars {
        gap: 6px;
    }
}

/* V1.1.25: mobile buttons and KPI cards */
.filter-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}
.filter-field > label {
    margin: 0;
}
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    min-width: 0;
}
.bonus-filter-row {
    display: grid;
    grid-template-columns: minmax(110px, 220px) minmax(190px, 280px) auto;
    align-items: end;
    gap: 12px;
}
.bonus-filter-row input,
.bonus-filter-row select,
.import-row input,
.import-row select {
    width: 100%;
    min-width: 0;
}
.import-card {
    padding: 14px;
}
.import-row {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    align-items: end;
    gap: 12px;
}
.import-actions {
    justify-content: flex-start;
}
.dashboard-kpis .kpi-card {
    min-height: 0;
}

@media (max-width: 900px) {
    .bonus-filter-row,
    .compact-card .import-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .filter-actions,
    .import-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }
    .filter-actions .btn,
    .import-actions .btn {
        width: 100%;
        min-width: 0;
        min-height: 38px;
        padding: 8px 10px;
    }
    .filter-actions .btn:first-child:nth-last-child(3) {
        grid-column: 1 / -1;
    }
    .dashboard-kpis,
    .kpi-grid.compact.dashboard-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .dashboard-kpis .kpi-card {
        padding: 11px 12px;
        border-radius: 15px;
    }
    .dashboard-kpis .kpi-card span {
        min-height: 2.3em;
        margin-bottom: 5px;
        font-size: .72rem;
        line-height: 1.18;
    }
    .dashboard-kpis .kpi-card strong {
        font-size: clamp(.95rem, 3.8vw, 1.18rem);
        line-height: 1.2;
    }
}

@media (max-width: 520px) {
    .content {
        padding: 10px 8px;
    }
    .filter-field > label,
    .compact-card label {
        font-size: .82rem;
    }
    .bonus-filter-row,
    .import-card,
    .dashboard-kpis {
        margin-bottom: 12px;
    }
    .import-card {
        padding: 12px;
    }
    .filter-actions,
    .import-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filter-actions .btn,
    .import-actions .btn {
        font-size: .82rem;
        min-height: 36px;
        border-radius: 11px;
    }
    .filter-actions .btn:first-child:nth-last-child(3) {
        grid-column: auto;
    }
    .dashboard-kpis,
    .kpi-grid.compact.dashboard-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }
    .dashboard-kpis .kpi-card {
        padding: 10px;
        border-radius: 14px;
    }
    .dashboard-kpis .kpi-card span {
        font-size: .68rem;
        line-height: 1.15;
        min-height: 2.25em;
    }
    .dashboard-kpis .kpi-card strong {
        font-size: clamp(.86rem, 4vw, 1.05rem) !important;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }
    .dashboard-kpis .kpi-card.highlight:nth-child(odd) {
        grid-column: 1 / -1;
    }
    .compact-card input[type=file] {
        min-height: 38px;
        padding: 6px 8px;
        font-size: .84rem;
    }
}

/* V1.1.27: negative amounts/rates use warning yellow instead of red. */
.negative-money,
.readonly-money.negative-money,
.strong-money.negative-money,
.kpi-card strong.negative-money,
.quarter-values b.negative-money {
    color: #b45309 !important;
}
.status-pill.negative-money,
.status-pill.bad.negative-money {
    background: #fef3c7 !important;
    color: #92400e !important;
}
.toast .toast-action {
    margin-left: 12px;
    border: 1px solid currentColor;
    background: rgba(255,255,255,.55);
    color: inherit;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 800;
    cursor: pointer;
}
.toast .toast-action:hover,
.toast .toast-action:focus {
    background: rgba(255,255,255,.85);
}

/* V1.1.29: compact percentage columns and clearer editable fields. */
.data-table th.rate-col,
.data-table td.rate-cell {
    width: 86px;
    min-width: 78px;
    max-width: 98px;
    text-align: center;
}
.data-table td.rate-cell input.rate,
.data-table td input.rate {
    min-width: 72px !important;
    width: 78px;
    max-width: 86px;
    padding-left: 8px;
    padding-right: 8px;
    text-align: right;
}
.data-table td input:not([readonly]):not([disabled]) {
    background: #fff;
    border-color: #b7cff7;
    box-shadow: inset 0 0 0 1px rgba(37,99,235,.08);
}
.data-table td input[readonly],
.data-table td input:disabled {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}
@media (max-width: 760px) {
    .data-table th.rate-col,
    .data-table td.rate-cell {
        width: 76px;
        min-width: 70px;
    }
    .data-table td.rate-cell input.rate,
    .data-table td input.rate {
        width: 70px;
        min-width: 66px !important;
        max-width: 74px;
    }
}

/* V1.1.31: move Excel import controls into monthly table header. */
.hidden-form {
    display: none !important;
}
.monthly-table-header {
    align-items: center;
    gap: 14px;
}
.monthly-table-header h2 {
    flex: 0 1 auto;
}
.table-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
    min-width: 0;
}
.inline-import-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}
.inline-file-input {
    width: min(420px, 34vw);
    min-width: 210px;
    min-height: 40px;
    padding: 7px 10px;
    background: #fff;
}
.table-card-actions .btn {
    white-space: nowrap;
}
.save-changes-btn {
    min-width: 132px;
}

@media (max-width: 980px) {
    .monthly-table-header {
        align-items: stretch;
    }
    .table-card-actions {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }
    .inline-import-actions {
        flex: 1 1 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
    }
    .inline-file-input {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 620px) {
    .monthly-table-header {
        gap: 10px;
    }
    .inline-import-actions {
        grid-template-columns: 1fr 1fr;
    }
    .inline-file-input {
        grid-column: 1 / -1;
        font-size: .84rem;
    }
    .table-card-actions .btn,
    .save-changes-btn {
        width: 100%;
        min-width: 0;
        min-height: 38px;
        padding: 8px 10px;
        font-size: .84rem;
    }
    .save-changes-btn {
        flex: 1 1 100%;
    }
}

/* V1.1.32: compact mobile filters, remove CSV flow, and normal-case headers. */
.data-table th,
.table-card th,
.card table th {
    text-transform: none !important;
    letter-spacing: 0 !important;
}
.data-table th {
    font-size: .8rem;
    line-height: 1.25;
}

@media (max-width: 620px) {
    .bonus-filter-row {
        display: grid !important;
        grid-template-columns: minmax(88px, .72fr) minmax(0, 1.28fr) !important;
        gap: 8px 10px !important;
        align-items: end !important;
        margin-bottom: 12px;
    }
    .bonus-filter-row .year-field {
        grid-column: 1;
        min-width: 0;
    }
    .bonus-filter-row .department-field {
        grid-column: 2;
        min-width: 0;
    }
    .bonus-filter-row .filter-actions {
        grid-column: 1 / -1;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }
    .bonus-filter-row input,
    .bonus-filter-row select {
        width: 100% !important;
        min-width: 0 !important;
        height: 42px;
        padding: 8px 12px;
        font-size: .95rem;
    }
    .bonus-filter-row .btn {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 38px;
        padding: 8px 10px;
        font-size: .84rem;
        border-radius: 12px;
    }
    .bonus-filter-row label {
        font-size: .8rem;
        margin-bottom: 4px;
    }
    .monthly-table-header {
        align-items: stretch;
    }
    .table-card-actions {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
        margin-left: 0;
    }
    .inline-import-actions {
        display: contents !important;
    }
    .inline-file-input {
        grid-column: 1 / -1;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 38px;
        font-size: .82rem;
        padding: 6px 8px;
    }
    .table-card-actions .btn,
    .save-changes-btn {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 38px;
        padding: 8px 6px;
        font-size: .78rem;
        border-radius: 12px;
        white-space: normal;
        line-height: 1.15;
    }
    .save-changes-btn {
        grid-column: auto !important;
    }
    .card.table-card {
        padding: 12px;
    }
    .data-table th,
    .data-table td {
        font-size: .78rem;
        padding: 9px 8px;
    }
}

@media (max-width: 380px) {
    .bonus-filter-row {
        grid-template-columns: minmax(82px, .68fr) minmax(0, 1.32fr) !important;
        gap: 7px;
    }
    .table-card-actions .btn,
    .save-changes-btn {
        font-size: .74rem;
    }
}

/* V1.1.33: dashboard mobile layout and no note-style text blocks. */
.dashboard-filter-row {
    display: grid;
    grid-template-columns: minmax(110px, 220px) minmax(190px, 280px) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
}
.dashboard-filter-row input,
.dashboard-filter-row select {
    width: 100%;
    min-width: 0;
}
.dashboard-filter-actions {
    align-self: end;
}
.dashboard-filter-actions .btn {
    min-width: 92px;
}
.chart-legend .legend-item em {
    display: none !important;
}
.card-header .subtext:empty {
    display: none !important;
}

@media (max-width: 620px) {
    .dashboard-filter-row {
        grid-template-columns: minmax(86px, .72fr) minmax(0, 1.28fr) !important;
        gap: 8px 10px !important;
        margin-bottom: 10px;
    }
    .dashboard-filter-row .year-field {
        grid-column: 1;
    }
    .dashboard-filter-row .department-field {
        grid-column: 2;
    }
    .dashboard-filter-row input,
    .dashboard-filter-row select {
        height: 40px;
        padding: 8px 10px;
        font-size: .92rem;
    }
    .dashboard-filter-row label {
        font-size: .8rem;
        margin-bottom: 4px;
    }
    .dashboard-filter-row .filter-actions {
        grid-column: 1 / -1;
        display: flex !important;
        justify-content: flex-end;
        width: 100%;
    }
    .dashboard-filter-row .btn {
        width: auto !important;
        min-width: 104px !important;
        min-height: 36px;
        padding: 8px 16px;
        font-size: .84rem;
        border-radius: 12px;
    }
    .quarter-card .card-header,
    .card .card-header {
        gap: 8px;
    }
    .chart-legend {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .chart-legend .legend-item {
        min-height: 38px;
        padding: 9px 10px;
    }
}

.auth-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .38);
    backdrop-filter: blur(3px);
}

.auth-confirm-dialog {
    width: min(94vw, 520px);
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 24px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
    padding: clamp(1.1rem, 3vw, 1.6rem);
    text-align: center;
}

.auth-confirm-dialog h2 {
    margin: 0 0 .65rem;
    color: var(--text);
    font-size: clamp(1.15rem, 3.5vw, 1.45rem);
    line-height: 1.25;
}

.auth-confirm-dialog p {
    margin: 0 0 1.2rem;
    color: var(--muted);
    line-height: 1.55;
}

.auth-confirm-actions {
    display: flex;
    justify-content: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.auth-confirm-actions .btn {
    min-width: min(100%, 180px);
}

@media (max-width: 520px) {
    .auth-confirm-dialog {
        border-radius: 20px;
    }

    .auth-confirm-actions {
        flex-direction: column;
    }

    .auth-confirm-actions .btn {
        width: 100%;
    }
}

/* V1.0.2F: responsive layout polish for TV / projector / large dashboards. */
.content,
.main,
.card,
.table-card,
.kpi-card,
.quarter-item,
.permission-group,
.role-edit-card {
    min-width: 0;
}
.content {
    width: 100%;
}
.table-responsive,
.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.table-responsive .data-table,
.table-wrap .data-table {
    margin: 0;
}
.data-table {
    font-variant-numeric: tabular-nums;
}
.data-table th,
.data-table td {
    line-height: 1.35;
}
.data-table td,
.data-table th,
.readonly-money,
.strong-money,
.num {
    overflow-wrap: normal;
}
.card-header,
.form-actions,
.filter-actions,
.table-card-actions,
.topbar-right {
    min-width: 0;
}
.card-header > div,
.card-header h2,
.topbar-title {
    min-width: 0;
}

@media (min-width: 1180px) {
    .content {
        max-width: min(1880px, calc(100vw - 28px));
        padding: clamp(18px, 1.45vw, 30px);
    }
    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
        gap: clamp(14px, 1vw, 20px);
    }
    .permission-groups {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    }
    .bonus-filter-row,
    .dashboard-filter-row {
        grid-template-columns: minmax(130px, 230px) minmax(230px, 340px) auto;
        gap: 14px;
    }
    .filter-row:not(.bonus-filter-row):not(.dashboard-filter-row) {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
        align-items: end;
        gap: 10px 12px;
    }
    .filter-row:not(.bonus-filter-row):not(.dashboard-filter-row) input,
    .filter-row:not(.bonus-filter-row):not(.dashboard-filter-row) select {
        width: 100%;
        min-width: 0;
    }
    .kpi-grid {
        gap: clamp(14px, 1vw, 20px);
    }
    .card,
    .auth-card {
        margin-bottom: clamp(18px, 1.2vw, 26px);
    }
}

@media (min-width: 1440px) {
    .sidebar {
        width: clamp(220px, 15vw, 270px);
        flex-basis: clamp(220px, 15vw, 270px);
    }
    .topbar {
        min-height: 66px;
    }
    .dashboard-kpis:not(.reference-kpis) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .reference-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .quarter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .chart-legend {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .chart-row {
        grid-template-columns: 58px minmax(0, 1fr) minmax(86px, auto);
    }
}

@media (min-width: 1680px) {
    html {
        font-size: 17px;
    }
    .content {
        max-width: min(2060px, calc(100vw - 32px));
    }
    .dashboard-kpis:not(.reference-kpis) {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    }
    .reference-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
    .dashboard-kpis .kpi-card {
        min-height: 118px;
        display: grid;
        align-content: center;
    }
    .kpi-card span {
        font-size: .9rem;
        line-height: 1.25;
    }
    .kpi-card strong {
        font-size: clamp(1.18rem, .55vw + .78rem, 1.48rem);
        line-height: 1.18;
        white-space: nowrap;
        overflow: visible;
        text-overflow: clip;
    }
    .monthly-achievement-table,
    .data-table {
        min-width: 0;
    }
    .monthly-achievement-table {
        table-layout: auto;
    }
    .chart-row {
        gap: 16px;
        padding: 14px 0;
    }
    .bar-track {
        height: 24px;
    }
    .bar-line {
        grid-template-columns: 106px minmax(0, 1fr);
    }
}

@media (min-width: 1920px) {
    html {
        font-size: 18px;
    }
    .content {
        max-width: min(2300px, calc(100vw - 40px));
        padding: clamp(24px, 1.35vw, 38px);
    }
    .sidebar {
        width: clamp(238px, 13vw, 296px);
        flex-basis: clamp(238px, 13vw, 296px);
    }
    .topbar {
        min-height: 74px;
        padding: 14px clamp(22px, 1.5vw, 36px);
    }
    .brand.brand-logo-only .brand-logo {
        width: min(190px, 88%);
        height: 78px;
        max-height: 78px;
    }
    .card,
    .auth-card {
        border-radius: 24px;
        padding: clamp(20px, 1.2vw, 30px);
    }
    .compact-card {
        padding: 18px;
    }
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.38rem;
    }
    .btn {
        min-height: 44px;
        padding: 10px 18px;
    }
    .btn.small {
        min-height: 38px;
        padding: 7px 13px;
    }
    input,
    select,
    textarea {
        min-height: 44px;
    }
    .data-table th,
    .data-table td {
        padding: 11px 12px;
        font-size: .92rem;
    }
    .data-table th {
        font-size: .84rem;
    }
    .status-pill {
        padding: 6px 12px;
        font-size: .82rem;
    }
    .quarter-grid {
        gap: 18px;
    }
    .quarter-item {
        min-height: 260px;
        padding: 18px;
    }
}

@media (min-width: 2560px) {
    html {
        font-size: 20px;
    }
    .content {
        max-width: min(2680px, calc(100vw - 56px));
    }
    .dashboard-kpis .kpi-card {
        min-height: 136px;
    }
    .kpi-card strong {
        font-size: clamp(1.18rem, .42vw + .82rem, 1.65rem);
    }
    .chart-row {
        grid-template-columns: 68px minmax(0, 1fr) minmax(110px, auto);
    }
    .bar-track {
        height: 28px;
    }
}

@media (min-width: 1600px) and (max-height: 980px) {
    .content {
        padding-top: 22px;
        padding-bottom: 22px;
    }
    .dashboard-kpis .kpi-card {
        min-height: 104px;
    }
    .quarter-item {
        min-height: 0;
    }
    .chart-row {
        padding: 10px 0;
    }
    .bar-track {
        height: 20px;
    }
}

@media (min-width: 1180px) and (max-width: 1679px) {
    .dashboard-kpis:not(.reference-kpis) {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .reference-kpis {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
    .quarter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1179px) {
    .content {
        max-width: 100%;
    }
    .table-wrap {
        overflow-x: auto;
    }
}

@media (max-width: 760px) {
    .table-responsive,
    .table-wrap {
        border-radius: 14px;
    }
    .data-table {
        min-width: 860px;
    }
    .department-table {
        min-width: 620px;
    }
    .monthly-achievement-table {
        min-width: 980px;
    }
}

/* V1.0.2G: monthly totals and unified table typography. */
.card.table-card,
.table-card .data-table,
.table-card .data-table th,
.table-card .data-table td,
.table-card .data-table input,
.table-card .data-table select,
.table-card .data-table .status-pill,
.table-card .table-card-actions,
.table-card .table-card-actions .btn,
.table-card .inline-file-input {
    font-size: .92rem;
    font-family: inherit;
}
.table-card .card-header h2 {
    font-size: 1.12rem;
    line-height: 1.28;
}
.table-card .data-table th {
    font-weight: 760;
    line-height: 1.25;
    color: #334155;
}
.table-card .data-table td {
    font-weight: 520;
}
.table-card .data-table td strong,
.table-card .data-table .strong-money,
.table-card .data-table .readonly-money,
.table-card .data-table .status-pill {
    font-size: inherit;
}
.table-card .data-table input,
.table-card .data-table select {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
}
.data-table tfoot td {
    background: #f8fafc;
    border-top: 2px solid #cbd5e1;
    border-bottom: 0;
    font-weight: 800;
}
.data-table tfoot .summary-total-row td:first-child {
    color: #0b2f5b;
}
.data-table tfoot .readonly-money,
.data-table tfoot .strong-money,
.data-table tfoot .total-rate {
    font-weight: 820;
}
.data-table tfoot .muted-total {
    text-align: center;
    color: #94a3b8;
    font-weight: 800;
}
.total-rate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    white-space: nowrap;
    color: #0f172a;
}
.monthly-achievement-table tfoot td {
    white-space: nowrap;
}

@media (min-width: 1680px) {
    .card.table-card,
    .table-card .data-table,
    .table-card .data-table th,
    .table-card .data-table td,
    .table-card .data-table input,
    .table-card .data-table select,
    .table-card .data-table .status-pill,
    .table-card .table-card-actions,
    .table-card .table-card-actions .btn,
    .table-card .inline-file-input {
        font-size: .9rem;
    }
    .table-card .card-header h2 {
        font-size: 1.1rem;
    }
}

@media (max-width: 620px) {
    .card.table-card,
    .table-card .data-table,
    .table-card .data-table th,
    .table-card .data-table td,
    .table-card .data-table input,
    .table-card .data-table select,
    .table-card .data-table .status-pill {
        font-size: .8rem;
    }
    .data-table tfoot td {
        padding-top: 10px;
        padding-bottom: 10px;
    }
}
