/* =========================================================
   Helpdesk Notes — "sổ tay làm việc": ấm, ngăn nắp, nhẹ nhàng
   ========================================================= */
:root {
  /* Neutral ánh ấm (giấy) — pha nhẹ sắc teal ở chữ */
  --bg: oklch(0.975 0.008 85);
  --surface: oklch(0.995 0.004 85);
  --sunken: oklch(0.955 0.01 85);
  --text: oklch(0.27 0.025 230);
  --muted: oklch(0.52 0.02 230);
  --faint: oklch(0.68 0.015 230);
  --line: oklch(0.91 0.012 85);
  --line-strong: oklch(0.85 0.014 85);

  /* Màu chủ đạo: teal đậm; accent hổ phách chỉ cho "cần chú ý" */
  --accent: oklch(0.5 0.085 195);
  --accent-hover: oklch(0.44 0.085 195);
  --accent-soft: oklch(0.94 0.03 195);
  --accent-contrast: #fff;
  --attention: oklch(0.72 0.14 70);
  --attention-soft: oklch(0.95 0.045 80);
  --attention-text: oklch(0.47 0.11 60);

  --success: oklch(0.55 0.11 155);
  --success-soft: oklch(0.94 0.045 155);
  --danger: oklch(0.56 0.17 28);
  --danger-soft: oklch(0.95 0.035 28);
  --info: oklch(0.52 0.12 250);
  --info-soft: oklch(0.95 0.03 250);

  /* Trạng thái công việc */
  --todo: var(--faint);
  --doing: var(--accent);
  --waiting: var(--attention);
  --done: var(--success);
  --created: oklch(0.82 0.05 195);
  --done-bar: var(--success);

  /* Màu biểu đồ (đã chạy validate_palette: đạt cả nền sáng/tối) — giữ đúng thứ tự, không đổi vị trí */
  --viz-created: #257de0; --viz-done: #00b894;
  --pm-doing: #00b894; --pm-review: #f2a600; --pm-new: #257de0; --pm-blocked: #ec4647;

  /* Chữ — thang 1.25 */
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14.5px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 26px; --fs-2xl: 32px;

  /* Khoảng cách — thang 4px */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow-sm: 0 1px 2px oklch(0.3 0.02 230 / .06);
  --shadow-lg: 0 24px 60px -12px oklch(0.25 0.03 230 / .28);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 180ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.2 0.012 230);
    --surface: oklch(0.235 0.014 230);
    --sunken: oklch(0.18 0.012 230);
    --text: oklch(0.93 0.01 85);
    --muted: oklch(0.72 0.015 230);
    --faint: oklch(0.58 0.015 230);
    --line: oklch(0.3 0.014 230);
    --line-strong: oklch(0.36 0.016 230);
    --accent: oklch(0.72 0.09 190);
    --accent-hover: oklch(0.78 0.09 190);
    --accent-soft: oklch(0.3 0.04 195);
    --accent-contrast: oklch(0.18 0.02 230);
    --attention-soft: oklch(0.32 0.05 70);
    --attention-text: oklch(0.85 0.11 75);
    --success-soft: oklch(0.3 0.05 155);
    --danger: oklch(0.7 0.15 28);
    --danger-soft: oklch(0.32 0.06 28);
    --info-soft: oklch(0.3 0.04 250);
    --created: oklch(0.45 0.06 195);
    --viz-created: #338ced; --viz-done: #00a888;
    --pm-doing: #00a888; --pm-review: #d28e05; --pm-new: #338ced; --pm-blocked: #eb6263;
    --shadow-lg: 0 24px 60px -12px oklch(0 0 0 / .55);
    color-scheme: dark;
  }
}

/* ---------- Nền tảng ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 400 var(--fs-base)/1.55 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: 'ss01';
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.err-text { color: var(--danger); }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------- Ô nhập ---------- */
input, select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 9px 11px; min-height: 40px; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { resize: vertical; min-height: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--sunken); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); min-width: 0; }
.field > input, .field > select, .field > textarea { font-size: var(--fs-base); font-weight: 400; color: var(--text); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 500; cursor: pointer; text-decoration: none; color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); }
.login-aside {
  padding: var(--s7); display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(120% 80% at 0% 100%, oklch(0.42 0.08 195) 0%, transparent 60%),
    oklch(0.32 0.05 215);
  color: oklch(0.96 0.01 85);
}
.login-quote { font-size: var(--fs-lg); line-height: 1.5; max-width: 30ch; color: oklch(0.9 0.02 190); }
.login-card { align-self: center; padding: var(--s7) var(--s6); display: flex; flex-direction: column; gap: var(--s4); }
.login-card h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
.check { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.check input { width: 16px; min-height: 0; height: 16px; margin-top: 3px; accent-color: var(--accent); }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.hint { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Thanh trên ---------- */
.wordmark { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.wordmark em { font-style: normal; color: var(--accent); }
.wordmark.light em { color: oklch(0.85 0.08 190); }
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 0 var(--s5); height: 60px; display: flex; align-items: center; gap: var(--s5); }
.tabs { display: flex; gap: 2px; height: 100%; }
.tab {
  border: 0; background: none; padding: 0 var(--s3); color: var(--muted); font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.sync { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.sync.busy i { background: var(--attention); animation: pulse 1.2s var(--ease) infinite; }
.sync.err { color: var(--danger); } .sync.err i { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
/* Chuông cảnh báo */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell svg { width: 19px; height: 19px; }
.bell.has-critical { color: var(--danger); }
.bell.has-critical svg { animation: ring 2.4s var(--ease) 1; transform-origin: 50% 10%; }
@keyframes ring { 0%, 30%, 100% { transform: rotate(0); } 5%, 15%, 25% { transform: rotate(14deg); } 10%, 20% { transform: rotate(-14deg); } }
.bell-count {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--attention); color: oklch(0.25 0.05 60); font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); font-variant-numeric: tabular-nums;
}
.bell.has-critical .bell-count { background: var(--danger); color: #fff; }
.bell-panel {
  position: absolute; right: -8px; top: calc(100% + 10px); width: min(400px, calc(100vw - 24px)); max-height: min(70vh, 560px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 30; animation: pop 180ms var(--ease);
}
.bell-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.bell-list { overflow: auto; padding: var(--s1) 0; }
.bell-group { padding: var(--s2) var(--s4) 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.bell-group.critical { color: var(--danger); } .bell-group.warning { color: var(--attention-text); } .bell-group.info { color: var(--accent); }
.alert-item {
  display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px var(--s4); cursor: pointer; transition: background var(--dur) var(--ease);
}
.alert-item:hover, .alert-item:focus-visible { background: var(--sunken); }
.alert-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; }
.alert-item.critical .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.alert-item.warning .dot { background: var(--attention); }
.alert-item.info .dot { background: var(--accent); }
.alert-item .at { display: block; font-size: var(--fs-sm); font-weight: 500; overflow-wrap: anywhere; }
.alert-item .ad { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.alert-item.critical .ad b { color: var(--danger); }
.alert-item.warning .ad b { color: var(--attention-text); }
.bell-empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.bell-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); flex-wrap: wrap; }

.install { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 35%, transparent); background: var(--accent-soft); }
.install:hover { background: var(--accent-soft); border-color: var(--accent); }
.user { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 500; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-xs); }

/* ---------- Trang ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); }
.greeting { margin-bottom: var(--s5); }
.greeting h1 { font-size: clamp(24px, 3.4vw, var(--fs-2xl)); letter-spacing: -0.03em; line-height: 1.15; }
.greeting p { margin-top: 6px; font-size: var(--fs-md); max-width: 70ch; }
.greeting b { color: var(--text); font-weight: 600; }
.greeting .hot { color: var(--attention-text); font-weight: 600; }
.notice { margin-bottom: var(--s4); padding: 10px 14px; border-radius: var(--r-sm); background: var(--attention-soft); color: var(--attention-text); font-size: var(--fs-sm); }
.view { animation: rise 260ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.block { margin-top: var(--s6); }
.block > h3, .grid2 h3 { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s3); }
.mt { margin-top: var(--s5); }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s4); }
.section-head h2 { font-size: var(--fs-lg); letter-spacing: -0.01em; }

/* ---------- Ô nhập nhanh ---------- */
.composer {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4) var(--s5) var(--s4); box-shadow: var(--shadow-sm);
}
.dest { display: inline-flex; padding: 3px; background: var(--sunken); border-radius: 999px; margin-bottom: var(--s3); }
.seg { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.quick { display: flex; flex-direction: column; gap: var(--s3); }
.title-field {
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 0 10px; min-height: 0;
  font-size: var(--fs-lg); font-weight: 500; background: transparent; letter-spacing: -0.01em;
}
.title-field:hover { border-color: var(--line-strong); }
.title-field:focus { box-shadow: none; border-color: var(--accent); }
.hd-fields { display: grid; grid-template-columns: 1.3fr .8fr .9fr 1.2fr; gap: var(--s3); }
.pm-fields { display: grid; grid-template-columns: 1.6fr 1.3fr 1fr .9fr; gap: var(--s3); }
.quick .pm-only { display: none; }
.quick.pm-mode .pm-only { display: grid; }
.quick.pm-mode .hd-only { display: none; }
.req { color: var(--danger); margin-left: 2px; }
/* Việc quá hạn trong ngày → bổ sung lý do */
.late-box { border-radius: var(--r-md); padding: var(--s3) var(--s4); background: var(--danger-soft); display: flex; flex-direction: column; gap: var(--s2); }
.late-box.ok { background: var(--attention-soft); }
.late-title { font-size: var(--fs-sm); font-weight: 600; color: var(--danger); }
.late-box.ok .late-title { color: var(--attention-text); }
.late-form { display: flex; gap: var(--s2); align-items: flex-end; }
.late-form textarea { background: var(--surface); }
.late-form .btn { white-space: nowrap; flex: none; }
.late-box.ok .late-form { display: none; }
.late-history { margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.late-history b { color: var(--text); font-weight: 600; }
.pill-late { font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; white-space: nowrap; }
.pill-late.need { background: var(--danger-soft); color: var(--danger); }
.pill-late.ok { background: var(--attention-soft); color: var(--attention-text); }
.attach { display: flex; flex-direction: column; gap: var(--s2); border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: var(--s3); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.attach h4 { font-size: var(--fs-sm); }
.attach.drag { border-color: var(--accent); background: var(--accent-soft); }
.attach-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.ai-btn { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.ai-btn:disabled { opacity: .7; cursor: progress; }
.ai-btn.hidden { display: none; }
.attach-btn { cursor: pointer; }
.thumbs { display: flex; gap: var(--s2); flex-wrap: wrap; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 96px; height: 72px; border-radius: var(--r-sm); overflow: hidden; background: var(--sunken); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb a { display: block; height: 100%; }
.thumb .rm { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: oklch(0.2 0.02 230 / .7); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.thumb .st { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; font-weight: 600; padding: 1px 5px; background: oklch(0.2 0.02 230 / .62); color: #fff; }
.thumb .st.ok { background: color-mix(in oklch, var(--success) 85%, black); }
.title-preview { font-size: var(--fs-sm); color: var(--muted); min-height: 1.4em; }
.title-preview b { color: var(--text); font-weight: 600; }
.more summary { cursor: pointer; font-size: var(--fs-sm); color: var(--accent); font-weight: 500; width: fit-content; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '+ '; }
.more[open] summary::before { content: '− '; }
.more-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--s3); align-items: end; margin-top: var(--s3); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.quick-info { font-size: var(--fs-sm); color: var(--success); }
.quick-info.err { color: var(--danger); }

/* ---------- Thanh lọc ---------- */
.toolbar { display: flex; gap: var(--s3); align-items: center; margin: var(--s6) 0 var(--s3); flex-wrap: wrap; }
.block .toolbar { margin-top: 0; }
.filters { display: flex; gap: 2px; flex-wrap: wrap; }
.chip { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; font-size: var(--fs-sm); color: var(--muted); font-weight: 500; cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.chip:hover { color: var(--text); background: var(--sunken); }
.chip.active { background: var(--text); color: var(--bg); }
.toolbar input[type=search] { width: 260px; margin-left: auto; min-height: 36px; }
.pull-line { display: flex; justify-content: flex-end; align-items: center; gap: var(--s2); margin: calc(-1 * var(--s2)) 0 var(--s2); }
.pull-line .err-text { font-weight: 500; }
.from-ehrm { font-size: 10px; font-weight: 600; color: var(--info); background: var(--info-soft); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }

/* ---------- Tờ danh sách (thay cho nhiều card) ---------- */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.sheet:empty { display: none; }
.task {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
  padding: 13px var(--s4); border-top: 1px solid var(--line); cursor: pointer; transition: background var(--dur) var(--ease);
}
.task:first-child { border-top: 0; }
.task:hover { background: var(--sunken); }
.prio { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.prio.normal { background: var(--faint); } .prio.high { background: var(--attention); } .prio.urgent { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.task .t { font-weight: 500; overflow-wrap: anywhere; }
.task .cust { font-weight: 700; }
.task.done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.task .meta { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: 2px; }
.task .meta .overdue { color: var(--danger); font-weight: 600; }
.task .right { display: flex; gap: var(--s3); align-items: center; }
.ref { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--sunken); border-radius: 4px; padding: 1px 6px; margin-right: 8px; vertical-align: 1px; }

.status-select, .pm-status {
  width: auto; min-height: 30px; padding: 3px 28px 3px 10px; font-size: var(--fs-xs); font-weight: 600;
  border-radius: 999px; border-color: transparent; background-color: var(--sunken); cursor: pointer;
}
.status-select.todo, .pm-status.s-new { color: var(--muted); }
.status-select.doing, .pm-status.s-doing { color: var(--accent); background-color: var(--accent-soft); }
.status-select.waiting, .pm-status.s-review { color: var(--attention-text); background-color: var(--attention-soft); }
.status-select.done, .pm-status.s-done { color: var(--success); background-color: var(--success-soft); }
.pm-status.s-blocked { color: var(--danger); background-color: var(--danger-soft); }
.status-select:disabled, .pm-status:disabled { opacity: .6; cursor: not-allowed; }

.sdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.sdot.synced { background: var(--success); opacity: .7; }
.sdot.pending, .sdot.syncing { background: var(--attention); }
.sdot.error { background: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: var(--s7) var(--s4); }
.empty b { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.small-empty { padding: var(--s5) var(--s4); }

/* ---------- Số liệu ---------- */
.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.stat { padding: var(--s4) var(--s5); border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .n { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.stat.bad .n { color: var(--danger); } .stat.warn .n { color: var(--attention-text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); }
.grid2 .block { margin-top: var(--s6); }
.legend { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: var(--s3); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.sw:first-child { margin-left: 0; }
.sw.created { background: var(--created); } .sw.done { background: var(--done-bar); }
.trend { display: flex; align-items: flex-end; gap: 5px; height: 160px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.day { flex: 1; display: flex; gap: 2px; align-items: flex-end; height: 100%; position: relative; }
.day i { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.day i.c { background: var(--created); } .day i.d { background: var(--done-bar); }
.day span { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.bars .row { display: grid; grid-template-columns: 130px 1fr 32px; gap: var(--s2); align-items: center; margin: 9px 0; font-size: var(--fs-sm); }
.bars .track { background: var(--sunken); border-radius: 4px; height: 8px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bars .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.mini-list .it { display: flex; justify-content: space-between; gap: var(--s2); padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: var(--fs-sm); }
.mini-list .it:last-child { border: 0; }
.mini-list .it:hover { color: var(--accent); }
.mini-list .d { color: var(--danger); font-size: var(--fs-xs); white-space: nowrap; font-weight: 500; }
.remind { margin-top: var(--s5); display: flex; justify-content: space-between; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--fs-xs); }

.access-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: var(--fs-sm); }
.access-row code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: var(--fs-sm); color: var(--accent); overflow-wrap: anywhere; }
.access-row .muted { flex-basis: 100%; font-size: var(--fs-xs); }

/* ---------- Lịch họp ---------- */
.mt-when { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: var(--s3); }
.mt-who { display: grid; grid-template-columns: 1fr 1.4fr 1.2fr; gap: var(--s3); }
.week-nav { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); margin: var(--s6) 0 var(--s3); flex-wrap: wrap; }
.week-title h2 { font-size: var(--fs-lg); letter-spacing: -0.01em; }
.week-btns { display: flex; gap: var(--s1); }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.day-cell {
  border: 0; border-left: 1px solid var(--line); background: transparent; padding: 10px 8px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: background var(--dur) var(--ease);
}
.day-cell:first-child { border-left: 0; }
.day-cell:hover { background: var(--sunken); }
.day-cell .dw { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.day-cell .dn { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.day-cell .dc { font-size: 11px; color: var(--faint); }
.day-cell.has .dc { color: var(--accent); font-weight: 600; }
.day-cell.today .dn { color: var(--accent-contrast); background: var(--accent); border-radius: 999px; min-width: 34px; padding: 0 8px; }
.agenda-day { margin-top: var(--s5); scroll-margin-top: 80px; }
.agenda-day h3 { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s2); }
.today-tag { color: var(--accent); }
.meeting { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: var(--s4); align-items: center; padding: 12px var(--s4); border-top: 1px solid var(--line); cursor: pointer; transition: background var(--dur) var(--ease); }
.meeting:first-child { border-top: 0; }
.meeting:hover { background: var(--sunken); }
.m-time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.3; }
.m-time b { font-size: var(--fs-md); }
.m-time span { font-size: var(--fs-xs); color: var(--muted); }
.meeting .t { font-weight: 500; overflow-wrap: anywhere; }
.meeting .cust { font-weight: 700; }
.meeting .meta { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: 2px; }
.meeting .join { color: var(--accent); font-weight: 600; text-decoration: none; }
.meeting .join:hover { text-decoration: underline; }
.meeting.cancelled .t { text-decoration: line-through; color: var(--muted); }
.meeting.done .m-time b, .meeting.past .m-time b { color: var(--muted); }
.m-tag { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.dlg-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.log textarea { background: var(--surface); }

/* ---------- Dự án ---------- */
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--attention-soft); color: var(--attention-text); }
.pm-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.pm-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 10px var(--s4); background: var(--sunken); }
.pm-table td { padding: 10px var(--s4); border-top: 1px solid var(--line); vertical-align: middle; }
.pm-table tr:hover td { background: color-mix(in oklch, var(--sunken) 50%, transparent); }
.pm-table a { color: var(--text); text-decoration: none; font-weight: 600; }
.pm-table a:hover { color: var(--accent); }
.pm-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: var(--s5); padding: 14px var(--s5); border-top: 1px solid var(--line); cursor: pointer; transition: background var(--dur) var(--ease); }
.pm-row:first-child { border-top: 0; }
.pm-row:hover { background: var(--sunken); }
.pm-row .t { font-weight: 600; }
.pm-row .meta { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: 3px; }
.pm-row .note { font-style: italic; }
.pm-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.progress { width: 100%; height: 6px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--success); border-radius: 3px; }

/* ---------- Hộp thoại ---------- */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(720px, 94vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog[open] { animation: pop 220ms var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
dialog::backdrop { background: oklch(0.25 0.03 230 / .42); backdrop-filter: blur(2px); }
dialog.wide { width: min(1120px, 96vw); }
.dlg { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); max-height: 88vh; overflow: auto; }
.dlg-head { display: flex; gap: var(--s2); align-items: flex-start; }
.dlg-title { flex: 1; min-width: 0; }
.dlg-head h2 { font-size: var(--fs-lg); letter-spacing: -0.01em; margin-top: 2px; }
.title-input { font-size: var(--fs-lg); font-weight: 600; border-color: transparent; padding-left: 6px; margin-left: -6px; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { box-shadow: none; border-color: var(--line-strong); }
.dlg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.sync-line { font-size: var(--fs-xs); color: var(--muted); }
.sync-line.err { color: var(--danger); }

/* Cảnh báo easyhrm đổi giao diện (đồng bộ tạm dừng) */
.ui-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 20px; font-size: var(--fs-sm);
  background: var(--attention-soft); color: var(--attention-text); border-bottom: 1px solid var(--line); }
.ui-banner b { font-weight: 600; }
.ui-banner .why { color: var(--text); opacity: .8; }
.ui-banner .btn { margin-left: auto; }
.ui-banner.hidden { display: none; }
/* Mời bật thông báo đẩy */
.push-nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 20px; font-size: var(--fs-sm);
  background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--line); }
.push-nudge > span { flex: 1 1 320px; }
.push-nudge b { font-weight: 600; color: var(--accent); }
.push-nudge .why { color: var(--muted); }
.push-nudge.hidden { display: none; }
.log { background: var(--sunken); border-radius: var(--r-md); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.log h4 { font-size: var(--fs-sm); }
.notes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.notes li { white-space: pre-wrap; font-size: var(--fs-sm); padding-left: var(--s4); position: relative; }
.notes li::before { content: ''; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notes li.none::before { display: none; }
.notes li.none { padding-left: 0; color: var(--muted); }
.notes small { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.note-add { display: flex; gap: var(--s2); align-items: flex-end; }
.dlg-foot { display: flex; gap: var(--s2); border-top: 1px solid var(--line); padding-top: var(--s4); }

.phases { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s3); }
.phase { background: var(--sunken); border-radius: var(--r-md); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.phase.late { box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--danger) 45%, transparent); }
.phase.inactive { opacity: .62; }
.phase header { display: flex; flex-direction: column; gap: 4px; }
.ph-name { font-weight: 600; }
.ph-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.ph-tasks li { background: var(--surface); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.ph-tasks li.none { background: transparent; padding: 0; color: var(--muted); }
.ph-tasks .tm { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ph-tasks .me { color: var(--accent); font-weight: 600; }
.ph-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.ph-add input { grid-column: 1 / -1; }
.ph-add input, .ph-add select { min-height: 34px; padding: 6px 9px; font-size: var(--fs-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .hd-fields, .pm-fields, .mt-who { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .login { grid-template-columns: 1fr; }
  .login-aside { padding: var(--s6) var(--s5); gap: var(--s4); }
  .login-quote { font-size: var(--fs-md); }
  .login-card { padding: var(--s6) var(--s5); }
}
@media (max-width: 640px) {
  .top-inner { padding: 0 var(--s4); gap: var(--s3); }
  .wordmark { display: none; }
  .sync span, #whoami { display: none; }
  .page { padding: var(--s5) var(--s4) var(--s7); }
  .composer { padding: var(--s4); }
  .hd-fields, .pm-fields, .more-body, .dlg-grid, .dlg-grid.two, .mt-who { grid-template-columns: 1fr; }
  .mt-when { grid-template-columns: 1fr 1fr; }
  .day-cell { padding: 8px 2px; }
  .day-cell .dc { display: none; }
  .day-cell.has .dn { text-decoration: underline 2px var(--accent); text-underline-offset: 4px; }
  .meeting { grid-template-columns: 52px minmax(0, 1fr); }
  .m-tag { grid-column: 2; justify-content: flex-start; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { border-left: 0 !important; border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .toolbar input[type=search] { width: 100%; margin-left: 0; }
  .task { grid-template-columns: 10px minmax(0, 1fr); }
  .task .right { grid-column: 2; }
  .pm-row { grid-template-columns: 1fr; gap: var(--s2); }
  .pm-table th:nth-child(2), .pm-table td:nth-child(2) { display: none; }
  .tab { padding: 0 var(--s2); white-space: nowrap; font-size: var(--fs-sm); }
  .tabs { overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
  .bell-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
  .tabs::-webkit-scrollbar { display: none; }
  .sync { margin-left: 0; }
  .chip, .seg { min-height: 36px; }
}
/* =========================================================
   Thống kê — bảng cá nhân
   ========================================================= */
.me-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s6); align-items: end;
  padding: var(--s5) 0 var(--s5); border-bottom: 1px solid var(--line); }
.me-id { display: flex; gap: var(--s4); align-items: center; min-width: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: var(--fs-lg); letter-spacing: -0.02em; box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line-strong); }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
#dName { font-size: var(--fs-xl); letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.me-line { color: var(--muted); margin-top: 4px; max-width: 62ch; }
.me-line b { color: var(--text); font-weight: 600; }
.hero { text-align: right; min-width: 220px; }
.hero-n { font-size: 64px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.hero-l { color: var(--muted); font-size: var(--fs-sm); margin: 4px 0 10px; }
.hero .segbar { width: 220px; margin-left: auto; }
.hero-key { display: flex; justify-content: flex-end; gap: var(--s3); font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; }
.hero-key b { color: var(--text); font-weight: 600; }
.hero-key i, .seg-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Thanh chia phần mỏng: bo tròn hai đầu, khe 2px màu nền, không in chữ (tên + số nằm ở chú thích) */
.segbar { display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--sunken); }
.segbar > span { height: 100%; transform-origin: left; animation: grow-x 700ms var(--ease) both; }
.segbar.tall { height: 12px; margin-top: var(--s2); }
@keyframes grow-x { from { transform: scaleX(0); } }

/* Cần chú ý: icon + chữ + số (không chỉ dựa vào màu) */
.attn { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.attn .a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; font-size: var(--fs-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; transition: border-color var(--dur) var(--ease); }
.attn .a:hover { border-color: var(--line-strong); }
.attn .a b { font-variant-numeric: tabular-nums; }
.attn .a svg { width: 14px; height: 14px; }
.attn .a.crit { background: var(--danger-soft); border-color: transparent; } .attn .a.crit svg { color: var(--danger); }
.attn .a.warn { background: var(--attention-soft); border-color: transparent; } .attn .a.warn svg { color: var(--attention-text); }
.attn .a.info svg { color: var(--accent); }
.attn .calm { color: var(--muted); font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 8px; }
.attn .calm svg { color: var(--success); }

/* Hàng chỉ số */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s5); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); display: grid; gap: 2px; align-content: start;
  animation: rise 420ms var(--ease) both; }
.kpi:nth-child(2) { animation-delay: 60ms; } .kpi:nth-child(3) { animation-delay: 120ms; } .kpi:nth-child(4) { animation-delay: 180ms; }
.kpi .l { color: var(--muted); font-size: var(--fs-xs); }
.kpi .n { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.kpi .n small { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.kpi .d { font-size: var(--fs-xs); color: var(--muted); }
.kpi .d.up { color: var(--success); } .kpi .d.down { color: var(--danger); }
.kpi .spark { width: 100%; height: 24px; margin-top: 6px; overflow: visible; }
.kpi .spark path { fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi .spark circle { fill: var(--viz-done); stroke: var(--surface); stroke-width: 2; }

/* Khối */
.dash-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s5); margin-top: var(--s5); }
.dash-grid + .dash-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.panel-head h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.link-btn:hover { color: var(--accent-hover); }
.sub-h { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: var(--s5) 0 var(--s2); }
.sub-h .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Chú thích: tên + số */
.seg-legend { list-style: none; margin: var(--s3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: var(--fs-sm); color: var(--muted); }
.seg-legend li b { color: var(--text); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg-legend.inline { margin: 0; gap: var(--s4); font-size: var(--fs-xs); }
.sw.s-created { background: var(--viz-created); } .sw.s-done { background: var(--viz-done); }
.sw.p-doing { background: var(--pm-doing); } .sw.p-review { background: var(--pm-review); } .sw.p-new { background: var(--pm-new); } .sw.p-blocked { background: var(--pm-blocked); }

/* Danh sách dự án: tên · thanh tiến độ (cùng tông) · số */
.meters { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.meters li { display: grid; grid-template-columns: minmax(0, 1fr) 140px 64px; gap: var(--s3); align-items: center; padding: 8px; margin: 0 -8px;
  border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); }
.meters li:hover, .meters li:focus-visible { background: var(--sunken); }
.meters .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meters .nm em { font-style: normal; color: var(--danger); font-size: var(--fs-xs); margin-left: 6px; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transform-origin: left; animation: grow-x 800ms var(--ease) both; }
.meters .fig { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: var(--fs-xs); }
.meters .fig b { color: var(--text); font-weight: 600; font-size: var(--fs-sm); }
.meters .more { cursor: default; color: var(--muted); font-size: var(--fs-xs); }
.meters .more:hover { background: none; }

/* Biểu đồ cột 14 ngày */
.cols-wrap { position: relative; }
.cols { width: 100%; height: 200px; display: block; overflow: visible; }
.cols .grid { stroke: var(--line); stroke-width: 1; }
.cols .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cols .tick.today { fill: var(--text); font-weight: 600; }
.cols .c-created { fill: var(--viz-created); } .cols .c-done { fill: var(--viz-done); }
.cols .bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y 600ms var(--ease) both; }
.cols .hit { fill: transparent; }
.cols .day:hover .hit, .cols .day:focus .hit { fill: var(--sunken); }
.cols .day:focus { outline: none; }
.cols .day:focus-visible .hit { stroke: var(--accent); stroke-width: 1.5; }
.cols .val { fill: var(--text); font-size: 11px; font-weight: 600; }
@keyframes grow-y { from { transform: scaleY(0); } }
.cols-empty { height: 200px; display: grid; place-items: center; color: var(--muted); font-size: var(--fs-sm); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: var(--s4); }
.table-view { margin-top: var(--s3); font-size: var(--fs-xs); color: var(--muted); }
.table-view summary { cursor: pointer; width: fit-content; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }

/* Xếp hạng khách hàng: một tông, lớn nhất trước, số ở đầu thanh */
.rank .row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: var(--s3); align-items: center; padding: 7px 0; font-size: var(--fs-sm); }
.rank .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .bar-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank .bar-line i { height: 14px; background: var(--accent); border-radius: 0 4px 4px 0; transform-origin: left; animation: grow-x 700ms var(--ease) both; }
.rank .bar-line b { font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--fs-xs); }

.mini-list .it .src { font-size: var(--fs-xs); color: var(--muted); margin-right: 6px; }
.mini-list .d.soon { color: var(--attention-text); }

.dash-foot { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); }
.dash-foot .remind { margin-top: 0; }
.dash-foot .remind .btn { white-space: nowrap; flex: none; }
/* Trên Thống kê đã có phần "Bảng của bạn" → ẩn lời chào chung cho khỏi lặp */
body[data-view="dashboard"] .greeting { display: none; }
.me-head { padding-top: var(--s2); }

/* Tooltip dùng chung cho biểu đồ: số đậm trước, tên sau, khoá màu bằng nét ngắn */
.viz-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: var(--fs-xs); min-width: 130px; }
.viz-tip .t { color: var(--muted); margin-bottom: 4px; }
.viz-tip .r { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.viz-tip .r i { width: 12px; height: 3px; border-radius: 2px; }
.viz-tip .r b { color: var(--text); font-size: var(--fs-sm); margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .me-head { grid-template-columns: 1fr; gap: var(--s4); }
  .hero { text-align: left; }
  .hero-n { font-size: 52px; }
  .hero .segbar { width: 100%; margin: 0; }
  .hero-key { justify-content: flex-start; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .dash-grid, .dash-grid + .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .avatar.lg { width: 44px; height: 44px; font-size: var(--fs-md); }
  .meters li { grid-template-columns: minmax(0, 1fr) 64px; }
  .meters .meter { grid-column: 1 / -1; grid-row: 2; }
  .rank .row { grid-template-columns: minmax(0, 120px) minmax(0, 1fr); }
  .panel { padding: var(--s4); }
}

/* Ô số liệu tab Dự án: mỗi ô một tông theo ý nghĩa (nền nhạt cùng tông, số và chấm màu đậm) */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s3); }
.tile { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-ink: var(--accent);
  position: relative; overflow: hidden; display: grid; gap: 2px; align-content: start;
  padding: var(--s4); border-radius: var(--r-md); background: var(--tone-soft); border: 1px solid transparent;
  animation: rise 420ms var(--ease) both; }
.tile:nth-child(2) { animation-delay: 50ms; } .tile:nth-child(3) { animation-delay: 100ms; }
.tile:nth-child(4) { animation-delay: 150ms; } .tile:nth-child(5) { animation-delay: 200ms; }
.tile .tl { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 500; color: var(--text); }
.tile .tl i { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 3px color-mix(in oklch, var(--tone) 22%, transparent); }
.tile .tn { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; color: var(--tone-ink); margin-top: 4px; }
.tile .tn small { font-size: var(--fs-md); font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.tile .tnote { font-size: var(--fs-xs); color: var(--muted); }
.tile .tbar { display: block; height: 4px; border-radius: 999px; background: color-mix(in oklch, var(--tone) 18%, transparent); margin-top: 8px; overflow: hidden; }
.tile .tbar i { display: block; height: 100%; border-radius: 999px; background: var(--tone); transform-origin: left; animation: grow-x 800ms var(--ease) both; }
.tile.t-danger { --tone: var(--danger); --tone-soft: var(--danger-soft); --tone-ink: var(--danger); }
.tile.t-danger .tnote { color: var(--danger); font-weight: 500; }
.tile.t-warn { --tone: var(--attention); --tone-soft: var(--attention-soft); --tone-ink: var(--attention-text); }
.tile.t-warn .tnote { color: var(--attention-text); font-weight: 500; }
.tile.t-info { --tone: var(--info); --tone-soft: var(--info-soft); --tone-ink: var(--info); }
.tile.t-ok { --tone: var(--success); --tone-soft: var(--surface); --tone-ink: var(--text); border-color: var(--line); }
.tile.t-ok .tnote { color: var(--success); }
@media (prefers-color-scheme: dark) {
  .tile.t-info { --tone: oklch(0.72 0.11 250); --tone-ink: oklch(0.8 0.09 250); }
  .tile.t-danger { --tone-ink: oklch(0.78 0.13 28); }
  .tile.t-danger .tnote { color: oklch(0.78 0.13 28); }
  .tile.t-ok .tnote { color: oklch(0.78 0.12 155); }
}
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr 1fr; } .tile .tn { font-size: 26px; } .tile:last-child:nth-child(odd) { grid-column: 1 / -1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
