/* ═══════════════════════════════════════════════════════════════
   global.css — shared styles for all dashboard pages  v2
   Includes: skeleton loaders, date mode toggle, filter bar styles
   ═══════════════════════════════════════════════════════════════ */

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── BODY ── */
body {
    font-family: 'DM Sans', sans-serif;
    background: #f0f2f5;
    color: #1e2329;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ══════════════════════════════════════
   SKELETON LOADER
══════════════════════════════════════ */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

.skel {
    background: linear-gradient(90deg, #e8eaed 25%, #f5f6f8 50%, #e8eaed 75%);
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite ease-in-out;
    border-radius: 4px;
    display: inline-block;
}
.skel-th { height: 12px; margin: 2px 0; }
.skel-td { height: 11px; margin: 3px 0; }

.skel-table { width: 100%; border-collapse: collapse; }
.skel-table th,
.skel-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #eef0f3;
    border-right:  1px solid #eef0f3;
}
.skel-table thead th { background: #f0f2f5; }

/* Card skeleton (for dashboard charts) */
.skel-chart-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.skel-chart-title { height: 14px; width: 120px; }
.skel-chart-body  { height: 160px; width: 100%; border-radius: 8px; }

/* Row skeleton (for detail panels) */
.skel-row {
    height: 32px;
    width: 100%;
    border-radius: 4px;
    margin-bottom: 6px;
}

/* ══════════════════════════════════════
   DATE MODE TOGGLE BADGE
══════════════════════════════════════ */
#dateModeLabel {
    font-family: 'DM Mono', monospace;
    font-size: .7rem;
    white-space: nowrap;
    align-self: center;
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
    flex-shrink: 0;
}
#dateModeLabel.mode-completed {
    background: #eaf3fb;
    border-color: #a5cce8;
    color: #1a6ea8;
}
#dateModeLabel.mode-created {
    background: #fff3e0;
    border-color: #f5c87a;
    color: #b56d00;
}
#dateModeLabel:hover { opacity: .8; }

/* ══════════════════════════════════════
   DATE RANGE PICKER WRAP
══════════════════════════════════════ */
.date-range-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    position: relative;
}
.date-range-wrap input {
    font-family: 'DM Mono', monospace;
    font-size: .75rem;
    background: #f0f2f5;
    color: #374151;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 7px 32px 7px 10px;
    cursor: pointer;
    width: 241px;
    outline: none;
    transition: border-color .2s;
}
.date-range-wrap input:focus { border-color: #3a82b0; }
.date-icon {
    position: absolute;
    right: 9px;
    pointer-events: none;
    font-size: .8rem;
    color: #6b7280;
}

/* ══════════════════════════════════════
   TOPBAR
══════════════════════════════════════ */
.topbar {
    background: #ffffff;
    border-bottom: 1px solid #e1e4e8;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-dot { width: 9px; height: 9px; border-radius: 50%; background: #e85c4a; }
.topbar h1 {
    font-family: 'Syne', sans-serif;
    font-size: .98rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #1e2329;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn-back {
    background: #f0f2f5;
    border: 1px solid #e1e4e8;
    color: #6b7280;
    border-radius: 6px;
    padding: 7px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: .82rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    display: inline-block;
    white-space: nowrap;
}
.btn-back:hover { border-color: #3a82b0; color: #3a82b0; }

.btn-apply {
    background: #3a82b0;
    border: 1px solid #2f6e99;
    color: #fff;
    border-radius: 6px;
    padding: 7px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}
.btn-apply:hover { background: #2f6e99; }

/* ══════════════════════════════════════
   MULTI-SELECT DROPDOWN
══════════════════════════════════════ */
.ms-wrap { position: relative; }

.ms-btn {
    background: #f0f2f5;
    border: 1px solid #e1e4e8;
    color: #6b7280;
    border-radius: 6px;
    padding: 7px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: .82rem;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
}
.ms-btn:hover { border-color: #3a82b0; color: #3a82b0; }
.ms-btn.active { border-color: #3a82b0; color: #3a82b0; background: #eaf3fb; }

.ms-badge {
    background: #3a82b0;
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.4;
}

.ms-arrow { font-size: .65rem; transition: transform .2s; }
.ms-btn.open .ms-arrow { transform: rotate(180deg); }

.ms-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 170px;
    background: #ffffff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    z-index: 999;
    overflow: hidden;
}
.ms-panel.show { display: block; }
.ms-panel.align-right { left: auto; right: 0; }

.ms-search { padding: 8px 10px; border-bottom: 1px solid #f0f2f5; }
.ms-search input {
    width: 100%;
    border: 1px solid #e1e4e8;
    border-radius: 5px;
    padding: 5px 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: .78rem;
    color: #374151;
    background: #f9fafb;
    outline: none;
}
.ms-search input:focus { border-color: #3a82b0; }

.ms-list { max-height: 200px; overflow-y: auto; padding: 6px 0; }
.ms-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: .8rem;
    color: #374151;
    cursor: pointer;
    transition: background .15s;
}
.ms-list label:hover { background: #f0f6fb; }
.ms-list input[type="checkbox"] {
    accent-color: #3a82b0;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    cursor: pointer;
}

.ms-footer { display: flex; border-top: 1px solid #f0f2f5; }
.ms-footer button {
    flex: 1;
    padding: 7px 0;
    font-family: 'DM Sans', sans-serif;
    font-size: .75rem;
    cursor: pointer;
    border: none;
    background: #f9fafb;
    color: #6b7280;
    transition: background .15s, color .15s;
}
.ms-footer button:first-child { border-right: 1px solid #f0f2f5; }
.ms-footer button:hover { background: #eaf3fb; color: #3a82b0; }

/* ══════════════════════════════════════
   SHARED TABLE ELEMENTS
══════════════════════════════════════ */
.content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    min-height: 0;
}

.table-wrap {
    flex: 1;
    overflow: auto;
    border-radius: 10px;
    border: 1px solid #e1e4e8;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    position: relative;
}

/* ── Region Row ── */
.region-row td {
    background: #f5f7fa;
    font-family: 'Syne', sans-serif;
    font-size: .78rem;
    font-weight: 700;
    color: #374151;
    letter-spacing: .02em;
    border-bottom: 1px solid #dde1e7;
    padding: 7px 12px;
}

/* ── Toggle Button ── */
.toggle-btn {
    background: none;
    border: 1px solid #ccd0d6;
    border-radius: 3px;
    font-size: .7rem;
    color: #6b7280;
    cursor: pointer;
    padding: 1px 5px;
    margin-right: 6px;
    transition: all .15s;
    font-family: monospace;
}
.toggle-btn:hover { border-color: #3a82b0; color: #3a82b0; }

/* ── Branch Row ── */
.branch-row:hover td { background: #fafbff; }
.branch-row td:first-child { padding-left: 28px; }

/* ── Grand Total Row ── */
.grand-total-row td {
    background: #eef2f7;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    font-size: .79rem;
    border-top: 2px solid #cdd2da;
    color: #1e2329;
    position: sticky;
    bottom: 0;
}

/* ══════════════════════════════════════
   SHARED DETAIL SUB-ROW
══════════════════════════════════════ */
.detail-row td { padding: 0 !important; background: #f8faff; border: none; }
.detail-inner { overflow: hidden; transition: max-height 0.35s ease; max-height: 0; }
.detail-inner.open { max-height: 560px; }

.detail-panel { padding: 10px 16px 14px 40px; border-bottom: 2px solid #3a82b0; }
.detail-panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-panel-title {
    font-family: 'Syne', sans-serif;
    font-size: .78rem;
    font-weight: 700;
    color: #3a82b0;
}

.detail-filter-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.dfilter-btn {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    border: 1px solid #e1e4e8;
    background: #f0f2f5;
    color: #6b7280;
    transition: all .15s;
    white-space: nowrap;
}
.dfilter-btn:hover { border-color: #3a82b0; color: #3a82b0; }
.dfilter-btn.active-all  { background: #eaf3fb; border-color: #3a82b0; color: #3a82b0; font-weight: 600; }
.dfilter-btn.active-yes  { background: #d4edda; border-color: #2e8b57; color: #1e7e34; font-weight: 600; }
.dfilter-btn.active-no   { background: #f8d7da; border-color: #c0392b; color: #c0392b; font-weight: 600; }
.dfilter-btn.active-miss { background: #f8d7da; border-color: #c0392b; color: #c0392b; font-weight: 600; }

.detail-loading {
    font-size: .75rem;
    color: #9ca3af;
    font-family: 'DM Mono', monospace;
    padding: 8px 0;
}
.detail-count { font-size: .7rem; color: #9ca3af; font-family: 'DM Mono', monospace; }

.detail-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.detail-sub-table { width: 100%; border-collapse: collapse; font-size: .73rem; }
.detail-sub-table th {
    background: #eef2f7;
    padding: 5px 10px;
    font-size: .68rem;
    font-weight: 600;
    color: #6b7280;
    text-align: left;
    border-bottom: 1px solid #e1e4e8;
    white-space: nowrap;
    font-family: 'DM Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: .04em;
    position: sticky;
    top: 0;
    z-index: 5;
}
.detail-sub-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #f0f2f5;
    color: #374151;
    font-family: 'DM Mono', monospace;
    font-size: .72rem;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.detail-sub-table tr:hover td { background: #f0f6fb; }

/* ══════════════════════════════════════
   KPI PAGE — specific
══════════════════════════════════════ */
.tab-bar {
    background: #ffffff;
    border-bottom: 2px solid #e1e4e8;
    padding: 0 24px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.tab-btn {
    padding: 10px 22px;
    font-family: 'Syne', sans-serif;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .04em;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 7px;
}
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: #1e2329; border-bottom-color: #3a82b0; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; }

.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; min-height: 0; }
.tab-content.active { display: flex; }

/* KPI Table */
.kpi-table { width: 100%; border-collapse: collapse; font-family: 'DM Mono', monospace; font-size: .79rem; }
.kpi-table thead tr { background: #d4edda; position: sticky; top: 0; z-index: 10; }
.kpi-table th {
    padding: 10px 14px;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: .78rem;
    font-weight: 600;
    color: #1e2329;
    border: 1px solid #b8dfc5;
    white-space: nowrap;
}
.kpi-table th:first-child,
.kpi-table th:nth-child(2) { text-align: left; }
.kpi-table th.achiev-header { background: #ffe066; color: #7a5a00; border-color: #e5c800; }
.kpi-table td { padding: 7px 14px; border: 1px solid #eef0f3; color: #374151; vertical-align: middle; }
.kpi-table td.num-cell { text-align: center; }
.kpi-table td.achiev-cell { text-align: center; font-weight: 500; }

.clickable-cell { cursor: pointer; text-decoration: underline dotted; transition: color .15s; }
.clickable-cell:hover { color: #3a82b0 !important; }
td.no-val.clickable-cell:hover { color: #c0392b !important; }

.no-val       { color: #c0392b; font-weight: 600; }
.below-target { color: #c0392b; font-weight: 600; }
.on-target    { color: #1e7e34; }
.achiev-cell:not(.below-target) { color: #1e7e34; }
.kpi-val-yes  { color: #1e7e34; font-weight: 600; }
.kpi-val-no   { color: #c0392b; font-weight: 600; }

/* KPI Info Bar */
.kpi-info-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.kpi-info-title {
    font-family: 'Syne', sans-serif;
    font-size: .9rem;
    font-weight: 800;
    color: #1e2329;
    display: flex;
    align-items: center;
    gap: 8px;
}
.kpi-target-badge {
    background: #fff3e0;
    border: 1px solid #f5c87a;
    border-radius: 5px;
    padding: 3px 10px;
    font-family: 'DM Mono', monospace;
    font-size: .74rem;
    color: #b56d00;
}
.kpi-total-badge {
    background: #eaf3fb;
    border: 1px solid #a5cce8;
    border-radius: 5px;
    padding: 3px 10px;
    font-family: 'DM Mono', monospace;
    font-size: .74rem;
    color: #1a6ea8;
}
.kpi-achiev-badge {
    border-radius: 5px;
    padding: 3px 10px;
    font-family: 'DM Mono', monospace;
    font-size: .74rem;
    font-weight: 600;
}
.kpi-achiev-badge.good { background: #d4edda; color: #155724; border: 1px solid #a3d4ad; }
.kpi-achiev-badge.bad  { background: #f8d7da; color: #721c24; border: 1px solid #f1aeb5; }

/* ══════════════════════════════════════
   DASHBOARD PAGE — specific
══════════════════════════════════════ */
.ho-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #f0f2f5;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: .82rem;
    color: #6b7280;
    transition: all .2s;
    user-select: none;
}
.ho-toggle:hover { border-color: #3a82b0; color: #3a82b0; }
.ho-toggle.active { background: #fff3e0; border-color: #e8943a; color: #c46a10; font-weight: 500; }
.ho-toggle input[type="checkbox"] { accent-color: #e8943a; width: 14px; height: 14px; cursor: pointer; }

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 14px;
    padding: 14px 24px;
    flex: 1;
    min-height: 0;
}
.chart-card {
    background: #ffffff;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.chart-title {
    font-family: 'Syne', sans-serif;
    font-size: .85rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 7px;
}
.chart-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chart-meta { font-size: .7rem; color: #9ca3af; font-family: 'DM Mono', monospace; }
.chart-body { flex: 1; position: relative; min-height: 0; }

/* ══════════════════════════════════════
   STATUS UPDATE PAGE — specific
══════════════════════════════════════ */
.su-content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 14px 24px 16px;
    min-height: 0;
}

.info-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.info-bar-title {
    font-family: 'Syne', sans-serif;
    font-size: .9rem;
    font-weight: 800;
    color: #1e2329;
    display: flex;
    align-items: center;
    gap: 8px;
}
.badge-pill { border-radius: 5px; padding: 3px 10px; font-family: 'DM Mono', monospace; font-size: .74rem; }
.badge-neutral { background: #eaf3fb; border: 1px solid #a5cce8; color: #1a6ea8; }
.badge-good    { background: #d4edda; border: 1px solid #a3d4ad; color: #155724; font-weight: 600; }
.badge-warn    { background: #fff3e0; border: 1px solid #f5c87a; color: #b56d00; font-weight: 600; }
.badge-bad     { background: #f8d7da; border: 1px solid #f1aeb5; color: #721c24; font-weight: 600; }

/* Status Update Table */
.su-table { width: 100%; border-collapse: collapse; font-family: 'DM Mono', monospace; font-size: .79rem; }
.su-table thead tr { background: #d4edda; position: sticky; top: 0; z-index: 10; }
.su-table th {
    padding: 10px 12px;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: .75rem;
    font-weight: 600;
    color: #1e2329;
    border: 1px solid #b8dfc5;
    white-space: nowrap;
}
.su-table th.left-th { text-align: left; }
.su-table th.pct-header      { background: #ffe066; color: #7a5a00; border-color: #e5c800; }
.su-table th.pct-prev-header { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.su-table td { padding: 7px 12px; border: 1px solid #eef0f3; color: #374151; vertical-align: middle; }
.su-table td.ctr { text-align: center; }

.miss-cell {
    color: #c0392b;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline dotted;
    transition: color .15s;
    white-space: nowrap;
}
.miss-cell:hover { color: #e74c3c; }
.ok-num { color: #2e8b57; }

.pct-wrap { min-width: 120px; }
.pct-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.pct-num { font-family: 'DM Mono', monospace; font-size: .78rem; font-weight: 600; }
.pct-num.good   { color: #1e7e34; }
.pct-num.warn   { color: #b56d00; }
.pct-num.danger { color: #c0392b; }
.pct-bar-bg { width: 100%; height: 5px; background: #e5e7eb; border-radius: 10px; overflow: hidden; }
.pct-bar-fill { height: 100%; border-radius: 10px; transition: width .5s ease; }
.pct-bar-fill.good   { background: #2e8b57; }
.pct-bar-fill.warn   { background: #e8a020; }
.pct-bar-fill.danger { background: #c0392b; }

.prev-num { font-family: 'DM Mono', monospace; font-size: .78rem; }
.prev-num.good   { color: #2e8b57; }
.prev-num.warn   { color: #b56d00; }
.prev-num.danger { color: #c0392b; }
.trend-badge { font-size: .68rem; font-family: 'DM Mono', monospace; margin-left: 3px; }
.trend-up   { color: #2e8b57; }
.trend-down { color: #c0392b; }

.miss-val { color: #c0392b; font-weight: 600; }
.ok-val   { color: #2e8b57; }