:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --ink: #111214;
  --sub: #5d6067;
  --faint: #9a9ca2;
  --line: #e6e6e3;
  --track: #efefec;
  --accent: #111214;
  --good: #1f8a4c;
  --warn: #b26a00;
  --shadow: 0 1px 2px rgba(20, 22, 30, 0.04), 0 8px 24px rgba(20, 22, 30, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d0e10;
    --surface: #17181b;
    --ink: #f2f2f0;
    --sub: #a3a5ab;
    --faint: #6c6f76;
    --line: #26282c;
    --track: #212327;
    --accent: #f2f2f0;
    --good: #4cc27c;
    --warn: #e0a040;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }

/* ---------- Đầu trang ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.top .spacer { flex: 1; }
.updated { color: var(--faint); font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--sub);
}
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-size: 30px; line-height: 1.15; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { color: var(--sub); margin: 0 0 24px; }

/* ---------- Tổng ---------- */
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.total {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sub); }
.big { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* ---------- Thẻ dự án ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.mono {
  width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--ink);
  display: grid; place-items: center; font-weight: 600; font-size: 17px; flex: none;
}
.card-title { flex: 1; min-width: 0; }
.card-title h2 { font-size: 18px; margin: 0; font-weight: 600; }
.card-title p { margin: 2px 0 0; color: var(--sub); font-size: 13px; }
.chip {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--sub);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}

.nums { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; align-items: end; }
.nums .big { font-size: 34px; margin-top: 0; line-height: 1; }
.num-sm { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta { color: var(--good); font-size: 13px; font-weight: 500; }

.spark { height: 44px; width: 100%; display: block; }
.spark-cap { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-top: 4px; }

.state {
  display: flex; align-items: center; gap: 8px; color: var(--sub); font-size: 13px;
  background: var(--track); border-radius: 12px; padding: 12px 14px;
}
.state svg { width: 16px; height: 16px; flex: none; }
.state.warn { color: var(--warn); }

.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.links a {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-size: 13px; color: var(--sub);
  border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px;
}
.links a:hover { color: var(--ink); border-color: var(--faint); }
.links svg { width: 12px; height: 12px; }

.skeleton { background: var(--track); border-radius: 8px; height: 34px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login .brand { justify-content: center; margin-bottom: 6px; }
.login input {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none; width: 100%;
}
.login input:focus { border-color: var(--ink); }
.login button {
  background: var(--accent); color: var(--bg); border: 0; border-radius: 12px; padding: 12px; font-weight: 600; cursor: pointer;
}
.login button:disabled { opacity: 0.5; }
.err { color: #c0392b; font-size: 13px; min-height: 18px; text-align: center; margin: 0; }

@media (max-width: 760px) {
  .totals { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .top .updated { display: none; }
}
