/* ==========================================================================
   CRM Phú Quý Priority — Design System v3 (mockup HTML)
   Ngôn ngữ thiết kế: Apple-inspired (xem DESIGN-apple.md)
   - Giữ màu chủ đạo Phú Quý: Đỏ rượu (accent duy nhất) + Vàng (logo/hạng)
   - Không shadow trên chrome/card, không gradient trang trí
   - Phân tầng bằng đổi màu bề mặt + hairline + backdrop-blur
   - Thang đậm 300 / 400 / 600 / 700 (bỏ 500, 800)
   - Nút hành động = pill; utility nhỏ = 8px; card = 18px
   - Nhấn nút: transform scale(.95)
   Bản cũ (v2) lưu tại: demohtml-v2-backup/
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

:root {
  /* ---- Brand (màu chủ đạo — giữ nguyên) ---- */
  --wine: #521b48;          /* Accent duy nhất cho mọi tương tác */
  --wine-hover: #3d1437;
  --wine-dark: #290f29;     /* Tile tối / sidebar */
  --wine-active: #431a40;
  --wine-light: #f7eff5;
  --wine-focus: #7a2d6c;    /* Vòng focus bàn phím */
  --wine-on-dark: #e9b8dc;  /* Link/nhấn trên nền tối */

  --gold: #e49e24;
  --gold-hover: #d48806;
  --gold-bg: #fff8e6;

  /* ---- Tier — soft badge ---- */
  --tier-diamond-text: #6b21a8;
  --tier-diamond-bg: #f3e8ff;
  --tier-diamond-border: transparent;
  --tier-platinum-text: #1d1d1f;
  --tier-platinum-bg: #ececf0;
  --tier-platinum-border: transparent;
  --tier-gold-text: #8a4b08;
  --tier-gold-bg: #fdf1d6;
  --tier-gold-border: transparent;
  --tier-none-text: #6e6e73;
  --tier-none-bg: #f0f0f3;
  --tier-none-border: transparent;

  /* ---- Status — ngữ nghĩa (bắt buộc cho CRM) ---- */
  --danger: #c9182b;
  --danger-bg: #fdf0f1;
  --danger-border: transparent;
  --warning: #c27803;
  --warning-bg: #fef8ec;
  --warning-border: #f6dfa8;
  --success: #1f7a3a;
  --success-bg: #eff8f1;
  --success-border: transparent;
  --info: #0b5cad;
  --info-bg: #eef5fc;
  --info-border: transparent;

  /* ---- Neutral — Apple ink & parchment ---- */
  --bg-layout: #f5f5f7;     /* parchment */
  --bg-container: #ffffff;  /* canvas */
  --bg-subtle: #fafafc;     /* pearl */
  --border: #e8e8ed;        /* hairline mềm */
  --border-strong: #d2d2d7; /* hairline rõ */
  --divider: #f0f0f2;
  --text: #1d1d1f;          /* ink */
  --text-2: #333336;
  --text-3: #6e6e73;
  --text-4: #a1a1a6;

  /* ---- Shape ---- */
  --r-xs: 5px;
  --r-tag: 9999px;
  --r-control: 8px;         /* utility */
  --r-field: 11px;          /* ô nhập */
  --r-card: 18px;           /* utility card */
  --r-card-lg: 18px;
  --r-pill: 9999px;

  /* ---- Layout ---- */
  --sider-w: 260px;
  --header-h: 56px;
  --page-pad: 32px;

  /* ---- Elevation: không shadow trên UI ---- */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --hairline: 1px solid var(--border);
  --frost: saturate(180%) blur(20px);

  /* ---- Type ---- */
  --font-text: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-display: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font: var(--font-text);
  --track-tight: -0.022em;  /* ≈ -0.374px @17px */
  --track-body: -0.011em;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-layout);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: var(--track-body);
  font-feature-settings: "ss03", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

b, strong { font-weight: 600; }

a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--wine-focus); outline-offset: 2px; }

.mono { font-family: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace; letter-spacing: 0; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app { display: flex; min-height: 100vh; }

/* ---- Sidebar — tile tối màu rượu, phẳng ---- */
.sider {
  flex: 0 0 var(--sider-w);
  width: var(--sider-w);
  background: var(--wine-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sider-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 4px; }

.sider-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-control);
  background: var(--gold);
  color: var(--wine-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  flex: none;
}

.sider-brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 20px; letter-spacing: var(--track-tight); }
.sider-brand-sub { font-size: 11px; color: var(--gold); letter-spacing: 0.06em; font-weight: 600; }

.sider-group-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 255, 255, 0.48);
  padding: 0 10px 6px;
}

.sider-nav { display: flex; flex-direction: column; gap: 2px; }

.sider-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--r-control);
  color: rgba(255, 255, 255, 0.82);
  font-weight: 400;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.sider-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sider-link:active { transform: scale(0.98); }
.sider-link.active { background: rgba(255, 255, 255, 0.13); color: #fff; font-weight: 600; }
.sider-subnav { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px 18px; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, 0.14); }
.sider-subnav[hidden] { display: none; }
.sider-chev { font-size: 11px; opacity: 0.7; transition: transform .15s; margin-left: auto; padding: 2px 4px; flex: none; }
.sider-link.open .sider-chev { transform: rotate(180deg); }
.sider-sublink {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px;
  color: rgba(255, 255, 255, 0.72); font-size: 12.5px; font-weight: 400;
  text-decoration: none; transition: background .12s, color .12s;
}
.sider-sublink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sider-sublink.active { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 600; }
.sider-link .ico { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.sider-link .label { flex: 1; }
.sider-link .count {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--gold);
  color: var(--wine-dark);
  border-radius: var(--r-pill);
  padding: 0 7px;
  line-height: 18px;
  letter-spacing: 0;
}

.sider-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.56);
  line-height: 18px;
}
.sider-foot b { color: rgba(255, 255, 255, 0.9); }

/* ---- Main ---- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* Header — frosted glass, không shadow */
.header {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: var(--frost);
  backdrop-filter: var(--frost);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0 var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-crumb { font-size: 12px; color: var(--text-3); }
.header-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: var(--track-tight);
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-right { display: flex; align-items: center; gap: 10px; }

.badge-brand {
  background: var(--wine);
  color: #fff;
  padding: 3px 10px;
  border-radius: var(--r-tag);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.page { padding: var(--page-pad); display: flex; flex-direction: column; gap: 24px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-sub { font-size: 15px; color: var(--text-3); margin: 6px 0 0; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   Card / panel — store-utility-card
   ========================================================================== */

.card {
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: none;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 14px;
  border-bottom: 0;
}
.card-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: var(--track-tight);
  line-height: 1.2;
}
.card-title-sm { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: var(--track-body); }
.card-sub { font-size: 13.5px; color: var(--text-3); margin: 4px 0 0; }
.card-body { padding: 6px 24px 24px; }
.card-body-flush { padding: 0; }

/* Tile tối phẳng (thay cho banner gradient) */
.tile-dark { background: var(--wine-dark); color: #fff; border-radius: var(--r-card); }
.tile-dark a { color: var(--wine-on-dark); }

.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* ==========================================================================
   KPI tiles
   ========================================================================== */

.kpi {
  background: var(--bg-container);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 13.5px; color: var(--text-3); font-weight: 400; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.kpi-value.sm { font-size: 26px; }
.kpi-value small, .kpi-value .unit { font-size: 15px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }
.kpi-foot { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
/* Bỏ thanh màu trang trí bên trái — Apple không dùng khung trang trí */
.kpi-accent { display: none; }

.delta-up { color: var(--success); font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

/* ==========================================================================
   Buttons — pill grammar
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--wine);
  color: #fff;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: var(--track-body);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--wine-hover); text-decoration: none; }
.btn:active { transform: scale(0.95); }
.btn:focus-visible { outline: 2px solid var(--wine-focus); outline-offset: 2px; }

/* Ghost pill — CTA thứ hai */
.btn-outline { background: transparent; border-color: var(--wine); color: var(--wine); }
.btn-outline:hover { background: var(--wine-light); border-color: var(--wine); color: var(--wine); }

.btn-gold { background: var(--gold); color: var(--wine-dark); }
.btn-gold:hover { background: var(--gold-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; color: var(--wine); padding: 0 10px; }
.btn-ghost:hover { background: var(--wine-light); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Header utility: nút pearl capsule trung tính */
.header .btn-outline {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-field);
}
.header .btn-outline:hover { background: #fff; color: var(--wine); border-color: var(--border-strong); }

/* ==========================================================================
   Tags / badges
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0;
  border: 0;
  white-space: nowrap;
}
.tier-diamond { color: var(--tier-diamond-text); background: var(--tier-diamond-bg); border-color: var(--tier-diamond-border); }
.tier-platinum { color: var(--tier-platinum-text); background: var(--tier-platinum-bg); border-color: var(--tier-platinum-border); }
.tier-gold { color: var(--tier-gold-text); background: var(--tier-gold-bg); border-color: var(--tier-gold-border); }
.tier-none { color: var(--tier-none-text); background: var(--tier-none-bg); border-color: var(--tier-none-border); }
.tier-wine { color: #521b48; background: #f8eff6; border-color: #d9b8d3; }
.tier-teal { color: #0f5e59; background: #e6f7f5; border-color: #99dbd4; }
.tier-amber { color: #8a5300; background: #fff4e0; border-color: #f0cc8a; }
.tag-danger { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.tag-warning { color: #8a5300; background: var(--warning-bg); border-color: transparent; }
.tag-success { color: var(--success); background: var(--success-bg); border-color: transparent; }
.tag-info { color: var(--info); background: var(--info-bg); border-color: transparent; }
.tag-neutral { color: var(--text-2); background: #f0f0f3; border-color: transparent; }
.tag-gold { color: var(--tier-gold-text); background: var(--tier-gold-bg); border-color: transparent; }

/* ==========================================================================
   Table — hairline, không kẻ đậm
   ========================================================================== */

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14.5px; }
table.tbl th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  background: transparent;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background 0.12s; }
table.tbl tbody tr:hover { background: var(--bg-subtle); }
table.tbl tbody tr.row-danger { background: var(--danger-bg); }
table.tbl tbody tr.row-danger:hover { background: #fbe4e6; }
table.tbl tbody tr.row-warn { background: var(--warning-bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.dim { color: var(--text-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }

/* ==========================================================================
   Form controls
   ========================================================================== */

.input, .select {
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-field);
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  letter-spacing: var(--track-body);
  color: var(--text);
  background: #fff;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-4); }
.input:focus, .select:focus {
  border-color: var(--wine-focus);
  box-shadow: 0 0 0 3px rgba(82, 27, 72, 0.14);
}
textarea.input { height: auto; min-height: 40px; padding: 10px 14px; resize: vertical; line-height: 1.47; }
.select { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.select .chev { margin-left: auto; color: var(--text-4); }

/* search-input — pill 44px */
.input-search { padding-left: 38px; border-radius: var(--r-pill); }
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap .mag { position: absolute; left: 14px; color: var(--text-4); pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox .box {
  width: 18px; height: 18px; border: 1px solid var(--border-strong);
  border-radius: var(--r-xs); display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; flex: none; background: #fff;
}
.checkbox .box.on { background: var(--wine); border-color: var(--wine); }

/* Switch — iOS */
.switch { width: 44px; height: 26px; border-radius: 9999px; background: #e3e3e8; position: relative; display: inline-block; flex: none; cursor: pointer; transition: background 0.2s; border: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.18); }
.switch.on { background: var(--wine); }
.switch.on::after { left: 20px; }

/* ==========================================================================
   Segment pills — configurator-option-chip
   ========================================================================== */

.pill-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s;
}
.pill:hover { border-color: var(--wine); color: var(--wine); }
.pill:active { transform: scale(0.95); }
.pill.active { background: var(--wine); border-color: var(--wine); color: #fff; font-weight: 600; box-shadow: none; }
.pill .n { font-size: 12.5px; opacity: 0.7; font-variant-numeric: tabular-nums; }
/* Mức ưu tiên: chấm màu thay viền trái */
.pill-lv1::before, .pill-lv2::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pill-lv1::before { background: var(--danger); }
.pill-lv2::before { background: var(--warning); }

/* ==========================================================================
   Progress
   ========================================================================== */

.progress { height: 8px; border-radius: 9999px; background: #e8e8ed; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 9999px; background: var(--wine); }
.progress.gold > span { background: var(--gold); }
.progress.danger > span { background: var(--danger); }
.progress.warn > span { background: var(--warning); }
.progress.sm { height: 5px; }

/* ==========================================================================
   Kanban
   ========================================================================== */

.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.kb-col { background: #ececf0; border: 0; border-radius: var(--r-card); display: flex; flex-direction: column; min-height: 220px; padding: 6px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; border-bottom: 0; }
.kb-head-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kb-head .n { font-size: 12px; color: var(--text-2); background: #fff; border: 0; border-radius: 9999px; padding: 1px 9px; font-weight: 600; }
.kb-body { padding: 6px; display: flex; flex-direction: column; gap: 8px; }
.kb-card {
  background: #fff;
  border: 0;
  border-radius: var(--r-field);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: none;
  position: relative;
}
/* Mức ưu tiên đã hiển thị bằng prio-flag trong thẻ — bỏ viền trái trang trí */
.kb-card.pinned { background: var(--danger-bg); }
.kb-card-title { font-size: 14px; font-weight: 600; line-height: 20px; }
.kb-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kb-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-3); }

/* ==========================================================================
   Alerts / callouts
   ========================================================================== */

.alert {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-field);
  font-size: 14px;
  border: 0;
  align-items: flex-start;
}
.alert .ico { flex: none; margin-top: 1px; }
.alert-danger { background: var(--danger-bg); color: #8f1220; }
.alert-warning { background: var(--warning-bg); color: #7a4a00; }
.alert-info { background: var(--info-bg); color: #0a4a8a; }
.alert-success { background: var(--success-bg); color: #175e2d; }
.alert b { font-weight: 600; }

/* ==========================================================================
   Steps
   ========================================================================== */

.steps { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-3); }
.step .num {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.step.done .num { background: var(--success); border-color: var(--success); color: #fff; }
.step.done { color: var(--text-2); }
.step.active .num { background: var(--wine); border-color: var(--wine); color: #fff; }
.step.active { color: var(--wine); font-weight: 600; }
.step-line { width: 44px; height: 1px; background: var(--border-strong); margin: 0 10px; }

/* ==========================================================================
   Timeline
   ========================================================================== */

.tl { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--divider); }
.tl-item:last-child { border-bottom: 0; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--wine); margin-top: 7px; flex: none; }
.tl-dot.danger { background: var(--danger); }
.tl-dot.success { background: var(--success); }
.tl-dot.warning { background: var(--warning); }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-size: 14.5px; font-weight: 600; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ==========================================================================
   Modal — nền mờ + blur, không shadow
   ========================================================================== */

.modal-mask {
  position: fixed; inset: 0; background: rgba(29, 29, 31, 0.36);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.modal-mask[hidden] { display: none; }

/* ==========================================================================
   Info Tip (biểu tượng chữ i + tooltip khi hover)
   ========================================================================== */

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(29, 29, 31, 0.08);
  color: var(--text-2);
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  margin-left: 6px;
  flex: none;
  transition: background .12s, color .12s;
}
.info-tip:hover, .info-tip:focus-visible {
  background: var(--wine);
  color: #fff;
  outline: none;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: max-content;
  max-width: 300px;
  padding: 9px 12px;
  border-radius: 9px;
  background: #1d1d1f;
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
  z-index: 160;
}
.info-tip:hover::after, .info-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.modal {
  background: #fff; border-radius: var(--r-card-lg); box-shadow: none;
  border: 1px solid rgba(0, 0, 0, 0.06);
  width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { padding: 22px 24px 12px; border-bottom: 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0; letter-spacing: var(--track-tight); }
.modal-body { padding: 6px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-subtle); }

/* ==========================================================================
   Drawer
   ========================================================================== */

.drawer-mask { position: fixed; inset: 0; background: rgba(29, 29, 31, 0.28); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 92vw;
  background: #fff; box-shadow: none; border-left: 1px solid var(--border); z-index: 91;
  display: flex; flex-direction: column;
}
.drawer-head { padding: 22px 24px 12px; border-bottom: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.drawer-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--bg-subtle); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 12px 16px; font-size: 14.5px; font-weight: 400; color: var(--text-3);
  border-bottom: 2px solid transparent; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit; letter-spacing: var(--track-body); margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--wine); font-weight: 600; }

/* ==========================================================================
   Misc utilities
   ========================================================================== */

.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap4 { gap: 4px; } .gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.divider { height: 1px; background: var(--border); }
.vsep { width: 1px; align-self: stretch; background: var(--border); }
.divider-v { width: 1px; height: 28px; background: var(--border); }

.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 68px; align-items: center; gap: 12px; }
.bar-label { font-size: 13.5px; color: var(--text-2); }
.bar-track { height: 16px; background: #ececf0; border-radius: 9999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 9999px; }
.bar-value { font-size: 13.5px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.donut-legend { display: flex; flex-direction: column; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--wine-light); color: var(--wine);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13.5px; flex: none; letter-spacing: 0;
}
.avatar.gold { background: var(--gold-bg); color: #874d00; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; align-items: baseline; }
.kv dt { color: var(--text-3); font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 600; }

.code-block {
  background: #1d1d1f; color: #e6e6e6; border-radius: var(--r-field);
  padding: 13px 15px; font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 13px;
  line-height: 20px; overflow-x: auto; white-space: pre; letter-spacing: 0;
}
.code-block .add { color: #7ee787; }
.code-block .del { color: #ffa198; }
.code-block .key { color: #79c0ff; }

.scroll-y { overflow-y: auto; }

/* Index hub — utility card grid */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.hub-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 24px; display: flex; flex-direction: column; gap: 8px; box-shadow: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.hub-card:hover { border-color: var(--wine); text-decoration: none; }
.hub-card:active { transform: scale(0.98); }
.hub-code { font-size: 12px; font-weight: 600; color: var(--wine); letter-spacing: 0.02em; }
.hub-name { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: var(--track-tight); line-height: 1.24; }
.hub-desc { font-size: 13.5px; color: var(--text-3); line-height: 1.43; }
.hub-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}

@media (max-width: 834px) {
  :root { --page-pad: 20px; --sider-w: 64px; }
  .page-title { font-size: 26px; }

  /* Sidebar thu gon thanh rail icon-only de con ngang cho noi dung */
  .sider { padding: 16px 8px 12px; align-items: center; }
  .sider-brand-name, .sider-brand-sub, .sider-group-label, .sider-link .label, .sider-foot { display: none; }
  .sider-brand { justify-content: center; padding: 0; }
  .sider-nav { width: 100%; }
  .sider-link { justify-content: center; padding: 0; }
  .sider-link .count { position: absolute; margin-left: 22px; margin-top: -14px; font-size: 10px; padding: 0 5px; }

  /* Header: cho phep phan phai co lai/thu gon thay vi day trang ra ngoai viewport */
  .header-right { min-width: 0; overflow: hidden; }
  .header-right .btn-outline { display: none; }
  .header-right .row { min-width: 0; }

  /* Tabs: cuon ngang thay vong lam trang doc */
  .tabs {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }

  /* Page head: nut thu gon xuong dong moi */
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
}
