/* ============ CPVN PROJECT TRACKER — design system ============ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root{
  --blue:#3b82f6;--green:#22c55e;--amber:#f59e0b;--red:#ef4444;--purple:#a855f7;--cyan:#06b6d4;--orange:#f97316;
  --radius:9px;--radius-lg:13px;--radius-sm:6px;
  --font:'IBM Plex Sans Thai','IBM Plex Sans',system-ui,sans-serif;
  --mono:'IBM Plex Mono',ui-monospace,monospace;
  --sidebar-w:248px;
  --shadow-sm:0 1px 2px rgba(0,0,0,.06);
  --shadow:0 4px 16px rgba(8,12,20,.10);
  --shadow-lg:0 18px 48px rgba(8,12,20,.20);
}
/* ----- DARK (default) ----- */
[data-theme=dark]{
  --bg:#0c0f15;--surface:#141922;--surface2:#1b212c;--surface3:#222a37;--surface4:#2b3543;
  --border:#252e3c;--border2:#36425440;--border-strong:#3a465a;
  --text:#e9edf2;--text2:#a6b6c8;--muted:#7f8fa1;--faint:#5a6678;
  --shadow:0 8px 28px rgba(0,0,0,.40);--shadow-lg:0 24px 60px rgba(0,0,0,.55);
  --tint:.17;--tint2:.10;
  color-scheme:dark;
}
/* ----- LIGHT ----- */
[data-theme=light]{
  --bg:#eef1f5;--surface:#ffffff;--surface2:#f6f8fa;--surface3:#eef1f5;--surface4:#e4e9ef;
  --border:#e3e8ee;--border2:#dfe5ec;--border-strong:#cdd6e0;
  --text:#16202e;--text2:#445166;--muted:#697789;--faint:#9aa6b4;
  --shadow:0 6px 22px rgba(20,30,48,.08);--shadow-lg:0 22px 54px rgba(20,30,48,.14);
  --tint:.13;--tint2:.08;
  color-scheme:light;
}

html,body{height:100%}
body{background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px;line-height:1.5;
  -webkit-font-smoothing:antialiased;transition:background .3s,color .3s}
button{font-family:inherit}
::selection{background:rgba(59,130,246,.3)}
/* scrollbars */
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:6px;border:2px solid transparent;background-clip:padding-box}
*::-webkit-scrollbar-thumb:hover{background:var(--muted);background-clip:padding-box}

/* ============ APP SHELL ============ */
.app{display:grid;grid-template-columns:var(--sidebar-w) 1fr;min-height:100vh}

/* ----- SIDEBAR ----- */
.sidebar{background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;
  position:sticky;top:0;height:100vh;overflow:hidden}
.brand{display:flex;align-items:center;gap:11px;padding:18px 18px 16px}
.brand-mark{width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,var(--blue),#2563eb);
  display:grid;place-items:center;color:#fff;font-weight:700;font-size:15px;flex-shrink:0;box-shadow:0 4px 12px rgba(59,130,246,.35)}
.brand-text{line-height:1.15}
.brand-text b{font-size:14.5px;font-weight:600;letter-spacing:-.2px;display:block}
.brand-text span{font-size:11px;color:var(--muted);font-family:var(--mono)}
.nav-scroll{flex:1;overflow-y:auto;padding:4px 12px 12px}
.nav-label{font-size:10.5px;font-weight:600;color:var(--faint);text-transform:uppercase;letter-spacing:.7px;padding:14px 10px 7px}
.nav-item{display:flex;align-items:center;gap:11px;padding:9px 11px;border-radius:var(--radius);color:var(--text2);
  font-size:13.5px;font-weight:500;cursor:pointer;transition:background .14s,color .14s;position:relative;border:1px solid transparent}
.nav-item:hover{background:var(--surface2);color:var(--text)}
.nav-item.active{background:var(--surface3);color:var(--text);border-color:var(--border)}
.nav-item.active .nav-ic{color:var(--accent,var(--blue))}
.nav-ic{width:18px;height:18px;flex-shrink:0;color:var(--muted);display:grid;place-items:center}
.nav-item .dot{width:9px;height:9px;border-radius:50%;flex-shrink:0}
.nav-count{margin-left:auto;font-size:11px;color:var(--muted);background:var(--surface3);
  padding:1px 8px;border-radius:20px;font-family:var(--mono);min-width:24px;text-align:center}
.nav-item.active .nav-count{background:var(--surface4)}
.nav-sub{padding-left:8px}
.sidebar-foot{border-top:1px solid var(--border);padding:11px 14px;display:flex;flex-direction:column;gap:8px}

/* ----- MAIN ----- */
.main{display:flex;flex-direction:column;min-width:0;min-height:100vh}
.topbar{height:60px;border-bottom:1px solid var(--border);background:color-mix(in srgb,var(--surface) 80%,transparent);
  backdrop-filter:blur(10px);position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:16px;padding:0 26px}
.crumb{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted);min-width:0}
.crumb b{color:var(--text);font-weight:600;font-size:15px;letter-spacing:-.2px}
.crumb .sep{color:var(--faint)}
.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:9px}

/* ---- Firebase sync status indicator ---- */
.sync-status{display:flex;align-items:center;gap:5px;padding:5px 10px;border-radius:20px;border:1px solid var(--border);background:var(--surface2);cursor:pointer;font-size:12px;font-family:var(--font);color:var(--text2);transition:all .2s;white-space:nowrap}
.sync-status:hover{border-color:var(--border-strong);background:var(--surface3)}
.ss-icon{font-size:14px;line-height:1}
.ss-label{font-size:11.5px}
.ss-ok{border-color:rgba(34,197,94,.3);color:var(--green)}
.ss-ok .ss-icon{animation:none}
.ss-syncing .ss-icon{display:inline-block;animation:spin .8s linear infinite}
.ss-error{border-color:rgba(239,68,68,.3);color:var(--red)}
.ss-offline{border-color:var(--border);color:var(--muted)}
.ss-config{border-color:rgba(245,158,11,.3);color:var(--amber)}
.auth-off{border-color:rgba(127,143,161,.35);color:var(--muted)}
.auth-on{border-color:rgba(34,197,94,.4);color:var(--green);background:rgba(34,197,94,.08)}
@keyframes spin{to{transform:rotate(360deg)}}
.content{flex:1;padding:24px 26px 44px;max-width:1480px;width:100%}
.page{display:none}
.page.active{display:block}

/* ----- PILL TABS (sub-nav) ----- */
.subtabs{display:flex;gap:3px;background:var(--surface2);padding:4px;border-radius:11px;border:1px solid var(--border);
  margin-bottom:22px;width:fit-content;max-width:100%;overflow-x:auto;flex-wrap:nowrap}
.subtab{padding:7px 15px;border-radius:8px;font-size:13px;font-weight:500;color:var(--text2);cursor:pointer;
  white-space:nowrap;transition:all .15s;border:none;background:transparent;display:flex;align-items:center;gap:7px}
.subtab:hover{color:var(--text)}
.subtab.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm);font-weight:600}

/* ============ BUTTONS ============ */
.btn{background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);
  padding:8px 14px;font-size:13px;font-weight:500;cursor:pointer;transition:all .15s;display:inline-flex;
  align-items:center;gap:7px;white-space:nowrap;line-height:1}
.btn:hover{border-color:var(--border-strong);background:var(--surface3)}
.btn:active{transform:translateY(.5px)}
.btn svg{width:15px;height:15px}
.btn-primary{background:var(--blue);border-color:var(--blue);color:#fff;box-shadow:0 3px 10px rgba(59,130,246,.32)}
.btn-primary:hover{background:#2f74e6;border-color:#2f74e6}
.btn-ghost{background:transparent;border-color:transparent}
.btn-ghost:hover{background:var(--surface2)}
.btn-sm{padding:5px 10px;font-size:12px}
.btn-icon{padding:8px;border-radius:var(--radius)}
.btn-icon svg{width:16px;height:16px}
.btn-danger:hover{border-color:var(--red);color:var(--red)}
.icon-toggle{display:inline-flex;background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:3px}
.icon-toggle button{border:none;background:transparent;color:var(--muted);padding:6px 8px;border-radius:6px;cursor:pointer;display:grid;place-items:center}
.icon-toggle button.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm)}
.icon-toggle button svg{width:16px;height:16px}

/* ============ CARDS / STATS ============ */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg)}
.section-head{display:flex;align-items:center;gap:12px;margin:0 0 14px}
.section-head h2{font-size:16px;font-weight:600;letter-spacing:-.2px}
.section-head .hint{font-size:12.5px;color:var(--muted)}
.section-head .right{margin-left:auto;display:flex;gap:8px;align-items:center}

.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(165px,1fr));gap:13px;margin-bottom:22px}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:16px 17px;position:relative;overflow:hidden}
.stat .accent{position:absolute;left:0;top:0;bottom:0;width:3px;border-radius:3px}
.stat-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:11px}
.stat-label{font-size:11.5px;font-weight:500;color:var(--muted);letter-spacing:.2px}
.stat-ic{width:30px;height:30px;border-radius:8px;display:grid;place-items:center}
.stat-ic svg{width:16px;height:16px}
.stat-val{font-size:30px;font-weight:680;line-height:1;letter-spacing:-1px;font-feature-settings:'tnum'}
.stat-sub{font-size:11.5px;color:var(--faint);margin-top:6px}

/* ============ CHARTS ============ */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-bottom:16px}
.chart-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:18px 18px 16px}
.chart-card h3{font-size:13.5px;font-weight:600;margin-bottom:3px}
.chart-card .sub{font-size:11.5px;color:var(--muted);margin-bottom:14px}
.chart-wrap{position:relative;height:230px}

/* progress ring + bar */
.prog-bar{height:8px;background:var(--surface3);border-radius:5px;overflow:hidden;margin-top:9px}
.prog-fill{height:100%;border-radius:5px;transition:width .6s cubic-bezier(.4,0,.2,1);background:var(--green)}
.big-prog{display:flex;align-items:center;gap:22px}
.ring{position:relative;width:128px;height:128px;flex-shrink:0}
.ring svg{transform:rotate(-90deg)}
.ring-txt{position:absolute;inset:0;display:grid;place-content:center;text-align:center}
.ring-txt b{font-size:30px;font-weight:680;letter-spacing:-1px;line-height:1}
.ring-txt span{font-size:11px;color:var(--muted)}

/* ============ SYSTEM CARDS (home) ============ */
.sys-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:16px}
.sys-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:20px;
  cursor:pointer;transition:transform .18s,box-shadow .18s,border-color .18s;position:relative;overflow:hidden;text-align:left;width:100%;color:inherit}
.sys-card:hover{transform:translateY(-3px);box-shadow:var(--shadow-lg);border-color:var(--border-strong)}
.sys-card .glow{position:absolute;top:-40px;right:-40px;width:140px;height:140px;border-radius:50%;opacity:.16;filter:blur(8px)}
.sys-card-top{display:flex;align-items:center;gap:13px;margin-bottom:16px;position:relative}
.sys-emblem{width:46px;height:46px;border-radius:12px;display:grid;place-items:center;color:#fff;flex-shrink:0;box-shadow:var(--shadow)}
.sys-emblem svg{width:24px;height:24px}
.sys-card h3{font-size:17px;font-weight:600;letter-spacing:-.3px}
.sys-card .th{font-size:12px;color:var(--muted)}
.sys-card .desc{font-size:12.5px;color:var(--text2);line-height:1.55;margin-bottom:18px;min-height:38px}
.sys-stats{display:flex;gap:20px;margin-bottom:14px}
.sys-stat b{font-size:22px;font-weight:680;letter-spacing:-.5px;display:block;line-height:1}
.sys-stat span{font-size:11px;color:var(--muted)}
.sys-foot{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:var(--muted);
  border-top:1px solid var(--border);padding-top:13px}
.sys-foot .go{color:var(--accent);font-weight:600;display:flex;align-items:center;gap:5px}
.add-sys{border:1.5px dashed var(--border-strong);background:transparent;display:grid;place-items:center;min-height:230px;
  color:var(--muted);gap:10px;cursor:pointer;border-radius:var(--radius-lg);transition:all .18s;font-size:13.5px;font-weight:500}
.add-sys:hover{border-color:var(--blue);color:var(--blue);background:rgba(59,130,246,.04)}
.add-sys .plus{width:42px;height:42px;border-radius:50%;border:1.5px solid currentColor;display:grid;place-items:center;font-size:22px;font-weight:300}

/* ============ FILTER BAR ============ */
.toolbar{display:flex;gap:9px;margin-bottom:16px;flex-wrap:wrap;align-items:center}
.search{position:relative;flex:1;min-width:220px}
.search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--muted)}
.search input{width:100%;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  color:var(--text);padding:9px 12px 9px 36px;font-size:13.5px;font-family:inherit;outline:none;transition:border .15s}
.search input:focus{border-color:var(--blue)}
select.flt,input.flt{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);
  padding:9px 11px;font-size:13px;font-family:inherit;outline:none;cursor:pointer;transition:border .15s}
select.flt:focus,input.flt:focus{border-color:var(--blue)}
.count-tag{font-size:12.5px;color:var(--muted);margin-left:auto;white-space:nowrap;font-family:var(--mono)}
.fchips{display:flex;flex-wrap:wrap;gap:8px;margin:-4px 0 16px;align-items:center}
.fchip{display:inline-flex;align-items:center;gap:7px;padding:5px 6px 5px 11px;border-radius:20px;font-size:12px;
  background:color-mix(in srgb,var(--blue) 12%,var(--surface));border:1px solid color-mix(in srgb,var(--blue) 35%,var(--border));color:var(--text)}
.fchip b{font-weight:600}
.fchip button{border:none;background:transparent;color:var(--muted);cursor:pointer;display:grid;place-items:center;padding:2px;border-radius:50%;width:18px;height:18px}
.fchip button:hover{background:var(--surface3);color:var(--text)}
.fchip button svg{width:12px;height:12px}
.fchip-clear{border:none;background:transparent;color:var(--muted);font-size:12px;cursor:pointer;text-decoration:underline;font-family:inherit}
.fchip-clear:hover{color:var(--text)}
/* clickable dashboard cues */
.stat.clickable{cursor:pointer;transition:transform .15s,box-shadow .15s,border-color .15s}
.stat.clickable:hover{transform:translateY(-2px);box-shadow:var(--shadow);border-color:var(--border-strong)}
.chart-card .sub .hintclick{color:var(--blue);font-weight:500}

/* ============ TABLE ============ */
.table-wrap{overflow-x:auto;border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface)}
table{width:100%;border-collapse:collapse;font-size:13px}
th{background:var(--surface2);color:var(--muted);font-weight:600;padding:11px 14px;text-align:left;white-space:nowrap;
  border-bottom:1px solid var(--border);font-size:11.5px;text-transform:uppercase;letter-spacing:.4px;position:sticky;top:0}
td{padding:11px 14px;border-bottom:1px solid var(--border);vertical-align:middle}
tr:last-child td{border-bottom:none}
tbody tr{transition:background .12s;cursor:pointer}
tbody tr:hover td{background:var(--surface2)}
.cell-name{font-weight:550;color:var(--text);max-width:320px}
.cell-name .nm{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.35}
.cell-name small{display:block;font-size:11px;color:var(--faint);font-weight:400;margin-top:3px;font-family:var(--mono)}
.row-actions{display:flex;gap:3px;opacity:.55;transition:opacity .12s}
tr:hover .row-actions{opacity:1}

/* ============ BADGES ============ */
.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:7px;font-size:11px;font-weight:600;
  white-space:nowrap;line-height:1.4;letter-spacing:.1px}
.badge .bd{width:6px;height:6px;border-radius:50%;background:currentColor}
.b-blue{background:rgba(59,130,246,var(--tint));color:#5fa0ff}
.b-green{background:rgba(34,197,94,var(--tint));color:#3ddc7f}
.b-amber{background:rgba(245,158,11,var(--tint));color:#fbb03c}
.b-red{background:rgba(239,68,68,var(--tint));color:#ff6b6b}
.b-purple{background:rgba(168,85,247,var(--tint));color:#c084fc}
.b-cyan{background:rgba(6,182,212,var(--tint));color:#22d3ee}
.b-orange{background:rgba(249,115,22,var(--tint));color:#fb923c}
.b-gray{background:var(--surface3);color:var(--muted)}
[data-theme=light] .b-blue{color:#2563eb}[data-theme=light] .b-green{color:#15924c}
[data-theme=light] .b-amber{color:#b9740a}[data-theme=light] .b-red{color:#dc2626}
[data-theme=light] .b-purple{color:#8b3fd6}[data-theme=light] .b-cyan{color:#0a92ad}
[data-theme=light] .b-orange{color:#d35d12}

/* ============ KANBAN ============ */
.kanban{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:14px;align-items:start}
.kcol{background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius-lg);padding:12px;min-height:120px;transition:background .15s}
.kcol.drag-over{background:rgba(59,130,246,.08);border-color:var(--blue);border-style:dashed}
.kcol-head{display:flex;align-items:center;gap:8px;margin-bottom:11px;padding:2px 4px}
.kcol-head .dot{width:9px;height:9px;border-radius:50%}
.kcol-head b{font-size:13px;font-weight:600}
.kcol-head .n{margin-left:auto;font-size:11px;color:var(--muted);background:var(--surface);padding:2px 9px;border-radius:20px;font-family:var(--mono)}
.kcard{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:12px 13px;margin-bottom:9px;
  cursor:grab;transition:box-shadow .15s,border-color .15s,transform .12s;border-left:3px solid var(--accent,var(--blue))}
.kcard:hover{box-shadow:var(--shadow);border-color:var(--border-strong)}
.kcard:active{cursor:grabbing}
.kcard.dragging{opacity:.45;transform:scale(.98)}
.kcard .knm{font-size:12.5px;font-weight:550;line-height:1.4;margin-bottom:8px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.kcard .kmeta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:11px;color:var(--muted)}
.kcard .kplant{font-family:var(--mono);font-size:10.5px}

/* ============ TIMELINE ============ */
.tl-trend{margin-bottom:6px}
.tl-trend-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
.tl-trend-stats{display:flex;gap:26px;flex-wrap:wrap;margin:14px 0 6px;padding-bottom:14px;border-bottom:1px solid var(--border)}
.tl-tstat{display:flex;flex-direction:column;gap:2px}
.tl-tstat b{font-size:19px;font-weight:700;line-height:1.1}
.tl-tstat span{font-size:11.5px;color:var(--muted)}
.tl-month-n{font-weight:500;color:var(--muted);text-transform:none;letter-spacing:0;font-size:11px;margin-left:6px}
.tl{position:relative;padding-left:8px}
.tl-month{font-size:12px;font-weight:700;color:var(--accent);text-transform:uppercase;letter-spacing:.5px;margin:22px 0 12px;padding-left:24px}
.tl-month:first-child{margin-top:0}
.tl-item{display:flex;gap:16px;padding:0 0 4px 0;position:relative}
.tl-rail{position:absolute;left:5px;top:0;bottom:0;width:2px;background:var(--border)}
.tl-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0;margin-top:14px;z-index:1;border:2px solid var(--bg);box-shadow:0 0 0 2px var(--border)}
.tl-body{flex:1;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:13px 15px;margin-bottom:10px;cursor:pointer;transition:border-color .15s,box-shadow .15s}
.tl-body:hover{border-color:var(--border-strong);box-shadow:var(--shadow-sm)}
.tl-nm{font-size:13px;font-weight:550;line-height:1.4;margin-bottom:6px}
.tl-meta{display:flex;align-items:center;gap:7px;flex-wrap:wrap;font-size:11.5px;color:var(--muted)}

/* ============ BY-PLANT ============ */
.plant-group{margin-bottom:14px;border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden;background:var(--surface)}
.plant-head{display:flex;align-items:center;gap:12px;padding:13px 17px;cursor:pointer;user-select:none;background:var(--surface2);transition:background .12s}
.plant-head:hover{background:var(--surface3)}
.plant-head .chev{transition:transform .2s;color:var(--muted)}
.plant-head.open .chev{transform:rotate(90deg)}
.plant-head b{font-size:14px;font-weight:600}
.plant-head .pmeta{margin-left:auto;display:flex;align-items:center;gap:8px}
.plant-mini{height:6px;width:90px;background:var(--surface4);border-radius:4px;overflow:hidden;display:flex}
.plant-body{display:none}
.plant-body.open{display:block}

/* ============ DETAIL PANEL ============ */
.scrim{position:fixed;inset:0;background:rgba(6,9,14,.55);z-index:140;opacity:0;pointer-events:none;transition:opacity .25s;backdrop-filter:blur(2px)}
.scrim.show{opacity:1;pointer-events:auto}
.panel{position:fixed;right:0;top:0;bottom:0;width:480px;max-width:94vw;background:var(--surface);border-left:1px solid var(--border);
  z-index:150;overflow-y:auto;transform:translateX(102%);transition:transform .28s cubic-bezier(.4,0,.2,1);box-shadow:var(--shadow-lg)}
.panel.open{transform:translateX(0)}
.panel-head{padding:20px 22px 16px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:2}
.panel-head .topline{display:flex;align-items:flex-start;gap:12px}
.panel-head h2{font-size:15.5px;font-weight:600;line-height:1.35;flex:1}
.panel-head .id-tag{font-family:var(--mono);font-size:11px;color:var(--muted);margin-bottom:7px}
.panel-body{padding:20px 22px 40px}
.badges-row{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:18px}
.kv{display:grid;grid-template-columns:120px 1fr;gap:12px;padding:9px 0;border-bottom:1px solid var(--border);font-size:13px}
.kv .k{color:var(--muted);font-size:12.5px}
.kv .v{color:var(--text)}
.kv .v.mono{font-family:var(--mono);font-size:12px}
.sec-label{font-size:11px;font-weight:700;color:var(--faint);text-transform:uppercase;letter-spacing:.6px;margin:22px 0 10px}
.desc-box{font-size:12.5px;color:var(--text2);line-height:1.65;white-space:pre-wrap;background:var(--surface2);border:1px solid var(--border);
  border-radius:var(--radius);padding:13px 15px;max-height:280px;overflow-y:auto;font-family:var(--mono)}

/* activity log */
.log{position:relative;padding-left:18px;margin-top:4px}
.log::before{content:'';position:absolute;left:4px;top:6px;bottom:6px;width:2px;background:var(--border)}
.log-empty{font-size:12px;color:var(--faint);padding-left:0}
.log-item{position:relative;padding:0 0 14px}
.log-item:last-child{padding-bottom:0}
.log-item .ld{position:absolute;left:-18px;top:4px;width:10px;height:10px;border-radius:50%;background:var(--accent,var(--blue));border:2px solid var(--surface)}
.log-item .lt{font-size:12.5px;color:var(--text);line-height:1.5}
.lm-row{display:flex;align-items:center;gap:6px;margin-top:3px}
.log-item .lm{font-size:11px;color:var(--faint);font-family:var(--mono)}
.log-acts{display:flex;gap:2px;margin-left:auto;opacity:0;transition:opacity .15s}
.log-item:hover .log-acts{opacity:1}
.log-act-btn{background:none;border:none;cursor:pointer;color:var(--muted);display:flex;align-items:center;padding:2px 4px;border-radius:4px;transition:color .15s,background .15s}
.log-act-btn:hover{color:var(--blue);background:rgba(59,130,246,.1)}
.log-act-btn svg{width:13px;height:13px}
.log-act-del:hover{color:var(--red);background:rgba(239,68,68,.1)}
/* image in log */
.log-img-wrap{margin-top:7px}
.log-img{max-width:100%;max-height:180px;border-radius:7px;cursor:zoom-in;border:1px solid var(--border);object-fit:cover}
.log-img-preview{display:flex;align-items:center;margin-top:7px;gap:6px}
.log-add{display:flex;gap:8px;margin-top:12px;align-items:stretch}
.log-add input{flex:1;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);color:var(--text);padding:8px 11px;font-size:13px;font-family:inherit;outline:none}
.log-add input:focus{border-color:var(--blue)}
.log-img-btn{cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 10px;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);color:var(--muted);transition:color .15s,border-color .15s}
.log-img-btn:hover{color:var(--blue);border-color:var(--blue)}
.log-img-btn svg{width:18px;height:18px}
/* table note column */
.cell-note{font-size:12.5px;color:var(--text2);max-width:180px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* status quick changer */
.quick-status{display:flex;gap:8px;margin-top:10px}

/* ============ MODAL ============ */
.modal-scrim{position:fixed;inset:0;background:rgba(6,9,14,.6);z-index:200;display:flex;align-items:flex-start;
  justify-content:center;padding:40px 20px;opacity:0;pointer-events:none;transition:opacity .2s;backdrop-filter:blur(3px);overflow-y:auto}
.modal-scrim.show{opacity:1;pointer-events:auto}
.modal{background:var(--surface);border:1px solid var(--border-strong);border-radius:16px;width:100%;max-width:680px;
  box-shadow:var(--shadow-lg);transform:translateY(-14px) scale(.98);transition:transform .22s;margin:auto}
.modal-scrim.show .modal{transform:none}
.modal-head{padding:20px 24px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between}
.modal-head h2{font-size:16px;font-weight:600}
.modal-head .sub{font-size:12px;color:var(--muted);margin-top:2px}
.modal-body{padding:22px 24px;max-height:64vh;overflow-y:auto}
.modal-foot{padding:16px 24px;border-top:1px solid var(--border);display:flex;gap:9px;justify-content:flex-end;align-items:center}

/* ----- FORM ----- */
.fg{margin-bottom:15px}
.fg label{display:block;font-size:12px;font-weight:600;color:var(--text2);margin-bottom:6px}
.fg label .req{color:var(--red)}
.fg input,.fg select,.fg textarea{width:100%;background:var(--surface2);border:1px solid var(--border);border-radius:var(--radius);
  color:var(--text);padding:9px 11px;font-size:13.5px;font-family:inherit;outline:none;transition:border .15s,box-shadow .15s}
.fg input:focus,.fg select:focus,.fg textarea:focus{border-color:var(--blue);box-shadow:0 0 0 3px rgba(59,130,246,.12)}
.fg textarea{min-height:86px;resize:vertical;line-height:1.55}
.fg .hint{font-size:11px;color:var(--muted);margin-top:5px}
.frow{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.frow-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px}
.qo-lookup{display:flex;gap:8px;align-items:flex-end}
.qo-lookup .fg{flex:1;margin-bottom:0}
.autofill-note{font-size:11.5px;padding:8px 12px;border-radius:var(--radius);margin-top:8px;display:none;align-items:center;gap:8px}
.autofill-note.ok{background:rgba(34,197,94,var(--tint2));color:var(--green);display:flex}
.autofill-note.miss{background:rgba(245,158,11,var(--tint2));color:var(--amber);display:flex}

/* ============ EMPTY / MISC ============ */
.empty{text-align:center;padding:64px 20px;color:var(--muted)}
.empty .ic{width:54px;height:54px;border-radius:14px;background:var(--surface2);display:grid;place-items:center;margin:0 auto 16px}
.empty .ic svg{width:26px;height:26px;color:var(--faint)}
.empty b{display:block;font-size:14px;color:var(--text);font-weight:600;margin-bottom:4px}
.empty span{font-size:12.5px}

/* toast */
.toast{position:fixed;bottom:26px;left:50%;transform:translateX(-50%) translateY(80px);background:var(--surface);
  border:1px solid var(--border-strong);border-radius:11px;padding:12px 18px;font-size:13.5px;font-weight:500;z-index:300;
  display:flex;align-items:center;gap:10px;box-shadow:var(--shadow-lg);opacity:0;transition:all .3s cubic-bezier(.4,0,.2,1)}
.toast.show{transform:translateX(-50%) translateY(0);opacity:1}
.toast .ti{width:20px;height:20px;flex-shrink:0}
.toast.ok .ti{color:var(--green)}.toast.err .ti{color:var(--red)}.toast.info .ti{color:var(--blue)}

.theme-toggle{display:flex;background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:3px;gap:2px}
.theme-toggle button{flex:1;border:none;background:transparent;color:var(--muted);padding:6px;border-radius:6px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;gap:6px;font-size:12px;font-weight:500;transition:all .15s}
.theme-toggle button.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm)}
.theme-toggle button svg{width:15px;height:15px}

.chip{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;font-size:12px;font-weight:500;
  background:var(--surface2);border:1px solid var(--border);color:var(--text2)}

/* segmented dashboard variant switcher */
.dash-controls{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap}
.year-sel{min-width:96px}
.seg{display:inline-flex;background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:3px;gap:2px}
.seg button{border:none;background:transparent;color:var(--muted);padding:6px 13px;border-radius:6px;cursor:pointer;font-size:12.5px;font-weight:500;transition:all .15s}
.seg button.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm);font-weight:600}

/* spotlight focus cards (dashboard v3) */
.focus-list{display:flex;flex-direction:column;gap:9px}
.focus-row{display:flex;align-items:center;gap:13px;padding:12px 15px;background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);cursor:pointer;transition:border-color .15s,box-shadow .15s}
.focus-row:hover{border-color:var(--border-strong);box-shadow:var(--shadow-sm)}
.focus-row .fbar{width:4px;align-self:stretch;border-radius:3px;flex-shrink:0}
.focus-row .fnm{flex:1;min-width:0}
.focus-row .fnm b{font-size:13px;font-weight:550;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}
.focus-row .fnm span{font-size:11px;color:var(--muted);font-family:var(--mono)}

/* responsive */
@media(max-width:980px){
  .app{grid-template-columns:1fr}
  .sidebar{position:fixed;left:0;top:0;z-index:160;transform:translateX(-100%);transition:transform .25s;width:280px}
  .sidebar.open{transform:none}
  .grid-2,.grid-3{grid-template-columns:1fr}
  .menu-btn{display:grid!important}
  .frow,.frow-3{grid-template-columns:1fr}
}
.menu-btn{display:none}

/* ============ BY OWNER (supervisor) ============ */
.own-chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:20px}
.own-chip{display:inline-flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;font-size:12.5px;font-weight:500;
  background:var(--surface);border:1px solid var(--border);color:var(--text2);cursor:pointer;transition:all .14s}
.own-chip:hover{border-color:var(--border-strong);color:var(--text)}
.own-chip .dot{width:9px;height:9px;border-radius:50%;opacity:.5;transition:opacity .14s}
.own-chip .n{font-family:var(--mono);font-size:11px;background:var(--surface3);padding:1px 7px;border-radius:10px;color:var(--muted)}
.own-chip.on{background:color-mix(in srgb,var(--oc) 13%,var(--surface));border-color:var(--oc);color:var(--text)}
.own-chip.on .dot{opacity:1}
.own-chip.on .n{background:color-mix(in srgb,var(--oc) 22%,transparent);color:var(--text)}

.own-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:15px}
.own-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:17px 18px}
.own-top{display:flex;align-items:center;gap:12px;margin-bottom:14px}
.own-av{width:42px;height:42px;border-radius:11px;display:grid;place-items:center;color:#fff;font-weight:700;font-size:15px;flex-shrink:0;font-family:var(--mono)}
.own-name{flex:1;min-width:0}
.own-name b{font-size:14px;font-weight:600;display:block;line-height:1.25;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.own-name span{font-size:11.5px;color:var(--muted)}
.own-pct{font-size:22px;font-weight:680;letter-spacing:-.5px;font-feature-settings:'tnum'}
.own-pctwrap{text-align:right;flex-shrink:0}
.own-pctlbl{font-size:9.5px;color:var(--muted);letter-spacing:.2px;margin-top:1px}
.own-prog{height:9px;border-radius:5px;overflow:hidden;background:var(--surface3);margin-bottom:14px}
.own-prog-fill{height:100%;border-radius:5px;transition:width .6s cubic-bezier(.4,0,.2,1)}
.own-bar{height:8px;border-radius:5px;overflow:hidden;display:flex;background:var(--surface3);margin-bottom:14px}
.own-bar span{height:100%;transition:width .5s}
.own-metrics{display:flex;gap:18px;padding-bottom:14px;border-bottom:1px solid var(--border);margin-bottom:12px}
.own-metrics b{font-size:18px;font-weight:680;display:block;line-height:1;letter-spacing:-.5px}
.own-metrics span{font-size:10.5px;color:var(--muted)}
.own-list{display:flex;flex-direction:column;gap:2px;max-height:220px;overflow-y:auto;margin:-4px -6px;padding:4px 6px}
.own-row{display:flex;align-items:center;gap:9px;padding:7px 8px;border-radius:7px;cursor:pointer;transition:background .12s}
.own-row:hover{background:var(--surface2)}
.own-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.own-rnm{flex:1;min-width:0;font-size:12.5px;color:var(--text2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
