/* =====================================================================
   GIAO DIỆN — mặc định "MODERN ZEN"
   Đổi giao diện: chỉ sửa khối :root (mục 1). Các mục khác dùng biến.
   ===================================================================== */

/* ---------- 1. Design tokens (biến dùng chung) ---------- */
/* LnD Portal: Modern Zen tông đỏ (duyệt 05/11/2026). Tên biến giữ nguyên để không phải sửa các mục dưới. */
:root {
  /* Màu chủ đạo */
  --deep-sage: #8E0F16;
  --sage: #B0121F;
  --muted-green: #C8102E;
  --soft-sage: #D9707A;
  --dark-forest: #6E0B12;
  --gradient: linear-gradient(125deg, #8E0F16, #C8102E);

  /* Nền */
  --bg-page: #F6F2EE;
  --bg-card: #FFFEFB;
  --bg-soft: #FAF6F3;
  --bg-item: #FBF8F6;
  --bg-profile: #FBF4F3;
  --bg-icon: #FBE9EA;
  --border: #EADFDA;

  /* Chữ */
  --text: #4A3F3F;
  --text-muted: #74676A;
  --text-label: #5C3A3C;
  --text-heading: #3A1E20;

  /* Trạng thái (luôn kèm chữ, không dùng màu một mình) */
  --success: #2F5D47;  --success-bg: #EAF2EC;
  --warning: #7A5A2E;  --warning-bg: #F7EFE2;
  --error:   #9B1C2C;  --error-bg:   #FFF4F4;  --error-border: #F0D2D4;

  /* Font */
  --font-serif: 'Noto Serif', Georgia, serif;
  --font-sans: 'Be Vietnam Pro', system-ui, sans-serif;

  /* Bóng đổ & góc bo */
  --shadow-card: 0 10px 30px #6B4A4A12;
  --shadow-btn: 0 10px 22px #8E0F1628;
  --radius-frame: 30px 66px 28px 28px;   /* góc bất đối xứng — nét riêng của Modern Zen */
  --radius-hero: 25px 65px 25px 25px;
  --radius-card: 26px;

  /* Màu phụ (đường kẻ, ô nhập, chip, focus…) */
  --line-soft: #F0E8E5;
  --input-border: #E2D6D3;   --input-hover: #D4B9B6;   --placeholder: #8F8486;   --disabled-bg: #F3EEEC;
  --focus-border: #C8102E;   --focus-ring: #C8102E1F;
  --chip-bg: #F8EEEC;        --chip-border: #E8D3D1;
  --outline-border: #E3C9C6;
  --profile-border: #EADAD7;
  --success-border: #CFE3D6; --danger-border: #E8C7C9; --error-soft: #FFF1F1;
  --hero-text: #FDEBEC;
  --warning-border: #EBDDC4; --check-border: #C9A9A6;
}

/* ---------- 2. Nền tảng ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}
h1, h2, h3 { font-family: var(--font-serif); color: var(--text-heading); margin: 0; }
h1 { font-size: 27px; font-weight: 400; }
h2 { font-size: 21px; font-weight: 500; }
a { color: var(--sage); }
a:hover { color: var(--dark-forest); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ---------- 3. Bố cục ---------- */
.container { max-width: 1000px; margin: 30px auto; padding: 0 22px 60px; display: flex; flex-direction: column; gap: 20px; }

.top-frame {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-frame); padding: 27px 36px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 22px;
}
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 14px; background: var(--gradient);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-name { font-family: var(--font-serif); font-size: 30px; color: var(--text-heading); line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--text-muted); }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.profile-chip {
  display: flex; align-items: center; gap: 10px; background: var(--bg-profile);
  border: 1px solid var(--profile-border); border-radius: 20px; padding: 6px 14px 6px 6px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sage); color: #fff;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.profile-name { font-size: 14px; font-weight: 600; color: var(--text-heading); line-height: 1.3; }
.profile-role { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

/* Thanh menu: các hàng cuộn ngang KHÔNG được co lại (bài học từ mockup) */
.main-nav { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.nav-link {
  min-height: 44px; display: inline-flex; align-items: center; padding: 10px 18px;
  border-radius: 25px; background: var(--chip-bg); border: 1px solid var(--chip-border);
  color: var(--text-label); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.nav-link:hover { transform: translateY(-2px); color: var(--text-label); }
.nav-link.active { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: var(--shadow-btn); }

/* ---------- 4. Thẻ (card) & hero ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 30px 36px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 16px;
}
.card-head { display: flex; align-items: center; gap: 14px; }
.section-icon {
  width: 37px; height: 37px; border-radius: 13px; background: var(--bg-icon);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hero {
  background: var(--gradient); border-radius: var(--radius-hero); padding: 32px 36px;
  box-shadow: 0 12px 26px #2F4F4F1F; color: #fff; display: flex; flex-direction: column; gap: 6px;
}
.hero h1 { color: #fff; }
.hero p { margin: 0; color: var(--hero-text); font-size: 14px; }
.placeholder {
  background: var(--bg-item); border: 1px dashed var(--outline-border); border-radius: 18px;
  padding: 18px 20px; color: var(--text-muted); font-size: 14px;
}

/* ---------- 5. Nút ---------- */
.btn {
  min-height: 46px; padding: 12px 20px; border-radius: 25px; border: 0;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .2s, box-shadow .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-btn); }
.btn-secondary { background: var(--chip-bg); color: var(--text-label); border: 1px solid var(--chip-border); }
.btn-outline { background: var(--bg-card); color: var(--sage); border: 1px solid var(--outline-border); }
.btn-small { min-height: 44px; padding: 10px 16px; }
.btn-icon { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; position: relative; }
.badge {
  min-width: 20px; height: 20px; border-radius: 10px; background: var(--sage); color: #fff;
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.btn-icon .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; font-size: 11px; }

/* ---------- 6. Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text-label); }
.field input, .field select, .field textarea {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--input-border); background: var(--bg-card);
  color: var(--deep-sage); font-family: inherit; font-size: 15px; padding: 12px 13px; font-weight: 400;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring);
}
.alert { display: flex; align-items: center; gap: 10px; border-radius: 14px; padding: 10px 14px; font-size: 13px; }
.alert-error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error); }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }

/* ---------- 7. Trang đăng nhập ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 22px; }
.login-wrap { width: 100%; max-width: 1000px; display: flex; flex-wrap: wrap; gap: 20px; }
.login-hero {
  flex: 1 1 380px; min-width: 0; background: var(--gradient); border-radius: var(--radius-hero);
  padding: 40px 36px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  box-shadow: 0 12px 26px #2F4F4F1F;
}
.login-hero h1 { color: #fff; font-size: 34px; line-height: 1.3; }
.login-hero p { color: var(--hero-text); max-width: 380px; }
.login-card {
  flex: 1 1 380px; min-width: 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-frame); padding: 40px 36px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
}
.login-card form { display: flex; flex-direction: column; gap: 18px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 14px; border-radius: 20px; background: #FFFFFF1F; border: 1px solid #FFFFFF33; }

/* ---------- 8. Popup (dialog) ---------- */
dialog.popup {
  width: min(480px, calc(100vw - 24px)); border: 1px solid var(--border); padding: 28px 30px;
  background: var(--bg-card); border-radius: var(--radius-frame); box-shadow: 0 24px 60px #273E3633;
  color: var(--text); font-family: var(--font-sans);
}
dialog.popup::backdrop { background: #273E3659; }
.popup-body { display: flex; flex-direction: column; gap: 18px; }
.popup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.seg {
  min-height: 44px; padding: 8px 4px; border-radius: 22px; border: 1px solid var(--chip-border); background: var(--bg-card);
  color: var(--text-label); font-family: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.seg.active { border-color: var(--sage); background: var(--success-bg); color: var(--text-heading); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.timer-display {
  background: var(--bg-item); border: 1px solid var(--border); border-radius: 18px; padding: 18px; text-align: center;
  font-family: var(--font-serif); font-size: 55px; color: var(--text-heading); line-height: 1.1; letter-spacing: 2px;
}

/* ---------- 8b. Thành phần dùng chung (trang, thẻ, bảng nhỏ, ô thống kê) ---------- */
.page { display: flex; flex-direction: column; gap: 20px; }
.page h1 { font-size: 27px; font-weight: 400; }
.text-heading { color: var(--text-heading); }
.text-err { color: var(--error); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page-head { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 24px 36px; }
.card-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* Tab dạng nút (VHPT · Nghề · Personal growth) — hàng cuộn ngang không được co lại */
.seg-tabs { display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0; }
.seg-tab {
  flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; padding: 8px 18px; border-radius: 22px;
  border: 1px solid var(--chip-border); background: var(--bg-card); color: var(--text-label); font-size: 14px; font-weight: 600; text-decoration: none;
}
.seg-tab.active { border-color: var(--sage); background: var(--success-bg); color: var(--text-heading); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat-tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 16px 20px; box-shadow: var(--shadow-card); }
.stat-value { font-family: var(--font-serif); font-size: 28px; color: var(--text-heading); line-height: 1.2; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.subject-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 24px; padding: 22px 24px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: inherit;
  transition: transform .2s, box-shadow .2s;
}
.subject-card:hover { transform: translateY(-2px); color: inherit; box-shadow: 0 14px 32px #68685D1F; }
.subject-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.subject-name { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-size: 20px; font-weight: 500; color: var(--text-heading); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.metric { background: var(--bg-item); border-radius: 14px; padding: 8px 4px; }
.metric-value { font-size: 20px; font-weight: 700; color: var(--text-heading); }
.metric-label { font-size: 11px; color: var(--text-muted); }
.grade-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
.add-tile, .empty-tile {
  min-height: 200px; border: 1.5px dashed var(--outline-border); border-radius: 24px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; padding: 22px; text-align: center;
}
.add-tile { color: var(--sage); font-weight: 600; text-decoration: none; }
.add-tile span { font-size: 28px; line-height: 1; }
.empty-tile { background: var(--bg-item); }

.pill-status { font-size: 12px; font-weight: 600; padding: 2px 12px; border-radius: 20px; white-space: nowrap; }
.pill-ok { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-err { background: var(--error-soft); color: var(--error); }
.pill-neutral { background: var(--chip-bg); color: var(--text-label); }

.subject-hero { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; }
.hero-kicker { font-size: 12px; color: var(--hero-text); font-weight: 600; letter-spacing: .5px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--hero-text); }
.hero-stats b { color: #fff; font-size: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-light { background: var(--bg-card); color: var(--text-heading); text-decoration: none; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-label); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table .num { text-align: right; }
.list-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; background: var(--bg-item); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.list-link { text-decoration: none; color: inherit; }
.list-link:hover { border-color: var(--outline-border); color: inherit; }

.entry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.entry-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px 18px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-card); text-decoration: none; color: inherit; box-shadow: var(--shadow-card);
}
a.entry-tile:hover { border-color: var(--sage); color: inherit; }
.entry-tile-title { font-size: 15px; font-weight: 600; color: var(--text-heading); }
.entry-tile.is-soon { opacity: .65; box-shadow: none; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch input:checked + span { border-color: var(--bg-card); box-shadow: 0 0 0 2px var(--dark-forest); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 3px #526F6366; }
.cell-input {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--input-border); background: var(--bg-card);
  color: var(--deep-sage); font-family: inherit; font-size: 15px; padding: 8px 10px;
}
.cell-input.narrow { width: 80px; text-align: center; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--text-label); min-height: 44px; }
.check-row input { width: 20px; height: 20px; accent-color: var(--sage); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-actions .spacer { flex: 1; }
.btn-danger-outline { background: var(--bg-card); color: var(--error); border: 1px solid var(--danger-border); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  padding: 12px 20px; border-radius: 16px; font-size: 14px; font-weight: 600; box-shadow: 0 12px 28px #273E3633;
}
.toast-ok { background: var(--dark-forest); color: #fff; }
.toast-error { background: var(--error); color: #fff; }

/* ---------- 9. Thanh điều hướng điện thoại ---------- */
.bottom-nav { display: none; }

@media (max-width: 600px) {
  .container { margin: 12px auto; padding: 0 10px 96px; gap: 14px; }
  .top-frame { padding: 16px 18px; border-radius: 22px 44px 22px 22px; }
  .brand-name { font-size: 23px; }
  .brand-sub, .profile-chip .profile-text, .top-frame .main-nav, .btn-label, #logout-btn { display: none; }
  .top-row { flex-wrap: nowrap; }
  .top-actions { flex-wrap: nowrap; gap: 8px; }
  .top-actions .btn-small { width: 44px; padding: 0; border-radius: 50%; position: relative; }
  .top-actions .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; font-size: 11px; }
  .profile-chip { padding: 0; border: 0; background: none; }
  .avatar { width: 44px; height: 44px; }
  .seg-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { gap: 14px; }
  .page-head { padding: 20px 18px; }
  .subject-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 22px; }
  .add-tile, .empty-tile { min-height: 120px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .cell-input { font-size: 16px; }
  .field input, .field select, .field textarea { font-size: 16px; }   /* iPhone tự phóng to khi chữ < 16px */   /* màn hẹp: 2 nút mỗi hàng để chữ không bị cắt */
  /* Đồng hồ đang chạy: nút Focus nở ra để hiện số đếm ngược */
  .top-actions #open-focus.running { width: auto; padding: 0 12px; border-radius: 22px; }
  .top-actions #open-focus.running .btn-label { display: inline; }
  .top-actions #open-focus.running svg { display: none; }
  .brand { gap: 10px; min-width: 0; }
  .brand-logo { width: 36px; height: 36px; border-radius: 12px; }
  .brand-name { font-size: 21px; white-space: nowrap; }
  .card { padding: 22px 18px; }
  .hero { padding: 24px 20px; border-radius: 22px 48px 22px 22px; }
  .hero h1 { font-size: 21px; }
  h2 { font-size: 19px; }
  /* Trang đăng nhập trên điện thoại: khối giới thiệu gọn lại để form hiện ngay */
  .login-page { align-items: flex-start; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); }
  .login-wrap { gap: 14px; }
  .login-hero { padding: 20px 22px; gap: 14px; border-radius: 22px 48px 22px 22px; }
  .login-hero h1 { font-size: 19px; line-height: 1.4; }
  .login-hero p, .login-pills { display: none !important; }  /* !important: thắng style viết trực tiếp trong HTML */
  .login-card { padding: 28px 22px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg-card); border-top: 1px solid var(--border); padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
    z-index: 10;
  }
  .bottom-nav a {
    min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; font-size: 11px; font-weight: 500; color: var(--text-muted);
  }
  .bottom-nav a.active { color: var(--text-heading); font-weight: 600; }
}

/* Tôn trọng người dùng bật "giảm chuyển động" */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* B40 fix: grade-parts table on phone, the name column gets the room */
@media (max-width: 600px) {
  .cell-input.narrow { width: 52px; padding-left: 4px; padding-right: 4px; }
  .comp-table th, .comp-table td { padding-left: 4px; padding-right: 4px; }
  .comp-table td:first-child { width: 100%; }
  .comp-table .cell-input:not(.narrow) { min-width: 110px; }
}


/* ---------- 11. Ô ngày / giờ tự vẽ (tiếng Anh, 24h, không tràn khung) ---------- */
.dt-wrap { position: relative; display: block; width: 100%; min-width: 0; }
.dt-wrap > input:not(.dt-face) { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0; }
.dt-face {
  display: flex; align-items: center; width: 100%; min-height: 48px; box-sizing: border-box; padding: 12px 36px 12px 13px;
  border-radius: 14px; border: 1px solid var(--input-border); background: var(--bg-card); color: var(--deep-sage);
  font-family: inherit; font-size: 15px; font-weight: 400; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dt-face.is-empty { color: var(--placeholder); }
.dt-face:hover { border-color: var(--input-hover); }
.dt-face:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }
.dt-face:disabled { background: var(--disabled-bg); color: var(--placeholder); cursor: not-allowed; }
.dt-wrap.is-cell .dt-face { min-height: 40px; padding: 8px 30px 8px 10px; border-radius: 12px; font-size: 14px; }
.dt-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.dt-clear:hover { background: var(--bg-item); color: var(--text-heading); }
.dt-clear[hidden] { display: none; }
input.dt-face.dt-type { cursor: text; font-variant-numeric: tabular-nums; }
input.dt-face.dt-type::placeholder { color: var(--placeholder); }
input.dt-face.dt-type:focus { outline: 2px solid var(--sage); outline-offset: 2px; }
.dt-wrap.is-bad .dt-face { border-color: var(--error); color: var(--error); }
@media (max-width: 600px) { .dt-face { font-size: 16px; } }


/* ---------- 13. Thống kê, bảng, biểu đồ (dùng cho trang Analytics và Admin) ---------- */
.an-card { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.an-title { margin: 0; font-size: 28px; }
.an-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.an-tabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 16px; border-radius: 18px; color: var(--text-label); font-size: 14px; font-weight: 600; text-decoration: none; }
.an-tabs a.on { background: var(--bg-card); color: var(--text-heading); box-shadow: 0 2px 6px #00000012; }
.an-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.an-range-f { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.an-range-f .dt-wrap { width: 168px; }
.an-range-f .dt-face { min-height: 40px; padding: 8px 12px; font-size: 14px; border-radius: 12px; }
#an-body { display: flex; flex-direction: column; gap: 16px; }
.an-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.an-tile { background: var(--bg-item); box-shadow: none; }
.an-sub { font-size: 12px; font-weight: 600; color: var(--sage); }
.an-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.an-split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: stretch; }
.an-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 22px; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.an-box h2 { font-size: 18px; margin: 0; }
.an-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.an-plot { position: relative; }
.an-plot svg { display: block; touch-action: pan-y; }
.an-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--dark-forest); color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 12px; display: flex; flex-direction: column; line-height: 1.35; white-space: nowrap; }
.an-tip span { color: var(--success-border); font-size: 11px; }
.an-empty { padding: 40px 0; text-align: center; }
.an-tablebox { margin-top: 6px; }
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.an-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.an-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.an-table td.muted { white-space: nowrap; }
.an-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.an-table td b { color: var(--text-heading); }
.an-row { cursor: pointer; }
.an-row:hover td, .an-row:focus td { background: var(--bg-item); }
.an-row:focus { outline: 2px solid var(--sage); outline-offset: -2px; }
.an-subj { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-heading); }
.an-subj i, .an-line i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.an-up { color: var(--sage); font-weight: 600; }
.an-down { color: var(--error); font-weight: 600; }
.an-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.an-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.an-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.an-line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.an-line-main b { color: var(--text-heading); font-size: 14px; overflow-wrap: anywhere; }
.an-line-main:hover b { text-decoration: underline; }
.an-log { font-size: 13px; font-weight: 600; white-space: nowrap; }
.an-topics { display: flex; flex-wrap: wrap; gap: 8px; }
.an-topic { display: inline-flex; gap: 6px; align-items: center; padding: 4px 12px; border-radius: 20px; background: var(--bg-soft); border: 1px solid var(--border); font-size: 13px; color: var(--text-heading); }
.an-topic b { color: var(--text-muted); font-weight: 600; }

.an-grades { display: flex; flex-direction: column; }
.an-grade { display: grid; grid-template-columns: 150px minmax(0, 1fr) 70px 230px; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--text); }
.an-grade:hover .an-subj { text-decoration: underline; }
.an-grade-avg { font-family: var(--font-serif); font-size: 20px; font-weight: 400; color: var(--text-heading); text-align: right; }
.an-grade-st { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.an-bullet { position: relative; height: 34px; }
.an-bullet-track, .an-bullet-fill { position: absolute; left: 0; top: 16px; height: 10px; border-radius: 5px; }
.an-bullet-track { right: 0; background: var(--line-soft); }
.an-bullet-mark { position: absolute; top: 8px; width: 2px; height: 26px; margin-left: -1px; background: var(--text-heading); }
.an-bullet-lab { position: absolute; top: -4px; margin-left: 6px; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.an-line-link { text-decoration: none; color: var(--text); }
.an-line-link:hover b { text-decoration: underline; }

@media (max-width: 980px) {
  .an-grade { grid-template-columns: 120px minmax(0, 1fr) 60px; }
  .an-grade-st { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .an-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-grid2, .an-split { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .an-title { font-size: 24px; }
  .an-bar { flex-direction: column; align-items: stretch; }
  .an-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .an-tabs a { justify-content: center; }
  .an-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
  .an-range-f { flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; }
  .an-range-f .dt-face { padding: 8px 8px; font-size: 13px; }
  .an-range #an-reset { padding-bottom: 10px; }
  .an-tabs { min-width: 0; }
  .an-range-f .dt-wrap { width: auto; }
  .an-tiles { gap: 8px; }
  .an-tile { padding: 10px 12px; }
  .an-tile .stat-value { font-size: 22px; }
  .an-box { padding: 14px; }
  .an-hide-s { display: none; }
  .an-grade { grid-template-columns: minmax(0, 1fr) 56px; gap: 6px 10px; }
  .an-grade .an-bullet { grid-column: 1 / -1; grid-row: 2; }
  .an-grade-st { grid-row: 3; }
}

/* ---------- 14. Admin ---------- */
.alert-warn { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning); }
.adm-card { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.adm-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.adm-head h1 { margin: 0; font-size: 28px; }
.adm-kpis, .adm-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.adm-kpis-left { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.adm-grid { align-items: start; }
.adm-table td { vertical-align: middle; }
.adm-table tr.is-off td { opacity: .6; }
.adm-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.adm-person { align-items: flex-start; }
.adm-person-main { min-width: 0; }
.adm-person-main .muted { overflow-wrap: anywhere; }
.adm-table td:nth-child(3) { min-width: 96px; max-width: 150px; }
.adm-acts { white-space: nowrap; }
.adm-person b { color: var(--text-heading); }
.adm-acts { margin-top: 2px; }
.adm-acts .btn-link { padding: 2px 0; }
.adm-person .avatar { width: 34px; height: 34px; font-size: 12px; flex: 0 0 auto; }
.adm-role { min-height: 38px; border-radius: 12px; border: 1px solid var(--input-border); background: var(--bg-card); font: inherit; font-size: 14px; padding: 4px 10px; color: var(--text-heading); }
.adm-wait { color: var(--warning); }
.adm-btns { text-align: right; }
.adm-btns > .btn { display: block; margin: 0 0 6px auto; white-space: nowrap; }
.adm-btns > .btn:last-child { margin-bottom: 0; }
.adm-name { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.adm-name.is-off { opacity: .55; }
.adm-name-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-name-btn { min-width: 0; text-align: left; background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-heading); cursor: pointer; overflow-wrap: anywhere; }
.adm-name-btn:hover { text-decoration: underline; }
.adm-del { color: var(--error); }
.adm-add { display: flex; gap: 8px; }
.adm-add input { flex: 1; min-width: 0; min-height: 40px; border-radius: 12px; border: 1px solid var(--input-border); padding: 6px 12px; font: inherit; }
.adm-activity { background: var(--bg-item); border: 1px solid var(--border); border-radius: 18px; padding: 12px 18px; font-size: 13px; color: var(--text-label); }
@media (max-width: 980px) {
  .adm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .adm-kpis { grid-template-columns: 1fr; gap: 8px; }
  .adm-kpis-left { gap: 8px; }
  .adm-table thead { display: none; }
  .adm-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
  .adm-table td { border: 0; padding: 0; }
  .adm-table td:nth-child(3) { grid-column: 1 / -1; padding-left: 44px; }
  .adm-table td.adm-btns { grid-column: 1 / -1; text-align: left; display: flex; flex-wrap: wrap; gap: 6px; }
  .adm-btns > .btn { margin: 0; }
}
a.btn, a.btn:hover { text-decoration: none; }

/* ---------- 15. Nút dạng link, ô tròn "Done" ---------- */
.btn-link { background: none; border: 0; padding: 6px 2px; font: inherit; font-weight: 600; color: var(--sage); text-decoration: underline; cursor: pointer; }
.task-check {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--check-border); background: var(--bg-card); color: #fff;
  font-size: 14px; cursor: pointer; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.task-check:hover { border-color: var(--sage); background: var(--success-bg); }
.task-check.is-done { background: var(--sage); border-color: var(--sage); }

/* ---------- 16. Trang mẫu Items (xoá khi không dùng) ---------- */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.item-row.is-done .item-main b { text-decoration: line-through; color: var(--text-muted); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.item-main b { color: var(--text-heading); overflow-wrap: anywhere; }
.item-main:hover b { text-decoration: underline; }
