:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #eff4ff;
  --danger: #c4320a;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --gray-soft: #f2f4f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --sidebar: #0f1b33;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

/* ---------- Đăng nhập ---------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 20%, #1e3a8a 0, #0f1b33 60%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 32px 28px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card h1 { font-size: 20px; }
.login-card p { margin: -8px 0 4px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 10px; background: #c8102e; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 22px; flex-shrink: 0;
}
.brand-mark.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }

/* ---------- Bố cục ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar); color: #c3cde0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; color: #fff; font-weight: 600; font-size: 15px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: #6e7d99; padding: 16px 10px 6px; font-weight: 600; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #c3cde0; padding: 8px 10px; border-radius: 7px; margin-bottom: 1px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.ni { width: 18px; text-align: center; opacity: .8; font-size: 13px; }
.nav-count { margin-left: auto; background: #f04438; color: #fff; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 7px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 16px; }
.me { display: flex; gap: 10px; align-items: center; }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; font-weight: 600; }
.me-name { color: #fff; font-weight: 600; }
.me-role { font-size: 12px; color: #8b97b0; }
.me-actions { display: flex; gap: 14px; margin-top: 10px; }
.sidebar .link { color: #9fb0cf; font-size: 13px; }
.sidebar .link:hover { color: #fff; }
.sidebar-overlay { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; min-height: 64px;
}
.title-wrap { flex: 1; min-width: 0; }
.crumb { font-size: 12.5px; color: var(--muted); }
.crumb a { color: var(--muted); }
.topbar h2 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { display: none; border: 0; background: none; font-size: 20px; cursor: pointer; padding: 2px 6px; }
.view { padding: 22px 28px 48px; max-width: 1480px; width: 100%; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar.open + .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .icon-btn { display: block; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .page-actions { width: 100%; }
  .page-actions:empty { display: none; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .result { margin-left: 0; }
}

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fecdca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .6; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.link.muted { color: var(--muted); }

/* ---------- Thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head .count { background: var(--gray-soft); color: var(--text-2); font-size: 12px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1150px) { .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Thống kê ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .sub { font-size: 12.5px; color: var(--muted); }
.stat.alert .value { color: var(--danger); }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }

/* ---------- Tab trạng thái (segmented) ---------- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.seg button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.seg button:hover { border-color: var(--border-strong); }
.seg button .c { background: var(--gray-soft); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg button.active .c { background: rgba(255,255,255,.22); color: #fff; }
.seg button.alert:not(.active) { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }
.seg button.alert:not(.active) .c { background: #fee4e2; color: var(--danger); }

/* ---------- Bộ lọc ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.filters input, .filters select { width: auto; min-width: 0; padding: 7px 10px; }
.filters .search { flex: 1 1 240px; max-width: 360px; position: relative; }
.filters .search input { width: 100%; padding-left: 32px; }
.filters .search::before { content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 16px; }
.filters .date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.filters .date-range input { width: 140px; }
.filters .result { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.filters .btn-clear { font-size: 13px; }

/* ---------- Ô nhập ---------- */
input, select, textarea {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: #fff; color: var(--text); box-shadow: var(--shadow);
}
input:focus, select:focus, textarea:focus { outline: 3px solid #d1e0ff; border-color: #84adff; }
textarea { resize: vertical; min-height: 64px; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; color: var(--text-2); }
.lbl { display: block; }
.req { color: var(--danger); }
input.sm, select.sm { padding: 5px 8px; font-size: 13px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid, .form-grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: 1 / -1; }
}
.form-section {
  grid-column: 1 / -1; font-weight: 600; font-size: 13px; color: var(--text); text-transform: uppercase; letter-spacing: .04em;
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-section:first-child { margin-top: 0; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; border: 1px solid #fecdca; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.check { flex-direction: row; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 500; }
.check input { width: auto; box-shadow: none; margin: 0; }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* Trường đối tác */
.checker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
tr.inactive td { opacity: .55; }
.match-group { border-top: 1px solid var(--border); }
.match-group:first-child { border-top: 0; }
.match-head { font-size: 13px; font-weight: 600; padding: 10px 0 4px; display: flex; gap: 8px; align-items: center; cursor: default; }
.match-group.ok .match-head { color: var(--ok); }
.match-group.unknown .match-head { color: var(--warn); }
.match-group.fail .match-head { color: var(--danger); cursor: pointer; list-style: none; }
.match-group.fail summary::-webkit-details-marker { display: none; }
.match-group.fail summary::after { content: "▸ xem lý do"; font-weight: 400; color: var(--muted); font-size: 12px; }
.match-group.fail[open] summary::after { content: "▾ ẩn"; }
.match-group .rows li { padding: 8px 0; }
.match-group .rows li:hover { background: none; }
.match-empty { padding: 2px 0 10px; }
.tab-pad .match-group .rows li, .tab-pad .match-head { padding-left: 0; padding-right: 0; }

/* Bảng nhập học lực */
.acad-input { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.acad-input th, .acad-input td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.acad-input tr:last-child td { border-bottom: 0; }
.acad-input th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.acad-input td:first-child, .acad-input th:first-child { text-align: left; font-weight: 500; color: var(--text-2); width: 26%; }
.acad-input input { max-width: 160px; text-align: center; padding: 6px 8px; }
.acad-input tr.total td { background: var(--primary-soft); font-weight: 700; color: var(--primary-dark); }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; letter-spacing: .02em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faff; }
tbody tr.clickable { cursor: pointer; }
.cell-main { font-weight: 600; color: var(--text); }
a.cell-main { color: var(--text); }
a.cell-main:hover { color: var(--primary); }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.cell-stack { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 28px; opacity: .5; margin-bottom: 6px; }

/* ---------- Nhãn ---------- */
.badge { text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--text-2); white-space: nowrap; line-height: 1.5; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.src { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.src::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--src, #98a2b3); }

/* ---------- Thanh tiến độ & biểu đồ ---------- */
.progress { height: 6px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; min-width: 70px; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.progress.lg { height: 8px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; gap: 8px; }
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 10px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-row .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Danh sách gọn ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { padding: 11px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; justify-content: space-between; align-items: center; }
.rows li:last-child { border-bottom: 0; }
.rows li:hover { background: #f8faff; }
.rows .grow { flex: 1; min-width: 0; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; padding: 0 12px; }
.tabs button { border: 0; background: none; padding: 12px 12px; cursor: pointer; font: inherit; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs .c { background: var(--gray-soft); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.tabs button.active .c { background: var(--primary-soft); }

/* ---------- Trang chi tiết ---------- */
.detail { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1050px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.profile-head { display: flex; gap: 14px; align-items: center; padding: 18px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 20px; flex-shrink: 0; }
.profile-head h3 { font-size: 18px; line-height: 1.25; }
.profile-head .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.panel-section { padding: 14px 18px; border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); word-break: break-word; min-width: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 24px; }
.kv-grid .k { font-size: 12.5px; color: var(--muted); }
.kv-grid .v { margin-top: 2px; word-break: break-word; }
.info-block + .info-block { margin-top: 20px; }
.note-box { background: var(--warn-soft); border: 1px solid #fedf89; border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 13.5px; }

/* Bảng học lực hiển thị */
.acad { width: 100%; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.acad th, .acad td { padding: 6px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.acad th { font-size: 11.5px; }
.acad td:first-child, .acad th:first-child { text-align: left; }
.acad tr:last-child td { border-bottom: 0; }
.acad td.total { font-weight: 700; background: var(--primary-soft); color: var(--primary-dark); }

/* Thanh tiến trình hồ sơ */
.stepper { display: flex; padding: 16px 18px 18px; overflow-x: auto; gap: 0; }
.step { flex: 1; min-width: 92px; position: relative; text-align: center; cursor: pointer; border: 0; background: none; font: inherit; padding: 0 4px; }
.step::before { content: ""; position: absolute; top: 13px; left: -50%; right: 50%; height: 2px; background: var(--border); }
.step:first-child::before { display: none; }
.step .dot { position: relative; z-index: 1; width: 28px; height: 28px; margin: 0 auto 6px; border-radius: 50%; border: 2px solid var(--border-strong); background: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.step .name { font-size: 12px; color: var(--muted); line-height: 1.3; }
.step.done::before, .step.current::before { background: var(--ok); }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.current .dot { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 0 0 4px #d1e0ff; }
.step.current .name { color: var(--primary); font-weight: 600; }
.step:hover .dot { border-color: var(--primary); }
.stepper.halted .step.current .dot { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 4px #fee4e2; }
.stepper.halted .step.current .name { color: var(--danger); }
.status-bar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }
.status-bar select { width: auto; }

/* Timeline tư vấn */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; }
.timeline li { position: relative; padding: 0 0 20px 26px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 19px; bottom: 2px; width: 2px; background: var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline .when strong { color: var(--text-2); }
.timeline .body { margin-top: 4px; white-space: pre-wrap; }
.timeline .extra { margin-top: 8px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; }

/* Checklist giấy tờ */
.doc-table td { padding: 8px 14px; }
.doc-table select { width: 200px; }
.doc-table .date-wrap { width: 150px; }

/* Ô ngày dd/mm/yyyy + nút lịch */
.date-wrap { position: relative; display: block; min-width: 0; }
.date-wrap .date-input { padding-right: 34px; }
.date-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; line-height: 1; }
.date-btn:hover { background: var(--gray-soft); }
.date-picker { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
.filters .date-wrap, .date-range .date-wrap { display: inline-block; width: 150px; }
.filters .date-range input { width: 100%; }
.doc-table select.st-done { background: var(--ok-soft); border-color: #abefc6; color: var(--ok); }
.doc-table select.st-doing { background: var(--warn-soft); border-color: #fedf89; color: var(--warn); }
.doc-table select.st-none { color: var(--muted); }

/* Lưu ý */
.note { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.note:last-child { border-bottom: 0; }
.note .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--border-strong); flex-shrink: 0; }
.note.p-khan .bar { background: var(--danger); }
.note.p-quan .bar { background: #f79009; }
.note.done { opacity: .55; }
.note .content { white-space: pre-wrap; }
.note .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); align-items: center; margin-top: 4px; }
.note .acts { display: flex; gap: 6px; flex-shrink: 0; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 24px 48px rgba(16,24,40,.25); display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); border-radius: 0 0 12px 12px; }
.close-x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.close-x:hover { color: var(--text); }

/* Chuông nhắc việc */
.bell-wrap { position: relative; }
.bell-btn { position: relative; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; width: 40px; height: 38px; cursor: pointer; font-size: 17px; box-shadow: var(--shadow); }
.bell-btn:hover { background: var(--surface-2); }
.bell-btn.ring { animation: ring 1s ease-in-out 2; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-6deg); } }
.bell-count { position: absolute; top: -6px; right: -6px; background: #f04438; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; border: 2px solid #fff; }
.reminder-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 400px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(16,24,40,.18); z-index: 40; }
.reminder-panel .rp-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.rp-group { padding: 10px 16px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rp-group.overdue { color: var(--danger); }
.rp-group.today { color: var(--warn); }
.rp-group.tomorrow, .rp-group.notes { color: var(--muted); }
.rp-list { margin: -18px -22px; }
.rp-list .rp-item:last-child { border-bottom: 0; }
.rp-item { display: flex; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); color: inherit; align-items: flex-start; }
.rp-item:hover { background: #f8faff; text-decoration: none; }
.rp-item .time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; color: var(--text-2); font-size: 13px; padding-top: 1px; }
.rp-foot { padding: 10px 16px; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Thông báo bật lên đúng giờ hẹn */
.alert-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 70; max-width: calc(100vw - 40px); width: 360px; }
.alert-card { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--warn); border-radius: 12px; box-shadow: 0 16px 40px rgba(16,24,40,.22); padding: 14px 16px; animation: slidein .25s ease-out; }
.alert-card.now { border-left-color: var(--danger); }
.alert-card .t { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.alert-card .acts { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.visa-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.quick-dates { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: -4px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #101828; color: #fff; padding: 11px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: calc(100vw - 44px); font-weight: 500; }
.toast.error { background: var(--danger); }

/* Truyền thông Facebook */
.progress.over > span { background: var(--danger); }
.cal-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; }
.cal-bar strong { min-width: 100px; text-align: center; }
.cal-legend { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.cal-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: -4px; }
.dot-info { background: #84adff; } .dot-ok { background: #47cd89; } .dot-gray { background: #d0d5dd; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.cal-dow { padding: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-align: center; border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 108px; padding: 4px 5px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell:nth-child(7n+14) { border-right: 0; }
.cal-cell:hover { background: #f8faff; }
.cal-cell.other { background: var(--surface-2); color: var(--muted); }
.cal-cell.today { background: var(--primary-soft); }
.cal-num { font-size: 12.5px; font-weight: 600; padding: 0 3px; }
.cal-cell.today .cal-num { color: var(--primary); }
.cal-chip { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid #d0d5dd; background: var(--gray-soft); border-radius: 4px; padding: 2px 5px;
  font: inherit; font-size: 12px; line-height: 1.35; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-2); }
.cal-chip.info { border-left-color: #2e90fa; background: var(--info-soft); }
.cal-chip.ok { border-left-color: #12b76a; background: var(--ok-soft); }
.cal-chip.due { border-left-color: var(--warn); background: var(--warn-soft); }
.cal-chip.cancel { text-decoration: line-through; opacity: .6; }
.cal-more { font-size: 11.5px; color: var(--muted); padding-left: 4px; }
.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.insights li { padding: 9px 12px 9px 14px; border-radius: 8px; border-left: 4px solid var(--border-strong); background: var(--surface-2); }
.insights li.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.insights li.warn { border-left-color: #f79009; background: var(--warn-soft); }
.insights li.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.insights li.info { border-left-color: var(--info); background: var(--info-soft); }
table.heat { text-align: center; font-size: 13px; }
table.heat th { font-size: 11.5px; padding: 8px 4px; }
table.heat td { padding: 6px 4px; border-radius: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
table.heat td:first-child { text-align: left; background: none; white-space: nowrap; padding-left: 8px; }
.heat-n { font-weight: 400; font-size: 11px; opacity: .85; }
.heat-empty { color: var(--border-strong); font-weight: 400 !important; }
.week-svg { width: 100%; height: auto; display: block; }
@media (max-width: 800px) { .cal-cell { min-height: 78px; } .cal-chip b { display: none; } }

/* Trợ lý nội dung AI */
.ai-banner { margin-bottom: 14px; border-left: 4px solid var(--border-strong); }
.ai-banner.warn { border-left-color: #f79009; background: var(--warn-soft); }
.ai-banner.info { border-left-color: var(--info); background: var(--info-soft); }
.ai-banner.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.ai-banner .card-body { padding: 11px 16px; }
.ai-banner code { background: rgba(16,24,40,.07); padding: 1px 6px; border-radius: 4px; }
.ai-loop { list-style: none; margin: 0 0 16px; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.ai-loop li { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; color: var(--text-2); }
.ai-loop li b { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; margin-right: 4px; }
.ai-loop li.back { background: none; border-style: dashed; color: var(--muted); }
.ai-headline { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.ai-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.ai-list.adj { list-style: none; padding: 0; gap: 8px; }
.ai-list.adj li { padding: 8px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 6px; }
.ai-plan { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.ai-plan .muted { display: inline-block; min-width: 118px; }
.ai-warn { margin-top: 12px; padding: 8px 12px; background: var(--warn-soft); border-radius: 8px; color: var(--warn); font-size: 13px; }
.ai-history { padding: 0 18px 14px; font-size: 13px; }
.ai-history summary { cursor: pointer; color: var(--muted); }
.ai-past { padding: 6px 0; border-bottom: 1px solid var(--border); }
.ai-draft { margin-bottom: 12px; }
.ai-why { background: var(--info-soft); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.ai-why .lbl { display: block; margin-bottom: 2px; }
