:root {
  /* Tell the browser this page manages its own theming (light by default),
     so Chrome "force dark" / auto-dark-mode won't darken the light theme. */
  color-scheme: light;

  /* Brand accent (teal) */
  --accent:        #0d9488;
  --accent-600:    #0f9e90;
  --accent-500:    #14b8a6;
  --accent-soft:   #e4f5f2;
  --accent-grad-a: #1ec7b6;
  --accent-grad-b: #0d9488;

  /* Discipline palette */
  --inf:  #14b8a6;  /* Hạ tầng  */
  --str:  #60a5fa;  /* Kết cấu  */
  --arc:  #a78bfa;  /* Kiến trúc */
  --mep:  #f59e0b;  /* MEP      */

  /* Semantic */
  --ok:    #10b981;
  --warn:  #f59e0b;
  --danger:#ef4444;
  --info:  #3b82f6;

  /* Neutrals — light theme */
  --bg:        #f7f9f9;
  --surface:   #ffffff;
  --surface-2: #fbfcfc;
  --sunken:    #f1f5f5;
  --line:      #e8edee;
  --line-soft: #f0f3f4;
  --ink:       #0f1f24;
  --ink-2:     #45565c;
  --ink-3:     #8aa0a6;
  --ink-4:     #aebdc1;

  --sidebar-bg: #ffffff;
  --topbar-bg:  #ffffff;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(15,31,36,.04), 0 1px 3px rgba(15,31,36,.03);
  --shadow-md: 0 4px 16px -4px rgba(15,31,36,.08), 0 2px 6px -2px rgba(15,31,36,.05);
  --shadow-lg: 0 18px 48px -12px rgba(15,31,36,.18);
  --ring: 0 0 0 4px rgba(13,148,136,.12);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --font: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w: 248px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --accent-soft: rgba(20,184,166,.14);

  --bg:        #0b1417;
  --surface:   #0f1d21;
  --surface-2: #122327;
  --sunken:    #0c181b;
  --line:      #1d3036;
  --line-soft: #18282d;
  --ink:       #eef5f5;
  --ink-2:     #9fb3b8;
  --ink-3:     #6c878d;
  --ink-4:     #4f686e;

  --sidebar-bg: #0d191d;
  --topbar-bg:  #0b1417;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 22px -6px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.65);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100vh; }

::selection { background: rgba(20,184,166,.22); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Layout ---- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 22px 20px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(150deg, var(--accent-grad-a), var(--accent-grad-b));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 16px -4px rgba(13,148,136,.5);
  flex: none;
}
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .01em; }

.nav { padding: 6px 14px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
  color: var(--ink-4); text-transform: uppercase;
  padding: 16px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 11px; border-radius: 10px;
  color: var(--ink-2); font-size: 14px; font-weight: 600;
  cursor: pointer; position: relative;
  transition: background .15s, color .15s, transform .15s cubic-bezier(.2,.8,.2,1);
  user-select: none;
}
.nav-item:hover { background: var(--sunken); color: var(--ink); transform: translateX(3px); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { color: var(--ink-3); flex: none; }
.nav-item .label { flex: 1; }
.nav-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--sunken); color: var(--ink-3);
}
.nav-item.active .nav-badge { background: rgba(13,148,136,.16); color: var(--accent); }
.nav-badge.warn { background: rgba(245,158,11,.14); color: #b87503; }
[data-theme="dark"] .nav-badge.warn { color: var(--warn); }

.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.user-chip {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 12px; cursor: pointer;
  transition: background .15s;
}
.user-chip:hover { background: var(--sunken); }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(150deg,#334155,#0f1f24);
}
[data-theme="dark"] .avatar { background: linear-gradient(150deg,#1ec7b6,#0d9488); }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }

.topbar {
  height: 72px; flex: none;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px;
}
.crumb { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.page-title { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-top: 1px; }

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  width: 320px; height: 42px; padding: 0 14px;
  background: var(--sunken); border: 1px solid transparent;
  border-radius: 12px; color: var(--ink-3); font-size: 14px;
  cursor: text; transition: border .15s, background .15s;
}
.search:hover { border-color: var(--line); }
.kbd {
  margin-left: auto; font-family: var(--mono); font-size: 11px;
  padding: 3px 7px; border-radius: 6px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink-3);
}

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 15px; border-radius: 12px;
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: background .15s, border .15s;
}
.pill:hover { background: var(--sunken); }
.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); flex:none;
  box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot.live { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{ box-shadow:0 0 0 0 rgba(16,185,129,.35);} 50%{ box-shadow:0 0 0 5px rgba(16,185,129,0);} }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; cursor: pointer; position: relative;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn .ping { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px;
  border-radius: 99px; background: var(--danger); border: 2px solid var(--surface); }

/* ---- Content scroll area ---- */
.content { flex: 1; overflow-y: auto; padding: 26px 28px 40px; animation: fadeUp .34s cubic-bezier(.2,.8,.2,1); }
.content.flush { padding: 0; overflow: hidden; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: box-shadow .22s ease, border-color .18s ease;
}
/* opt-in lift for clickable cards (file grid, stat tiles) */
.card-hover { cursor: pointer; transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15.5px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.card-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; font-weight: 500; white-space: nowrap; }

/* Stat card */
.stat { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.stat-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.stat-label { font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-value .u { font-size: 17px; color: var(--ink-3); font-weight: 700; margin-left: 2px; }
.trend { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 7px; white-space: nowrap; }
.trend.up { background: rgba(16,185,129,.12); color: #0a8f63; }
.trend.down { background: rgba(245,158,11,.14); color: #b87503; }
.trend.flat { background: var(--sunken); color: var(--ink-3); }
[data-theme="dark"] .trend.up { color: #34d399; }
[data-theme="dark"] .trend.down { color: #fbbf24; }

/* Grids */
.grid { display: grid; gap: 18px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-2u { grid-template-columns: 1.55fr 1fr; }
.g-2v { grid-template-columns: 1fr 1.35fr; }

/* Seg control */
.seg { display: inline-flex; background: var(--sunken); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 700;
  color: var(--ink-3); padding: 6px 13px; border-radius: 8px; cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Legend rows */
.legend { display: flex; flex-direction: column; gap: 14px; }
.legend-row { display: flex; align-items: center; gap: 11px; font-size: 13.5px; }
.legend-row .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row .ln { flex: 1; color: var(--ink-2); font-weight: 600; }
.legend-row .v { font-weight: 800; }
.legend-row .pct { color: var(--ink-3); font-weight: 700; width: 36px; text-align: right; font-size: 12.5px; }

/* Progress */
.bar-row { display: flex; align-items: center; gap: 14px; }
.bar-row .nm { width: 92px; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 9px; }
.bar-row .nm .sw { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.bar { flex: 1; height: 9px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar-row .pc { width: 42px; text-align: right; font-weight: 800; font-size: 13.5px; }

/* Activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-ico { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.feed-main { flex: 1; min-width: 0; }
.feed-t { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.feed-t b { font-weight: 800; }
.feed-s { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-weight: 500; }
.feed-time { font-size: 12px; color: var(--ink-4); font-weight: 600; white-space: nowrap; }
.tag-mono { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px;
  background: var(--sunken); color: var(--ink-2); font-weight: 600; }

/* Generic chip */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 8px; font-size: 12px; font-weight: 700; }
.chip.inf { background: rgba(20,184,166,.13); color: #0c8d80; }
.chip.str { background: rgba(96,165,250,.16); color: #2f6fc4; }
.chip.arc { background: rgba(167,139,250,.16); color: #7c54e0; }
.chip.mep { background: rgba(245,158,11,.15); color: #b07203; }
.chip.ok  { background: rgba(16,185,129,.13); color: #0a8f63; }
.chip.warn{ background: rgba(245,158,11,.15); color: #b07203; }
.chip.danger{ background: rgba(239,68,68,.13); color: #d23b3b; }
.chip.idle{ background: var(--sunken); color: var(--ink-3); }
[data-theme="dark"] .chip.inf{color:#2dd4bf} [data-theme="dark"] .chip.str{color:#93c5fd}
[data-theme="dark"] .chip.arc{color:#c4b5fd} [data-theme="dark"] .chip.mep{color:#fbbf24}
[data-theme="dark"] .chip.ok{color:#34d399} [data-theme="dark"] .chip.warn{color:#fbbf24}
[data-theme="dark"] .chip.danger{color:#f87171}

/* Buttons */
.btn { display:inline-flex; align-items:center; gap:8px; height:40px; padding:0 16px;
  border-radius:11px; font:inherit; font-size:13.5px; font-weight:700; cursor:pointer; white-space:nowrap;
  border:1px solid var(--line); background:var(--surface); color:var(--ink-2);
  transition: background .16s ease, box-shadow .16s ease, transform .1s ease, border-color .16s ease; }
.btn:hover { background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color:#fff; }
.btn.primary:hover { background: var(--accent-600); box-shadow: 0 6px 16px -7px var(--accent); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--ink-3); padding: 14px 14px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 14px; border-top: 1px solid var(--line-soft); color: var(--ink-2); font-weight: 500; transition: background .16s ease; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .t-strong { color: var(--ink); font-weight: 700; }

.empty-line { height: 1px; background: var(--line); }

.fade-up { animation: fadeUp .34s cubic-bezier(.2,.8,.2,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px);} to { opacity:1; transform:none; } }
@keyframes drawerIn { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* spark */
.spark path.area { transition: opacity .6s; }