/* ============================================================
   Dashboard Đảng uỷ Phường An Lạc — Light NOC Theme
   Nền trắng, hiện đại; lưới vừa khít 1 màn hình TV/NOC 16:9–21:10
   ============================================================ */

:root {
    --bg: #eef2f8;
    --bg-soft: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e6eaf2;
    --border-strong: #d4dae6;
    --text: #0f1b33;
    --text-dim: #5a6b89;
    --text-faint: #8b99b4;

    --c-red: #e5384f;     --c-red-bg: #fff0f2;     --c-red-ring: rgba(229,56,79,.18);
    --c-emerald: #0b9d6e; --c-emerald-bg: #e9faf3; --c-emerald-ring: rgba(11,157,110,.16);
    --c-sky: #2480e8;     --c-sky-bg: #eaf3ff;     --c-sky-ring: rgba(36,128,232,.16);
    --c-amber: #e08600;   --c-amber-bg: #fff6e6;   --c-amber-ring: rgba(224,134,0,.18);
    --c-violet: #7a52e0;  --c-violet-bg: #f3eeff;  --c-violet-ring: rgba(122,82,224,.16);
    --c-gold: #c98a00;

    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(16,27,51,.05), 0 1px 3px rgba(16,27,51,.04);
    --shadow: 0 6px 20px -6px rgba(16,27,51,.12), 0 2px 6px -2px rgba(16,27,51,.06);
    --shadow-lg: 0 18px 44px -16px rgba(16,27,51,.22);

    --chrome-h: 124px; /* header + tab bar, dùng để fit 1 màn hình */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    font-feature-settings: "tnum" 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}
main { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.cc-header, .tab-bar, footer { flex: 0 0 auto; }

.bg-atmosphere {
    position: fixed; inset: 0; z-index: -2;
    background:
        radial-gradient(900px 500px at 88% -6%, #e8f0ff 0%, transparent 55%),
        radial-gradient(800px 480px at 5% 4%, #f3eeff 0%, transparent 55%),
        var(--bg);
}
.bg-grid {
    position: fixed; inset: 0; z-index: -1;
    background-image:
        linear-gradient(rgba(120,140,180,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(120,140,180,.05) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 100% 70% at 50% 25%, #000 35%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 100% 70% at 50% 25%, #000 35%, transparent 100%);
}

.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---- Header ---- */
.cc-header {
    z-index: 50;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid var(--border);
}
.emblem {
    width: 50px; height: 50px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #d81f37, #a30f22);
    box-shadow: 0 6px 16px -4px var(--c-red-ring);
    color: #ffe082; flex-shrink: 0;
}
.emblem svg { width: 28px; height: 28px; }

.clock-time {
    font-variant-numeric: tabular-nums; font-weight: 800;
    letter-spacing: .02em; color: var(--text); line-height: 1;
}
.btn-ghost {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-dim);
    border-radius: 11px; font-weight: 600; cursor: pointer;
    transition: all .18s; box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--c-sky); }
.btn-ghost svg { width: 18px; height: 18px; }

.period-select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 11px; font-weight: 600; cursor: pointer; outline: none;
    box-shadow: var(--shadow-sm);
}

/* ---- Ticker ---- */
.ticker-wrap {
    background: linear-gradient(90deg, #fff7e0, #fffaf0);
    border-top: 1px solid #f2e2b8;
    overflow: hidden; white-space: nowrap;
}
.ticker-content {
    display: inline-block; padding-left: 100%;
    color: var(--c-gold); font-weight: 600;
    animation: tickerScroll 48s linear infinite;
}
@keyframes tickerScroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---- Tabs ---- */
.tab-bar {
    z-index: 40;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.tab-btn {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 13px 20px; font-weight: 600; color: var(--text-faint);
    border: none; background: transparent; cursor: pointer;
    position: relative; transition: color .18s; white-space: nowrap;
}
.tab-btn svg { width: 19px; height: 19px; }
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.tab-active { color: var(--c-sky); }
.tab-btn.tab-active::after {
    content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px;
    border-radius: 3px 3px 0 0; background: var(--c-sky);
}

/* ---- Tab content ---- */
.tab-content { display: none; animation: fadeUp .45s ease both; }
.tab-content.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   NOC GRID — vừa khít 1 màn hình cho tab Tổng quan
   ========================================================= */
.noc-grid {
    display: grid;
    gap: clamp(10px, 0.9vw, 16px);
    grid-template-columns: 1.5fr 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "kpis kpis"
        "main side";
    height: 100%;
    overflow: hidden;
}
.noc-kpis {
    grid-area: kpis;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(12px, 1.1vw, 20px);
}
.noc-table { grid-area: main; }
.noc-mid {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 0.9vw, 16px);
    min-height: 0;
}
.noc-mid .noc-progress { flex: 0 0 auto; }
.noc-mid .noc-insights { flex: 1 1 auto; }
.noc-progress, .noc-insights { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.noc-insights .insight-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.noc-table { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.noc-table > div:last-child { flex: 1; overflow: auto; }

/* Trên cửa sổ thấp: cho phép cuộn mềm, bỏ khoá chiều cao */
@media (max-height: 720px) { body { height: auto; overflow: auto; } main { overflow: visible; } .noc-grid { height: auto; overflow: visible; } }

/* ---- KPI cards ---- */
.kpi {
    position: relative; border-radius: var(--radius);
    padding: clamp(14px, 1.1vw, 20px);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow); overflow: hidden;
    display: flex; flex-direction: column; justify-content: center;
    animation: kpiIn .55s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes kpiIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.kpi::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent);
}
.kpi-ico {
    width: clamp(40px, 2.4vw, 46px); height: clamp(40px, 2.4vw, 46px);
    display: grid; place-items: center; border-radius: 12px;
    background: var(--accent-bg); color: var(--accent);
    margin-bottom: clamp(6px, .6vw, 10px);
}
.kpi-ico svg { width: 56%; height: 56%; }
.kpi-value {
    font-size: clamp(2rem, 2.9vw, 3.1rem);
    font-weight: 800; line-height: 1; letter-spacing: -.025em;
    font-variant-numeric: tabular-nums; color: var(--text);
}
.kpi-value .unit { font-size: .4em; font-weight: 600; color: var(--text-faint); margin-left: 6px; }
.kpi-label { color: var(--text-dim); font-weight: 600; margin-top: 8px; font-size: clamp(.85rem, 1vw, 1.05rem); }
.kpi-sub {
    margin-top: clamp(8px, .9vw, 14px);
    display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
    background: var(--accent-bg); color: var(--accent);
    border-radius: 9px; padding: 6px 11px;
    font-size: clamp(.72rem, .85vw, .88rem); font-weight: 600;
}
.kpi-sub svg { width: 14px; height: 14px; }

.accent-red    { --accent: var(--c-red);     --accent-bg: var(--c-red-bg);     --accent-ring: var(--c-red-ring); }
.accent-emerald{ --accent: var(--c-emerald); --accent-bg: var(--c-emerald-bg); --accent-ring: var(--c-emerald-ring); }
.accent-sky    { --accent: var(--c-sky);     --accent-bg: var(--c-sky-bg);     --accent-ring: var(--c-sky-ring); }
.accent-amber  { --accent: var(--c-amber);   --accent-bg: var(--c-amber-bg);   --accent-ring: var(--c-amber-ring); }
.accent-violet { --accent: var(--c-violet);  --accent-bg: var(--c-violet-bg);  --accent-ring: var(--c-violet-ring); }

/* ---- Panel ---- */
.panel { padding: clamp(16px, 1.5vw, 26px); }
.panel-title {
    display: flex; align-items: center; gap: 10px;
    font-size: clamp(1rem, 1.3vw, 1.35rem); font-weight: 700; color: var(--text);
    margin: 0 0 clamp(10px, 1vw, 16px); letter-spacing: -.01em;
}
.panel-title svg { width: 22px; height: 22px; color: var(--c-sky); }
.panel-title .sub { color: var(--text-faint); font-weight: 500; font-size: .72em; }

/* ---- Progress ---- */
.noc-progress { overflow: hidden; }
.noc-progress .prog-row { flex: 0 0 auto; }
.prog-row + .prog-row { margin-top: clamp(10px, 1.1vw, 16px); }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.prog-label { font-weight: 600; color: var(--text); font-size: clamp(.9rem,1vw,1.05rem); }
.prog-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: clamp(.9rem,1vw,1.05rem); }
.prog-track { height: 11px; border-radius: 99px; background: #eef1f6; overflow: hidden; position: relative; }
.prog-fill {
    height: 100%; border-radius: 99px; background: var(--accent);
    width: 0; transition: width 1.4s cubic-bezier(.2,.8,.2,1); position: relative;
}
.prog-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
    animation: shimmer 2.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(220%); } }
.prog-pct { font-size: .82rem; color: var(--text-faint); margin-top: 5px; font-weight: 500; }

/* ---- Insights ---- */
.insight {
    border-radius: var(--radius-sm); padding: 15px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-left: 4px solid var(--accent, var(--c-sky));
    display: flex; gap: 13px; transition: transform .18s, box-shadow .18s;
}
.insight:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.insight-ico {
    width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 10px; background: var(--accent-bg, var(--c-sky-bg)); color: var(--accent, var(--c-sky));
}
.insight-ico svg { width: 21px; height: 21px; }
.insight-title { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.insight-body { color: var(--text-dim); font-size: .92rem; margin-top: 4px; line-height: 1.5; white-space: pre-line; }
.badge { font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 4px; }
.badge svg { width: 12px; height: 12px; }
.badge-ai { background: var(--c-violet-bg); color: var(--c-violet); }

/* ---- Table ---- */
.cc-table { width: 100%; border-collapse: collapse; }
.cc-table th {
    text-align: left; padding: 11px 16px; color: var(--text-faint); font-weight: 600;
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 2px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
.cc-table th.num, .cc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cc-table th.cur { color: var(--c-sky); }
.cc-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 1rem; }
.cc-table tbody tr:hover { background: var(--surface-2); }
.cc-table td.cur { font-weight: 700; color: var(--text); background: var(--c-sky-bg); }
.delta-up { color: var(--c-emerald); font-weight: 700; }
.delta-down { color: var(--c-red); font-weight: 700; }
.delta-flat { color: var(--text-faint); font-weight: 600; }

/* ---- Detail metric cards (other tabs) ---- */
.metric {
    border-radius: var(--radius-sm); padding: 17px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    transition: transform .18s, box-shadow .18s;
}
.metric:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.metric-name { font-size: .82rem; color: var(--text-faint); font-weight: 600; margin-bottom: 8px; min-height: 2.4em; }
.metric-value { font-size: clamp(1.5rem, 2vw, 2.1rem); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric-value .unit { font-size: .5em; color: var(--text-faint); font-weight: 600; margin-left: 5px; }
.metric-change { font-size: .78rem; margin-top: 7px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.metric-change svg { width: 13px; height: 13px; }
.metric-target { margin-top: 12px; }
.metric-target .lbl { font-size: .72rem; color: var(--text-faint); }
.metric-mini-track { height: 6px; border-radius: 99px; background: #eef1f6; margin-top: 5px; overflow: hidden; }
.metric-mini-fill { height: 100%; border-radius: 99px; background: var(--c-sky); }

/* ---- Footer ---- */
.live-pill { display: none; }

/* ---- Flash on update ---- */
.flash-update { animation: flashUp 1.2s ease; }
@keyframes flashUp { 0% { background: var(--c-sky-bg); } 100% { background: transparent; } }

/* ---- Presentation / TV mode ---- */
body.tv-mode .cc-header, body.tv-mode .tab-bar, body.tv-mode footer { display: none; }
body.tv-mode .tv-hide { display: none !important; }
body.tv-mode main { padding-top: 76px !important; padding-bottom: 16px !important; }
body.tv-mode { cursor: none; }
body.tv-mode .noc-grid { height: 100%; }

.tv-bar {
    display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 60;
    padding: 14px 34px; align-items: center; justify-content: space-between;
    background: rgba(255,255,255,.92); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
body.tv-mode .tv-bar { display: flex; }
.tv-bar .tv-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.tv-bar .tv-clock { font-size: 1.4rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.tv-rotation {
    position: fixed; bottom: 0; left: 0; height: 4px; z-index: 60;
    background: var(--c-sky); width: 0; display: none;
}
body.tv-mode .tv-rotation { display: block; }
body.tv-mode .kpi-value { font-size: clamp(3rem, 5vw, 6rem); }

/* scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd5e3; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #b3bdd0; }

.container { width: 100%; max-width: 2200px; margin: 0 auto; padding-left: clamp(16px, 2vw, 36px); padding-right: clamp(16px, 2vw, 36px); }
