/* =====================================================================
   Growth Forecast — Design System
   Màu chủ đạo: Công ty = vàng hổ phách (giống header Sheets của anh),
                Áo lớp  = xanh ngọc (cyan).
   Mình = nét liền, Đối thủ = nét đứt / nhạt hơn.
   ===================================================================== */
:root {
  /* nền & bề mặt */
  --bg: #070b16;
  --bg-2: #0b1122;
  --surface: rgba(20, 28, 52, 0.62);
  --surface-2: rgba(28, 38, 68, 0.72);
  --surface-solid: #121a31;
  --border: rgba(148, 163, 214, 0.14);
  --border-strong: rgba(148, 163, 214, 0.28);

  /* chữ */
  --text: #e7ecf8;
  --text-2: #a9b3cf;
  --text-3: #6f7a99;

  /* màu thương hiệu */
  --brand: #8b7dff;
  --brand-2: #5b8cff;
  --ct: #fbbf24;          /* dòng Công ty */
  --ct-soft: rgba(251, 191, 36, 0.14);
  --al: #22d3ee;          /* dòng Áo lớp */
  --al-soft: rgba(34, 211, 238, 0.14);
  --up: #34d399;          /* tăng */
  --up-soft: rgba(52, 211, 153, 0.14);
  --down: #fb7185;        /* giảm */
  --down-soft: rgba(251, 113, 133, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --forecast: #fb923c;    /* số dự kiến (giống ô cam trong Sheets) */
  --forecast-soft: rgba(251, 146, 60, 0.16);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 0 1px rgba(139, 125, 255, 0.25), 0 12px 40px -10px rgba(139, 125, 255, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(91, 140, 255, 0.16), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(139, 125, 255, 0.14), transparent 60%),
    radial-gradient(700px 400px at 50% 50%, rgba(34, 211, 238, 0.04), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* icon mặc định: luôn nhỏ gọn, không bị kéo giãn */
svg.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(139, 125, 255, 0.4); }

/* thanh cuộn */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 214, 0.22); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 214, 0.38); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   Bố cục
   ===================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(14, 20, 40, 0.92), rgba(9, 13, 27, 0.92));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 14px; border-bottom: 1px solid var(--border); }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 55%, var(--al));
  box-shadow: 0 8px 24px -6px rgba(139, 125, 255, 0.6);
}
.brand-logo svg { width: 24px; height: 24px; color: #fff; }
.brand-title { font-weight: 800; font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); padding: 10px 12px 4px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}
.nav a svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav a:hover { background: rgba(148, 163, 214, 0.08); color: var(--text); transform: translateX(2px); }
.nav a.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(139, 125, 255, 0.26), rgba(91, 140, 255, 0.08));
  box-shadow: inset 0 0 0 1px rgba(139, 125, 255, 0.3);
}
.nav a.active::before {
  content: ''; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand), var(--al));
}
.nav .step { margin-left: auto; font-size: 10px; padding: 2px 7px; border-radius: 20px; background: rgba(148, 163, 214, 0.1); color: var(--text-3); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.save-status { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); padding: 8px 10px; border-radius: var(--radius-xs); background: rgba(148, 163, 214, 0.06); }
.save-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.save-status[data-state='saved'] .dot { background: var(--up); box-shadow: 0 0 10px var(--up); }
.save-status[data-state='pending'] .dot,
.save-status[data-state='saving'] .dot,
.save-status[data-state='loading'] .dot { background: var(--warn); animation: pulse 1s infinite; }
.save-status[data-state='error'] { color: var(--down); background: var(--down-soft); }
.save-status[data-state='error'] .dot { background: var(--down); }
.foot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.main { min-width: 0; padding: 26px 32px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.crumb { font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
.topbar h1 {
  margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.4px;
  background: linear-gradient(90deg, #fff, #c9d3f5 60%, #9fb1ea);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar p { margin: 6px 0 0; color: var(--text-2); max-width: 760px; }
.topbar-right { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.view { animation: viewIn 0.45s var(--ease); }

/* =====================================================================
   Thành phần
   ===================================================================== */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-sub { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* thẻ chỉ số */
.stat {
  position: relative; overflow: hidden;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.stat:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent, var(--brand)) 0%, transparent 70%); opacity: 0.18;
}
.stat.ct { --accent: var(--ct); }
.stat.al { --accent: var(--al); }
.stat-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.stat-label svg.ic { width: 18px; height: 18px; color: var(--accent, var(--brand)); }
.card-title svg.ic { width: 20px; height: 20px; color: var(--brand); }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }
.stat-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-3); }

/* nhãn nhỏ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: rgba(148, 163, 214, 0.1); color: var(--text-2); white-space: nowrap; }
.badge.ct { background: var(--ct-soft); color: var(--ct); }
.badge.al { background: var(--al-soft); color: var(--al); }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.forecast { background: var(--forecast-soft); color: var(--forecast); }
.dot-ct, .dot-al, .dot-tot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.dot-ct { background: var(--ct); } .dot-al { background: var(--al); } .dot-tot { background: #a78bfa; }

/* nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: rgba(148, 163, 214, 0.06);
  color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: rgba(148, 163, 214, 0.14); border-color: rgba(148, 163, 214, 0.42); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { border-color: transparent; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 22px -8px rgba(139, 125, 255, 0.7); }
.btn-primary:hover { background: linear-gradient(135deg, #9a8eff, #6d99ff); box-shadow: 0 10px 28px -8px rgba(139, 125, 255, 0.85); }
.btn-danger { color: var(--down); border-color: rgba(251, 113, 133, 0.35); background: var(--down-soft); }
.btn-danger:hover { background: rgba(251, 113, 133, 0.24); border-color: rgba(251, 113, 133, 0.55); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ô nhập */
.input, .select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: rgba(7, 11, 22, 0.55);
  outline: none; transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139, 125, 255, 0.22); background: rgba(7, 11, 22, 0.8); }
.input.invalid { border-color: var(--down); box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.2); }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a9b3cf' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.select option { background: var(--surface-solid); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

/* ô tích */
.check { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--border-strong); background: rgba(7, 11, 22, 0.5);
  display: grid; place-items: center; transition: all 0.2s var(--ease);
}
.check .box::after { content: ''; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform 0.18s var(--ease); }
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(139, 125, 255, 0.35); }
.check.off input:checked + .box { background: var(--down); border-color: var(--down); }
.check.ct input:checked + .box { background: var(--ct); border-color: var(--ct); }
.check.al input:checked + .box { background: var(--al); border-color: var(--al); }
.check.ct .box::after, .check.al .box::after { border-color: #0b1122; }

/* nút chuyển dạng phân đoạn */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: rgba(7, 11, 22, 0.55); border: 1px solid var(--border); }
.seg button { padding: 7px 14px; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; transition: all 0.25s var(--ease); }
.seg button:hover { color: var(--text); }
.seg button.active { background: linear-gradient(135deg, rgba(139, 125, 255, 0.9), rgba(91, 140, 255, 0.9)); color: #fff; box-shadow: 0 6px 16px -6px rgba(139, 125, 255, 0.7); }

/* bảng */
.table-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); max-height: 70vh; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: #141c36; color: var(--text-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; text-align: left;
}
.tbl tbody tr { transition: background 0.15s; }
.tbl tbody tr:hover { background: rgba(148, 163, 214, 0.05); }
.tbl .num { text-align: right; }
.tbl .center { text-align: center; }
.tbl th.ct { color: var(--ct); } .tbl th.al { color: var(--al); }

/* trạng thái trống */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 46px 20px; color: var(--text-2);
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(139, 125, 255, 0.22), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(139, 125, 255, 0.3);
  animation: float 4s ease-in-out infinite;
}
.empty-icon svg { width: 30px; height: 30px; color: var(--brand); }
.empty h3 { margin: 4px 0 0; color: var(--text); font-size: 17px; }
.empty p { margin: 0; max-width: 520px; }

/* danh sách bước */
.roadmap { display: grid; gap: 10px; margin-top: 6px; }
.roadmap-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(148, 163, 214, 0.05); border: 1px solid var(--border); }
.roadmap-item .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: rgba(148, 163, 214, 0.12); color: var(--text-2); flex: none; }
.roadmap-item.done .n { background: var(--up-soft); color: var(--up); }
.roadmap-item.now { border-color: rgba(139, 125, 255, 0.45); box-shadow: var(--shadow-glow); }
.roadmap-item.now .n { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.roadmap-item .t { font-weight: 600; }
.roadmap-item .d { color: var(--text-3); font-size: 12.5px; }
.roadmap-item .badge { margin-left: auto; }

/* thông báo nổi */
#toast-host { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 12px;
  background: rgba(20, 28, 52, 0.95); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); animation: toastIn 0.35s var(--ease);
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.err { border-color: rgba(251, 113, 133, 0.5); }
.toast.leaving { animation: toastOut 0.3s var(--ease) forwards; }

/* hộp thoại */
.modal-back { position: fixed; inset: 0; background: rgba(3, 6, 14, 0.6); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 90; animation: fadeIn 0.2s; }
.modal { width: min(520px, calc(100vw - 32px)); background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 22px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8); animation: modalIn 0.3s var(--ease); }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.muted { color: var(--text-3); }
.up { color: var(--up); } .down { color: var(--down); }
.hide { display: none !important; }
.test-link { display: block; margin-top: 10px; font-size: 12px; color: var(--text-3); text-decoration: none; text-align: center; transition: color 0.2s; }
.test-link:hover { color: var(--up); }

/* =====================================================================
   Nhập liệu
   ===================================================================== */
.entry-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.toolbar-right { gap: 10px; }
.name-field { min-width: 240px; }
.year-tabs { flex-wrap: wrap; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }

.entry-wrap { max-height: none; }
.entry-table td { padding: 5px 8px; vertical-align: middle; }
.entry-table thead th { padding: 11px 8px; }
.entry-table th.center, .entry-table td.center { text-align: center; }
.month-cell { min-width: 150px; }
.month-name { font-weight: 700; }
.month-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.month-flags:empty { display: none; }
.month-flags .badge { font-size: 10.5px; padding: 1px 7px; }
.badge.hint svg.ic { width: 12px; height: 12px; }

.cell-input {
  width: 100%; min-width: 70px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid transparent; background: rgba(148, 163, 214, 0.05);
  outline: none; font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cell-input:hover { border-color: var(--border-strong); }
.cell-input:focus { border-color: var(--brand); background: rgba(7, 11, 22, 0.85); box-shadow: 0 0 0 3px rgba(139, 125, 255, 0.2); }
.cell-input.num { text-align: right; }
.cell-input.money { min-width: 150px; font-weight: 600; }
.cell-input.day { min-width: 80px; width: 90px; }
.cell-input.note { min-width: 180px; }
.cell-input[data-col="sale"] { width: 80px; }
.cell-input::placeholder { color: var(--text-3); font-weight: 400; }
.cell-input.invalid { border-color: var(--down); box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.2); background: var(--down-soft); }
.ct-cell .cell-input.money { color: #fde68a; }
.al-cell .cell-input.money { color: #a5f3fc; }
.is-off .cell-input { text-decoration: line-through; opacity: 0.45; }

.entry-table tbody tr.is-forecast td { background: var(--forecast-soft); }
.entry-table tbody tr.is-forecast td:first-child { box-shadow: inset 3px 0 0 var(--forecast); }
.total-cell { min-width: 140px; }
.total-cell .sub, .sub { font-size: 11px; color: var(--text-3); font-weight: 400; }
.entry-table tfoot td { background: #141c36; padding: 10px 8px; border-top: 1px solid var(--border-strong); font-size: 13px; }
.entry-table tfoot tr.strong td { color: #fff; }
.entry-table tfoot td:first-child { font-weight: 700; }

.check.fc input:checked + .box { background: var(--forecast); border-color: var(--forecast); }
.check.tet input:checked + .box { background: var(--warn); border-color: var(--warn); }

/* hộp thoại rộng + dán dữ liệu */
.modal-wide { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.modal-head h3 { margin: 0; }
.field-error { color: var(--down); font-size: 12.5px; min-height: 18px; margin-top: 6px; }
.paste-help { font-size: 13px; color: var(--text-2); background: rgba(139, 125, 255, 0.07); border: 1px solid rgba(139, 125, 255, 0.2); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; }
.paste-help ul { margin: 6px 0 0; padding-left: 18px; }
.paste-help li { margin: 3px 0; }
kbd { font-family: inherit; font-size: 11.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: rgba(148, 163, 214, 0.1); }
.paste-area { resize: vertical; font-family: Consolas, 'Cascadia Mono', monospace; font-size: 12.5px; white-space: pre; }
.paste-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.paste-opts .dim { opacity: 0.4; }
.paste-preview { margin-top: 14px; }
.preview-head { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.warn-list { list-style: none; margin: 0 0 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: #fcd34d; font-size: 12.5px; }
.warn-list li { display: flex; gap: 6px; align-items: flex-start; margin: 2px 0; }
.warn-list svg.ic { margin-top: 2px; }
td.overwrite { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.paste-guard { display: grid; gap: 6px; margin-bottom: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid rgba(251, 113, 133, 0.45); background: var(--down-soft); color: #fecdd3; font-size: 12.5px; }
.paste-guard div { display: flex; gap: 8px; align-items: flex-start; }
.paste-guard svg.ic { color: var(--down); margin-top: 2px; }
.paste-guard b { color: #fff; }
@media (max-width: 760px) { .paste-opts { grid-template-columns: 1fr; } }

/* =====================================================================
   Phân tích & Tổng quan
   ===================================================================== */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.analysis-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.seg button .dot-ct, .seg button .dot-al, .seg button .dot-tot { margin-right: 4px; }

.notice-card { margin-bottom: 18px; border-color: rgba(245, 158, 11, 0.35); background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), var(--surface)); }
.notice-card .card-title svg.ic { color: var(--warn); }
.notice-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.notice-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(7, 11, 22, 0.35); font-size: 13px; color: var(--text-2); }
.notice-list li svg.ic { margin-top: 2px; width: 16px; height: 16px; }
.notice-list li.warn svg.ic { color: var(--warn); }
.notice-list li.info svg.ic { color: var(--brand); }
.notice-list li b { color: var(--text); }

.metrics-table td { vertical-align: top; white-space: normal; }
.metrics-table td:first-child { min-width: 260px; }
.metrics-table td.num { white-space: nowrap; }
.metric-name { font-weight: 600; }
.empty.small { padding: 30px 16px; height: 100%; justify-content: center; }

.overview-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.mix { margin-bottom: 16px; }
.mix-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 7px; }
.mix-bar { display: flex; height: 12px; border-radius: 8px; overflow: hidden; background: rgba(148, 163, 214, 0.1); }
.mix-bar span { display: block; height: 100%; transition: width 0.8s var(--ease); }
.mix-bar .ct { background: linear-gradient(90deg, #f59e0b, var(--ct)); }
.mix-bar .al { background: linear-gradient(90deg, #06b6d4, var(--al)); }
.mix-legend { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.mini-title { font-size: 13px; color: var(--text-2); margin: 18px 0 8px; font-weight: 600; }
.mini-table td, .mini-table th { padding: 7px 8px; }
.insight-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-2); }
.insight-list b { color: var(--text); }
@media (max-width: 1100px) { .overview-main { grid-template-columns: 1fr; } }

/* =====================================================================
   Kế hoạch năm
   ===================================================================== */
.plan-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.scen-seg button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 16px; line-height: 1.2; }
.scen-seg button small { font-size: 11px; font-weight: 500; opacity: 0.75; }
.plan-top { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.plan-bottom { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }

.target-card { background: linear-gradient(140deg, rgba(139, 125, 255, 0.16), rgba(34, 211, 238, 0.06) 60%, var(--surface)); border-color: rgba(139, 125, 255, 0.35); }
.target-input-wrap { position: relative; margin-top: 10px; }
.target-input { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; padding: 14px 44px 14px 16px; text-align: right; font-variant-numeric: tabular-nums; }
.target-unit { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 700; font-size: 18px; }
.target-meta { margin-top: 12px; display: grid; gap: 8px; font-size: 13px; }
.target-growth { font-size: 14px; color: var(--text-2); }
.target-growth > span:first-child { font-size: 22px; font-weight: 800; margin-right: 6px; }
.target-rating { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.target-rating .muted { flex: 1; min-width: 200px; }

.split-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.split-line { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; }
.split-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.split-line.ct .split-name { color: var(--ct); } .split-line.al .split-name { color: var(--al); }
.split-pct { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.split-pct b { font-size: 16px; color: var(--text); min-width: 70px; text-align: right; display: inline-block; }
.pct-input { width: 90px; text-align: right; font-weight: 700; padding: 7px 10px; }
.split-money { font-variant-numeric: tabular-nums; font-size: 15px; }
.split-refs { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: 12.5px; }
.ref-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 4px 0; color: var(--text-2); }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--ct), var(--al)); margin: 8px 0; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); transition: transform 0.15s; }
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); }
.range:disabled { opacity: 0.4; cursor: not-allowed; }

.line-card.ct { border-top: 3px solid var(--ct); }
.line-card.al { border-top: 3px solid var(--al); }
.line-card .card-head { margin-bottom: 10px; }
.blend { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; font-size: 12.5px; color: var(--text-2); }
.blend .range { background: linear-gradient(90deg, var(--brand), #cbd5e1); }
.blend.dim { opacity: 0.6; }
.line-notes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.line-notes li { display: flex; gap: 8px; align-items: flex-start; }
.line-notes svg.ic { flex: none; margin-top: 2px; color: var(--brand); }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.line-actions:empty { display: none; }

.plan-wrap { max-height: none; }
.plan-table th, .plan-table td { padding: 7px 8px; }
.plan-table thead th { text-align: right; }
.plan-table .sticky-col { position: sticky; left: 0; z-index: 1; background: #10172d; text-align: left; min-width: 230px; box-shadow: 1px 0 0 var(--border); }
.plan-table thead .sticky-col { z-index: 3; background: #1d4ed8; color: #fff; }
.plan-table .row-name { font-weight: 700; font-size: 12.5px; text-align: right; }
.plan-table .year-col { background: rgba(7, 11, 22, 0.5); font-weight: 700; min-width: 140px; }
.plan-table thead .year-col { background: #1b2647; }
.plan-table tbody tr.row-total td { background: rgba(139, 125, 255, 0.1); font-weight: 800; color: #fff; border-bottom: 1px solid var(--border-strong); }
.plan-table tbody tr.row-total td.sticky-col { background: #1c2244; }
.plan-table tr.row-pct.ct .row-name, .plan-table tr.row-money.ct .row-name { color: var(--ct); }
.plan-table tr.row-pct.al .row-name, .plan-table tr.row-money.al .row-name { color: var(--al); }
.plan-table tr.row-money td.money-cell { font-weight: 600; min-width: 120px; }
.plan-table tr.row-money.ct td.money-cell { color: #fde68a; }
.plan-table tr.row-money.al td.money-cell { color: #a5f3fc; }
.plan-table tr.row-money.al td, .plan-table tr.row-money.ct td { border-bottom-color: var(--border-strong); }
.plan-table td.over { background: var(--down-soft); box-shadow: inset 0 0 0 1px rgba(251, 113, 133, 0.6); color: #fecdd3 !important; }
.plan-table tr.row-ref td { color: var(--text-2); font-size: 12.5px; }
.plan-table tr.row-ref .row-name { color: var(--text-3); font-weight: 600; }
.plan-table td.is-fc { color: var(--forecast); }
.pct-cell { min-width: 112px; }
.pct-wrap { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.cell-input.pct { min-width: 0; width: 66px; padding: 5px 7px; font-weight: 700; }
.pct-cell.is-off .cell-input.pct { opacity: 0.35; text-decoration: line-through; }
.pct-cell.is-off { background: rgba(7, 11, 22, 0.45); }
.pct-cell.is-manual .cell-input.pct { color: #c4b5fd; border-color: rgba(139, 125, 255, 0.55); background: rgba(139, 125, 255, 0.12); }
.badge.manual-badge { background: rgba(139, 125, 255, 0.16); color: #c4b5fd; }
.plan-alert { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--down-soft); border: 1px solid rgba(251, 113, 133, 0.45); font-size: 13px; color: #fecdd3; }
.plan-alert svg.ic { color: var(--down); width: 18px; height: 18px; flex: none; }
.plan-alert span { flex: 1; min-width: 240px; }

.advice-list { display: grid; gap: 10px; }
.advice-item { padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(7, 11, 22, 0.35); border-left: 3px solid var(--brand); font-size: 13px; color: var(--text-2); }
.advice-item.ok { border-left-color: var(--up); }
.advice-item.warn { border-left-color: var(--warn); background: rgba(245, 158, 11, 0.07); }
.advice-item.bad { border-left-color: var(--down); background: rgba(251, 113, 133, 0.07); }
.advice-title { font-weight: 700; color: var(--text); margin-bottom: 6px; }
.advice-body b { color: var(--text); }
.advice-body b.up { color: var(--up); }
.advice-ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.advice-warn { margin-top: 8px; color: #fcd34d; font-size: 12.5px; }
@media (max-width: 1100px) { .plan-top, .plan-bottom { grid-template-columns: 1fr; } }

/* =====================================================================
   Kế hoạch tuyển dụng › Sale
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.recruit-tabs { padding: 8px; }
.rtabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); width: 100%; border: 0; background: transparent; padding: 0; gap: 4px; }
.rtabs button { display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-align: left; }
.rtabs button svg.ic { width: 20px; height: 20px; flex: none; }
.rtabs button b { display: block; font-size: 13.5px; }
.rtabs button small { display: block; font-size: 11px; font-weight: 500; opacity: 0.75; margin-top: 1px; }
.rtabs button:not(.active):hover { background: rgba(148, 163, 214, 0.08); }

.sales-wrap { max-height: 72vh; }
.sales-table td { padding: 4px 6px; vertical-align: middle; }
.sales-table thead th { padding: 10px 6px; }
.sales-table .sticky-col { position: sticky; left: 0; z-index: 1; background: #10172d; min-width: 220px; box-shadow: 1px 0 0 var(--border); }
.sales-table thead .sticky-col { z-index: 3; background: #141c36; }
.sales-table tfoot .sticky-col { z-index: 2; }
.sales-table .name-cell .month-flags .badge { font-size: 10.5px; padding: 1px 7px; }
.cell-input.name { min-width: 190px; font-weight: 600; }
.cell-input.ym { width: 96px; min-width: 0; text-align: center; }
.sales-table .status-cell { text-align: center; min-width: 105px; }
.sales-table .btn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.sales-table .btn-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.sales-table .btn-status.active {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.28);
}
.sales-table .btn-status.active .dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
.sales-table .btn-status.active:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(16, 185, 129, 0.45);
}
.sales-table .btn-status.resigned {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.28);
}
.sales-table .btn-status.resigned .dot {
  background: #ef4444;
}
.sales-table .btn-status.resigned:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.45);
}
.sales-table tr.row-resigned td {
  opacity: 0.62;
}
.sales-table tr.row-resigned:hover td {
  opacity: 1;
}
.m-cell-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.sales-table .m-cell-box .cell-input.money {
  min-width: 0;
  width: 122px;
  color: #ddd6fe;
  padding-right: 22px;
}
.btn-cell-calc {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(139, 125, 255, 0.16);
  border: 1px solid rgba(139, 125, 255, 0.32);
  border-radius: 5px;
  font-size: 11px;
  padding: 2px 3px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s ease;
  color: #e0e7ff;
  line-height: 1;
  z-index: 2;
}
.m-cell-box:hover .btn-cell-calc,
.m-cell-box:focus-within .btn-cell-calc {
  opacity: 0.8;
  pointer-events: auto;
}
.btn-cell-calc:hover {
  opacity: 1;
  background: rgba(139, 125, 255, 0.35);
  border-color: rgba(139, 125, 255, 0.6);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 0 8px rgba(139, 125, 255, 0.4);
}

/* Floating Inline Hint */
.cell-inline-hint {
  position: fixed;
  z-index: 99;
  background: #151b33;
  border: 1px solid rgba(139, 125, 255, 0.4);
  border-radius: 10px;
  padding: 6px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), 0 0 15px rgba(139, 125, 255, 0.15);
  font-size: 12.5px;
  color: #f1f5f9;
  animation: fadeIn 0.15s ease;
  backdrop-filter: blur(10px);
}
.cell-inline-hint.hide {
  display: none !important;
}
.cell-inline-hint .hint-title {
  color: #94a3b8;
  font-size: 12px;
}
.cell-inline-hint .btn-hint-zero {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.35));
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cell-inline-hint .btn-hint-zero:hover {
  background: rgba(16, 185, 129, 0.45);
  border-color: #34d399;
  transform: scale(1.03);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}
.cell-inline-hint .btn-hint-calc {
  background: rgba(139, 125, 255, 0.18);
  border: 1px solid rgba(139, 125, 255, 0.35);
  color: #c7d2fe;
  border-radius: 6px;
  padding: 4px 9px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cell-inline-hint .btn-hint-calc:hover {
  background: rgba(139, 125, 255, 0.32);
  border-color: rgba(139, 125, 255, 0.6);
  color: #fff;
}

/* Modal Cộng dồn doanh số thông minh */
.sc-modal-box {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.sc-target-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(139, 125, 255, 0.12);
  border: 1px solid rgba(139, 125, 255, 0.28);
  color: #e0e7ff;
  font-size: 13.5px;
  font-weight: 600;
}
.sc-target-badge .sc-target-dot {
  color: rgba(148, 163, 214, 0.4);
}
.sc-target-badge .sc-target-period {
  color: #38bdf8;
}
.sc-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sc-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.sc-input-label {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.4;
}
.btn-xs {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: 4px;
}
.sc-textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  padding: 10px 12px;
  background: rgba(7, 11, 22, 0.7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: #fff;
  resize: vertical;
  min-height: 110px;
}
.sc-textarea:focus {
  border-color: var(--brand);
  background: rgba(7, 11, 22, 0.9);
  box-shadow: 0 0 0 3px rgba(139, 125, 255, 0.25);
}
.sc-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sc-toggle-label {
  display: block;
  cursor: pointer;
  user-select: none;
}
.sc-toggle-label input[type="checkbox"] {
  display: none;
}
.sc-toggle-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  background: rgba(148, 163, 214, 0.06);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.sc-toggle-custom:hover {
  background: rgba(148, 163, 214, 0.1);
  border-color: var(--border-strong);
}
.sc-toggle-label input:checked + .sc-toggle-custom {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.22);
}
.sc-badge-zeros {
  font-weight: 800;
  font-size: 13.5px;
  color: #94a3b8;
  background: rgba(148, 163, 214, 0.12);
  padding: 4px 9px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
.sc-toggle-label input:checked + .sc-toggle-custom .sc-badge-zeros {
  color: #10b981;
  background: rgba(16, 185, 129, 0.25);
}
.sc-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sc-toggle-text b {
  font-size: 13px;
  color: var(--text);
}
.sc-toggle-text small {
  font-size: 11.5px;
  color: var(--text-3);
}
.sc-toggle-label input:checked + .sc-toggle-custom .sc-toggle-text b {
  color: #6ee7b7;
}

.sc-preview-wrap {
  background: rgba(7, 11, 22, 0.55);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
}
.sc-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 214, 0.1);
}
.sc-count-badge {
  background: rgba(139, 125, 255, 0.18);
  color: #c7d2fe;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
}
.sc-items-scroll {
  max-height: 135px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 8px 0;
  padding-right: 4px;
}
.sc-empty {
  padding: 14px 6px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  font-style: italic;
}
.sc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  font-variant-numeric: tabular-nums;
}
.sc-idx {
  color: var(--text-3);
  font-size: 11px;
  min-width: 22px;
}
.sc-raw {
  color: var(--text-2);
  flex: 1;
  font-family: monospace;
}
.sc-arrow {
  color: rgba(148, 163, 214, 0.4);
  font-size: 11px;
}
.sc-val {
  color: #c7d2fe;
  font-weight: 600;
}
.sc-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  margin-top: 6px;
}
.sc-total-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sc-total-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-3);
}
.sc-total-words {
  font-size: 12px;
  color: #94a3b8;
}
.sc-total-number {
  font-size: 21px;
  font-weight: 800;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.sales-table td.is-out { background: rgba(7, 11, 22, 0.5); }
.sales-table td.is-out .cell-input { opacity: 0.5; }
.badge.out-badge { background: rgba(7, 11, 22, 0.6); border: 1px dashed var(--border-strong); }
.sales-table tfoot td { background: #141c36; padding: 8px 6px; border-top: 1px solid var(--border); font-size: 12.5px; }
.sales-table tfoot tr:first-child td { border-top: 1px solid var(--border-strong); }
.sales-table tfoot td:first-child { font-weight: 700; text-align: right; }
.sales-table tfoot tr.strong td { color: #fff; font-weight: 700; }
.sales-table tfoot tr.ref td { color: var(--text-2); }
.sales-table td.diff-warn { color: #fcd34d; background: rgba(245, 158, 11, 0.16); }
.sales-table td.diff-ok { color: var(--up); }
.sales-table tr.sales-empty td { text-align: center; padding: 34px 16px; color: var(--text-3); white-space: normal; }
.sale-del { color: var(--text-3); padding: 6px; }
.sale-del:hover { color: var(--down); background: var(--down-soft); }
.sale-alert { margin-bottom: 12px; }
.btn[hidden] { display: none; }

/* ---- Tab Sale mới ---- */
.ramp-wrap, .idx-wrap, .preview-wrap { max-height: none; }
.ramp-table th, .ramp-table td, .idx-table th, .idx-table td, .preview-table th, .preview-table td { padding: 7px 8px; }
.ramp-table .sticky-col, .idx-table .sticky-col, .preview-table .sticky-col { position: sticky; left: 0; z-index: 1; background: #10172d; text-align: left; box-shadow: 1px 0 0 var(--border); }
.ramp-table thead .sticky-col, .idx-table thead .sticky-col, .preview-table thead .sticky-col { z-index: 3; background: #141c36; }
.ramp-table .sticky-col { min-width: 170px; }
.ramp-table td { padding: 6px 4px; }
.ramp-table .row-name { font-weight: 700; font-size: 12.5px; white-space: normal; }
.ramp-table .cell-input.money { min-width: 108px; width: 100%; padding: 6px 6px; font-size: 12.5px; color: #ddd6fe; }
.ramp-input-row td { background: rgba(139, 125, 255, 0.06); }
.ramp-used-row td { border-top: 1px solid var(--border-strong); }
.ramp-guess { color: var(--warn); font-style: italic; }
.ramp-hint { white-space: normal; font-size: 12.5px; }

.season-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mix-ctl { padding: 12px 14px 10px; border-radius: var(--radius-sm); background: rgba(7, 11, 22, 0.35); border: 1px solid var(--border); border-top: 3px solid var(--c, var(--brand)); transition: border-color 0.2s, opacity 0.2s; }
.mix-ctl:hover { border-color: var(--border-strong); border-top-color: var(--c, var(--brand)); }
.mix-ctl.dim { opacity: 0.6; }
.mix-ctl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.mix-ctl-head small { color: var(--text-3); font-size: 11.5px; }
.mix-ctl .range { background: linear-gradient(90deg, rgba(148, 163, 214, 0.18), var(--c, var(--brand))); }
.mix-ctl .range::-webkit-slider-thumb { border-color: var(--c, var(--brand)); }
.mix-ctl .range::-moz-range-thumb { border-color: var(--c, var(--brand)); }
.mix-ctl-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.mix-ctl-foot .val { font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

.idx-table .sticky-col { min-width: 300px; white-space: normal; }
.idx-table td.idx { font-variant-numeric: tabular-nums; min-width: 58px; transition: background 0.25s; }
.src-name { display: flex; align-items: center; gap: 7px; }
.src-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.idx-table tr.is-missing td, .idx-table tr.is-unused td { opacity: 0.55; }
.idx-table tr.mix-row td { border-top: 1px solid var(--border-strong); color: var(--text-2); }
.idx-table tr.applied-row td { font-size: 13.5px; color: #fde68a; border-top: 1px solid rgba(251, 191, 36, 0.4); }
.idx-table tr.applied-row td.sticky-col { background: #1f1d2a; color: var(--text); }
.season-chart { height: 280px; margin-top: 14px; }

.preview-table .sticky-col { min-width: 195px; }
.preview-table td.pv { min-width: 74px; font-variant-numeric: tabular-nums; transition: background 0.25s; }
.preview-table td.pv .sub { font-size: 10px; }
.preview-table tr.is-best td.sticky-col { box-shadow: inset 3px 0 0 var(--up), 1px 0 0 var(--border); }
.preview-table tr.is-worst td.sticky-col { box-shadow: inset 3px 0 0 var(--down), 1px 0 0 var(--border); }
.preview-table td.total-cell { background: rgba(139, 125, 255, 0.08); color: #fff; }
@media (max-width: 1200px) { .season-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* ---- Tab Kế hoạch tuyển dụng (Bước C) ---- */
.rec-plan-table { position: relative; border-collapse: separate; border-spacing: 0; }
.rec-plan-table th.sticky-col,
.rec-plan-table td.sticky-col {
  position: sticky !important;
  left: 0 !important;
  min-width: 270px;
  max-width: 320px;
  text-align: left !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.55), 1px 0 0 var(--border) !important;
  white-space: nowrap;
}
.rec-plan-table thead th.sticky-col {
  z-index: 10 !important;
  background: #1d4ed8 !important;
  color: #fff !important;
  font-weight: 800;
}
.rec-plan-table tbody td.sticky-col {
  z-index: 5 !important;
  background: #10172d !important;
}
.rec-plan-table tr.row-target td.sticky-col { background: #1d172b !important; }
.rec-plan-table tr.row-hires td.sticky-col { background: #181938 !important; }
.rec-plan-table tr.row-rec-total td.sticky-col { background: #1e1e4a !important; color: #fff !important; font-weight: 800 !important; }
.rec-plan-table tr.row-kpi-floor td.sticky-col { background: #102428 !important; }
.rec-plan-table tr.row-sales-total td.sticky-col { background: #141e3a !important; }
.rec-plan-table tr.row-headcount td.sticky-col { background: #0e2238 !important; }
.rec-plan-table tr.row-payroll td.sticky-col { background: #1c1a3b !important; }
.rec-plan-table tr.row-replace td.sticky-col { background: #241c20 !important; }

.rec-plan-table .cell-input.hire-inp { width: 56px; text-align: right; padding: 4px 6px; font-size: 13px; font-weight: 700; color: #fff; background: rgba(139, 125, 255, 0.12); border-color: rgba(139, 125, 255, 0.35); }
.rec-plan-table .cell-input.hire-inp:focus { background: rgba(139, 125, 255, 0.25); border-color: var(--brand); }
.rec-plan-table td.is-manual .hire-inp { border-color: #fbbf24; background: rgba(251, 191, 36, 0.15); color: #fde68a; }

.rec-plan-table tr.row-hires td { background: rgba(139, 125, 255, 0.06); }
.rec-plan-table tr.row-target td { background: rgba(251, 113, 133, 0.05); font-weight: 600; }
.rec-plan-table tr.row-rec-total td { background: rgba(139, 125, 255, 0.12); font-weight: 700; font-size: 13.5px; color: #fff; border-top: 1px solid var(--border-strong); }
.rec-plan-table tr.row-kpi-floor td { background: rgba(52, 211, 153, 0.05); color: #6ee7b7; font-size: 12.5px; }
.rec-plan-table td.diff-pos { color: var(--up); font-weight: 700; }
.rec-plan-table td.diff-neg { color: var(--down); background: rgba(251, 113, 133, 0.15); font-weight: 700; }
.rec-plan-table td.kpi-ratio-cell { color: #fde68a; font-weight: 600; font-size: 12px; }
.rec-plan-table tr.row-sales-total td { background: rgba(139, 125, 255, 0.08); }
.rec-plan-table tr.row-headcount td { background: rgba(56, 189, 248, 0.05); color: #bae6fd; font-size: 12.5px; }
.rec-plan-table tr.row-payroll td { background: rgba(167, 139, 250, 0.08); color: #ddd6fe; font-size: 12.5px; font-weight: 600; }
.rec-plan-table tr.row-replace td { background: rgba(251, 146, 60, 0.06); color: #fed7aa; font-size: 12.5px; }

.cohort-table .sticky-col,
.oldkpi-table .sticky-col { position: sticky; left: 0; z-index: 2; background: #10172d; box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45), 1px 0 0 var(--border); }
.cohort-table thead .sticky-col,
.oldkpi-table thead .sticky-col { z-index: 3; background: #1e2646; }


.lead-table .lead-row { cursor: pointer; transition: background 0.18s; }
.lead-table .lead-row:hover { background: rgba(148, 163, 214, 0.08); }
.lead-table .lead-row.is-active { background: rgba(139, 125, 255, 0.15); border-left: 3px solid var(--brand); }
.lead-table .lead-row.is-rec { font-weight: 600; }

.cohort-table td.floor-sub { font-size: 11.5px; color: var(--text-3); }
.rec-chart { height: 320px; margin-top: 14px; }
.rec-field-group { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rec-field-group .field { margin-bottom: 0; }
.rec-field-group .input.num { width: 85px; }

.rec-presets-box { margin: 0 16px 14px; padding: 14px 16px; background: rgba(139, 125, 255, 0.05); border: 1px solid rgba(139, 125, 255, 0.2); border-radius: var(--radius-sm); }
.btn-preset-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 6px 11px; border-radius: 8px; cursor: pointer; transition: all 0.18s var(--ease); }
.btn-preset-opt:hover { transform: translateY(-1px); border-color: var(--brand); }
.btn-preset-opt.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- Preset Option Cards (PA 1 & PA 2) ---- */
.opt-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 12px; }
@media (max-width: 960px) { .opt-card-grid { grid-template-columns: 1fr; } }
.opt-card { background: rgba(15, 23, 42, 0.65); border: 1.5px solid rgba(139, 125, 255, 0.2); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; position: relative; transition: all 0.2s ease; }
.opt-card:hover { border-color: rgba(139, 125, 255, 0.45); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); }
.opt-card.is-active { border-color: var(--brand); background: rgba(99, 102, 241, 0.12); box-shadow: 0 0 0 1px var(--brand), 0 4px 18px rgba(99, 102, 241, 0.25); }
.opt-card.is-rec { border-color: rgba(52, 211, 153, 0.35); }
.opt-card.is-rec.is-active { border-color: #34d399; background: rgba(52, 211, 153, 0.1); box-shadow: 0 0 0 1px #34d399, 0 4px 18px rgba(52, 211, 153, 0.25); }
.opt-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.opt-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.opt-card-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.opt-metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; background: rgba(7, 11, 22, 0.45); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
@media (max-width: 640px) { .opt-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.opt-metric-item .lbl { font-size: 10.5px; color: var(--text-3); margin-bottom: 2px; }
.opt-metric-item .val { font-size: 13px; font-weight: 700; color: var(--text); }
.opt-metric-item .val.up { color: var(--up); }
.opt-bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-2); }
.opt-bullets li { display: flex; align-items: baseline; gap: 6px; line-height: 1.35; }


/* ---- Tab Chất lượng đội sale (Tier) ---- */
.tier-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 12px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.tier-tag .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.tier-tag.t0 { background: rgba(244, 114, 182, 0.16); color: #f472b6; }
.tier-tag.t1 { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
.tier-tag.t2 { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; }
.tier-tag.t3 { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.tier-tag.t4 { background: rgba(251, 191, 36, 0.16); color: #fde68a; }
.tier-tag.t5 { background: rgba(251, 113, 133, 0.18); color: #fca5a5; }

.policy-toggle-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: rgba(7, 11, 22, 0.4); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.policy-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; background: rgba(7, 11, 22, 0.35); transition: border-color 0.2s, background 0.2s; position: relative; }
.policy-card.is-active { border-color: var(--brand); background: rgba(139, 125, 255, 0.08); box-shadow: 0 0 0 1px var(--brand); }
.policy-card .p-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.policy-card .p-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.timeline-strip { display: flex; gap: 6px; margin: 12px 0; overflow-x: auto; padding-bottom: 4px; }
.timeline-step { flex: 1; min-width: 90px; padding: 8px 10px; border-radius: 8px; background: rgba(148, 163, 214, 0.06); border: 1px solid var(--border); font-size: 11.5px; }
.timeline-step .t-m { font-weight: 700; color: var(--text); font-size: 12px; margin-bottom: 3px; }
.timeline-step.danger { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.08); }
.timeline-step.warning { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.timeline-step.success { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.timeline-step.info { border-color: rgba(139, 125, 255, 0.4); background: rgba(139, 125, 255, 0.08); }

.roi-pill { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.roi-pill.up { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.3); }

.eval-cell-pill { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.eval-cell-pill .pct { font-weight: 700; font-size: 12px; }
.eval-cell-pill .sub { font-size: 10px; color: var(--text-3); }
.eval-cell-pill.bad .pct { color: var(--down); }
.eval-cell-pill.ok .pct { color: var(--up); }
.eval-status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 8px; }
.eval-status-badge.stop { background: rgba(251, 113, 133, 0.18); color: #fca5a5; border: 1px solid rgba(251, 113, 133, 0.4); }
.eval-status-badge.pip { background: rgba(251, 191, 36, 0.18); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.4); }
.eval-status-badge.warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.4); }
.eval-status-badge.watch { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.eval-status-badge.ok { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }

/* ---- Tab Sale Đối Thủ ---- */
.rival-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.rival-table th, .rival-table td { padding: 7px 10px; font-variant-numeric: tabular-nums; }
.rival-table thead th { position: sticky; top: 0; z-index: 3; background: #141c36; }
.rival-table .sticky-col { position: sticky; left: 0; z-index: 2; background: #10172d; min-width: 190px; box-shadow: 1px 0 0 var(--border); }
.rival-table thead .sticky-col { z-index: 4; background: #141c36; }
.rival-table tr.row-grand-total td { background: #2e1065; color: #f5f3ff; font-weight: 700; border-bottom: 2px solid #7c3aed; }
.rival-table tr.row-grand-total .sticky-col { background: #2e1065; }
.rival-table tr:hover:not(.row-grand-total) td { background: rgba(255, 255, 255, 0.035); }
.btn-sale-name { background: none; border: none; color: #a5b4fc; font-weight: 600; cursor: pointer; padding: 0; text-align: left; font-size: 13.5px; transition: color 0.15s; }
.btn-sale-name:hover { color: #fff; text-decoration: underline; }
.tier-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tier-top { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.35); }
.tier-core { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border: 1px solid rgba(96, 165, 250, 0.35); }
.tier-low { background: rgba(245, 158, 11, 0.18); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.35); }
.order-table th, .order-table td { padding: 6px 9px; font-size: 12.5px; }

/* Layout lưới thẻ KPI & Phân tầng gọn gàng không bị dồn dọc */
.rival-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; }
.rival-tier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }

/* Bảng danh sách đơn hàng chi tiết (Ảnh 3) */
.rival-orders-section { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.rival-orders-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.rival-filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rival-month-pill { padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: var(--text-2); cursor: pointer; transition: all 0.15s; }
.rival-month-pill:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-1); }
.rival-month-pill.active { background: #4338ca; color: #ffffff; border-color: #6366f1; }
.rival-orders-table th, .rival-orders-table td { padding: 6px 10px; font-size: 12.5px; }

/* =====================================================================
   Bảo mật & Quản lý tài khoản (Auth, RBAC, Forensic Watermark, Lock)
   ===================================================================== */
/* Cổng đăng nhập toàn màn hình (Auth Gate Modal) */
.auth-gate-modal {
  position: fixed; inset: 0; z-index: 99999;
  background: radial-gradient(1200px 700px at 50% 20%, rgba(91, 140, 255, 0.18), transparent 70%),
              radial-gradient(800px 500px at 20% 80%, rgba(139, 125, 255, 0.14), transparent 60%),
              #060913;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
  animation: fadeIn 0.25s var(--ease);
}
.auth-box {
  width: 100%; max-width: 480px;
  background: linear-gradient(180deg, rgba(22, 32, 60, 0.94), rgba(12, 18, 38, 0.96));
  border: 1px solid rgba(139, 125, 255, 0.28);
  border-radius: 20px; padding: 34px 28px;
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(24px);
  animation: modalIn 0.3s var(--ease);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 55%, var(--al));
  display: inline-grid; place-items: center;
  color: #fff; font-size: 26px; margin-bottom: 12px;
  box-shadow: 0 10px 30px -8px rgba(139, 125, 255, 0.7);
}
.auth-brand h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 0.3px; }
.auth-brand-tag { margin: 4px 0 0; font-size: 13px; color: var(--text-3); }

.auth-header-desc {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px; font-size: 13px;
}
.auth-header-desc b { display: block; color: var(--text); margin-bottom: 2px; }
.auth-header-desc p { margin: 0; color: var(--text-2); font-size: 12.5px; }

.setup-welcome {
  background: rgba(139, 125, 255, 0.1); border: 1px solid rgba(139, 125, 255, 0.25);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 20px;
}
.setup-welcome h3 { margin: 0 0 6px; font-size: 14.5px; color: var(--brand); }
.setup-welcome p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }

.auth-form { display: grid; gap: 14px; }
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap .input { padding-right: 40px; }
.btn-eye {
  position: absolute; right: 10px; background: none; border: none;
  color: var(--text-3); cursor: pointer; padding: 4px; border-radius: 4px;
  display: grid; place-items: center; transition: color 0.15s;
}
.btn-eye:hover { color: var(--text); }
.pw-meter { height: 4px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width 0.25s, background-color 0.25s; }
.pw-meter span.down { background: var(--down); }
.pw-meter span.warn { background: var(--warn); }
.pw-meter span.up { background: var(--up); }
.pw-meter-label { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

.auth-options { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; padding: 0; text-decoration: underline; font-size: 12.5px; }
.btn-link:hover { color: #b1a7ff; }

.auth-roles-hint {
  display: grid; gap: 6px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3);
}
.hint-item { display: flex; align-items: center; gap: 8px; }
.hint-item svg { width: 14px; height: 14px; flex: none; }

/* Mã khôi phục khẩn cấp */
.recovery-box {
  background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.recovery-head { display: flex; align-items: center; gap: 8px; color: var(--warn); font-size: 13px; }
.recovery-desc { margin: 6px 0 10px; font-size: 12px; color: var(--text-2); line-height: 1.4; }
.recovery-key-row { display: flex; align-items: center; gap: 8px; }
.recovery-code {
  flex: 1; padding: 8px 12px; background: rgba(0, 0, 0, 0.4); border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-xs); font-family: Consolas, monospace; font-size: 16px;
  font-weight: 700; color: #fde68a; letter-spacing: 1.5px; text-align: center;
}

/* Khóa màn hình (Lock screen overlay) */
.screen-lock-overlay {
  position: fixed; inset: 0; z-index: 99998;
  background: rgba(7, 11, 22, 0.88); backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.25s var(--ease);
}
.lock-card {
  width: 100%; max-width: 420px; text-align: center;
  background: linear-gradient(180deg, rgba(24, 34, 64, 0.95), rgba(14, 20, 42, 0.98));
  border: 1px solid rgba(139, 125, 255, 0.25); border-radius: 20px; padding: 32px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.lock-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(139, 125, 255, 0.15); color: var(--brand);
  display: inline-grid; place-items: center; font-size: 26px; margin-bottom: 14px;
}
.lock-title { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.lock-sub { margin: 0 0 20px; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.lock-user-info {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 18px;
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--al));
  display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #fff; flex: none;
}
.user-fullname { font-weight: 700; font-size: 14px; }
.user-role-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; margin-top: 2px; }
.role-editor { color: var(--brand); }
.role-viewer { color: var(--al); }
.lock-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 10px; }

/* Watermark in chìm bảo mật chống chụp trộm (Forensic Watermark) */
.security-forensic-watermark {
  position: fixed; inset: 0; pointer-events: none; z-index: 99990;
  user-select: none; opacity: 0.85; background-repeat: repeat;
}

/* User pill trên Topbar */
.topbar-user-pill {
  display: flex; align-items: center; gap: 10px;
  background: rgba(20, 28, 52, 0.6); border: 1px solid var(--border);
  padding: 4px 10px 4px 6px; border-radius: 30px;
}
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--al));
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none;
}
.topbar-user-meta { display: flex; flex-direction: column; }
.topbar-username { font-size: 12.5px; line-height: 1.2; }
.topbar-role-badge { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }

/* Trang Quản lý tài khoản */
.account-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-num { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.account-layout-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1080px) { .account-layout-grid { grid-template-columns: 1fr; } }

.role-selector-grid { display: grid; gap: 10px; margin-top: 4px; }
.role-option input { display: none; }
.role-box {
  display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.18s;
  background: rgba(255, 255, 255, 0.02);
}
.role-option input:checked + .role-box {
  border-color: var(--brand); background: rgba(139, 125, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(139, 125, 255, 0.3);
}
.role-icon { font-size: 20px; flex: none; margin-top: 2px; }
.role-title { font-weight: 700; font-size: 13.5px; }
.role-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; line-height: 1.4; }

.account-table { width: 100%; border-collapse: collapse; }
.account-table th { text-align: left; padding: 10px 12px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--border); font-weight: 600; }
.account-table td { padding: 12px; border-bottom: 1px solid rgba(148, 163, 214, 0.08); vertical-align: middle; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--al));
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none;
}
.user-name-line { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.user-username-line { font-size: 12px; color: var(--text-3); font-family: Consolas, monospace; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

/* Cấu hình an ninh */
.security-cfg-grid { display: grid; gap: 14px; }
.cfg-item {
  display: flex; align-items: center; gap: 16px; padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.cfg-icon { font-size: 24px; flex: none; }
.cfg-content { flex: 1; }
.cfg-title { font-weight: 700; font-size: 13.5px; }
.cfg-sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.45; }
.cfg-control { flex: none; }

/* Switch Toggle */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: rgba(255, 255, 255, 0.14);
  border-radius: 24px; transition: 0.2s;
}
.slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
input:checked + .slider { background: var(--brand); }
input:checked + .slider::before { transform: translateX(20px); }

/* Bảng Audit Log */
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table th { text-align: left; padding: 8px 10px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.audit-table td { padding: 9px 10px; font-size: 12.5px; border-bottom: 1px solid rgba(148, 163, 214, 0.06); }

/* Khi ở chế độ Viewer */
body.role-viewer #btn-backup,
body.role-viewer #btn-restore { display: none !important; }
body.role-viewer .btn-danger:not(#modal-cancel):not(#modal-ok) { display: none !important; }
body.role-viewer input:not(#lock-password):not([type="search"]),
body.role-viewer select:not(#cfg-idle-minutes),
body.role-viewer textarea {
  pointer-events: none !important;
  opacity: 0.88 !important;
  border-color: rgba(148, 163, 214, 0.1) !important;
}

/* =====================================================================
   Giao diện Phân quyền Ma trận (Granular Menu RBAC)
   ===================================================================== */
.perm-header-bar {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 12px;
}
.perm-layout-grid {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start;
}
@media (max-width: 1024px) {
  .perm-layout-grid { grid-template-columns: 1fr; }
}

.perm-sidebar-card {
  position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.perm-user-list {
  display: grid; gap: 6px; overflow-y: auto; max-height: 520px; padding-right: 4px;
}
.perm-user-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.16s var(--ease);
}
.perm-user-item:hover {
  background: rgba(255, 255, 255, 0.05); border-color: rgba(148, 163, 214, 0.28);
}
.perm-user-item.active {
  background: rgba(139, 125, 255, 0.12); border-color: var(--brand);
  box-shadow: 0 0 0 1px rgba(139, 125, 255, 0.35);
}
.perm-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--al));
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none;
}
.perm-user-item-info { flex: 1; min-width: 0; }
.perm-user-item-name {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.perm-user-item-sub { font-size: 11.5px; color: var(--text-3); font-family: Consolas, monospace; }
.perm-user-item-tag { flex: none; }

/* Target Banner */
.perm-target-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: linear-gradient(135deg, rgba(139, 125, 255, 0.08), rgba(34, 211, 238, 0.04));
  border: 1px solid rgba(139, 125, 255, 0.2); border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.perm-target-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 55%, var(--al));
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; flex: none;
  box-shadow: 0 6px 18px -4px rgba(139, 125, 255, 0.5);
}
.perm-target-meta { flex: 1; }
.perm-target-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perm-target-title h3 { margin: 0; font-size: 17px; font-weight: 800; }
.perm-target-user { font-size: 13px; color: var(--text-3); font-family: Consolas, monospace; }
.perm-target-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* Preset roles */
.perm-presets-section {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.perm-presets-title { font-size: 12px; font-weight: 600; color: var(--text-2); }
.perm-presets-list { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-apply-preset {
  font-size: 12px; padding: 5px 10px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  transition: all 0.15s;
}
.btn-apply-preset:hover {
  background: rgba(139, 125, 255, 0.14); border-color: rgba(139, 125, 255, 0.4);
  color: #fff;
}

/* Ma trận Menu */
.perm-matrix-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.perm-matrix-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border);
}
.perm-matrix-head-options { display: flex; align-items: center; gap: 8px; }

.perm-groups-list { display: grid; }
.perm-group-box { border-bottom: 1px solid rgba(148, 163, 214, 0.08); }
.perm-group-box:last-child { border-bottom: none; }
.perm-group-title {
  padding: 8px 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-3); background: rgba(14, 20, 40, 0.4);
}
.perm-items-list { display: grid; }
.perm-item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-top: 1px solid rgba(148, 163, 214, 0.06);
  gap: 16px; transition: background 0.15s;
}
.perm-item-row:hover { background: rgba(255, 255, 255, 0.015); }
.perm-item-info { display: flex; align-items: center; gap: 12px; }
.perm-item-icon {
  width: 32px; height: 32px; border-radius: 8px; background: rgba(255, 255, 255, 0.04);
  display: grid; place-items: center; color: var(--text-2); flex: none;
}
.perm-item-name { font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.perm-item-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* 3-way Segmented Control */
.perm-segmented-control {
  display: inline-flex; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px; gap: 2px; flex: none;
}
.seg-option {
  position: relative; display: inline-flex; align-items: center; padding: 4px 10px;
  border-radius: 16px; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--text-3); transition: all 0.16s var(--ease); user-select: none;
}
.seg-option input { display: none; }
.seg-option:hover:not(.disabled) { color: var(--text); }
.seg-option.disabled { opacity: 0.4; cursor: not-allowed; }

.seg-option.seg-none.active {
  background: rgba(251, 113, 133, 0.18); color: #fda4af;
  border: 1px solid rgba(251, 113, 133, 0.35);
}
.seg-option.seg-view.active {
  background: rgba(34, 211, 238, 0.16); color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.35);
}
.seg-option.seg-edit.active {
  background: rgba(139, 125, 255, 0.22); color: #c4b5fd;
  border: 1px solid rgba(139, 125, 255, 0.4);
}

/* Khối đặc quyền */
.perm-caps-card {
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.perm-caps-grid { display: grid; gap: 10px; margin-top: 12px; }
.perm-cap-item { display: block; cursor: pointer; }
.perm-cap-item input { display: none; }
.perm-cap-box {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border);
  border-radius: var(--radius-xs); transition: all 0.15s;
}
.perm-cap-item input:checked + .perm-cap-box {
  background: rgba(139, 125, 255, 0.08); border-color: rgba(139, 125, 255, 0.35);
}
.perm-cap-icon { font-size: 20px; flex: none; }
.perm-cap-title { font-weight: 700; font-size: 13px; }
.perm-cap-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* Bottom actions */
.perm-bottom-actions {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* =====================================================================
   Hiệu ứng
   ===================================================================== */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* =====================================================================
   Màn hình nhỏ
   ===================================================================== */
@media (max-width: 1400px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1200px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 20px 16px 50px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =====================================================================
   Chế độ Chỉ xem (Viewer Protection Controls)
   ===================================================================== */
.viewer-banner {
  animation: fadeIn 0.25s ease-out;
}
.is-readonly-control {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  user-select: none !important;
}
button.is-readonly-control,
.btn.is-readonly-control,
.seg button.is-readonly-control {
  pointer-events: none !important;
  filter: grayscale(40%);
}

/* =====================================================================
   Sidebar User Card & Profile Modal
   ===================================================================== */
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.22s var(--ease);
  user-select: none;
  position: relative;
  overflow: hidden;
}
.sidebar-user-card:hover {
  background: rgba(139, 125, 255, 0.09);
  border-color: rgba(139, 125, 255, 0.38);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px -4px rgba(139, 125, 255, 0.25);
}
.sidebar-user-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.sidebar-user-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex: none;
}
.sidebar-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(139, 125, 255, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: block;
}
.sidebar-avatar-initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 60%, var(--al));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14.5px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 125, 255, 0.35);
}
.sidebar-user-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--up);
  border: 2px solid #0e1428;
  box-shadow: 0 0 6px var(--up);
}
.sidebar-user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-user-name {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.sidebar-user-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.sidebar-user-handle {
  color: var(--text-3);
  font-family: Consolas, monospace;
}
.sidebar-user-role-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sidebar-user-role-badge.role-editor {
  background: rgba(139, 125, 255, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(139, 125, 255, 0.3);
}
.sidebar-user-role-badge.role-viewer {
  background: rgba(34, 211, 238, 0.14);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.3);
}
.sidebar-user-cog {
  color: var(--text-3);
  opacity: 0.65;
  transition: all 0.2s var(--ease);
  flex: none;
  font-size: 14px;
}
.sidebar-user-card:hover .sidebar-user-cog {
  opacity: 1;
  color: var(--brand);
  transform: rotate(15deg);
}

.sidebar-user-unauth {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
}

/* Topbar avatar */
.topbar-avatar-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(139, 125, 255, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: block;
}

/* Profile Modal Details */
.profile-modal {
  animation: modalIn 0.3s var(--ease);
}
.profile-avatar-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.profile-avatar-preview-box {
  width: 72px;
  height: 72px;
  flex: none;
  position: relative;
}
.profile-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brand);
  box-shadow: 0 4px 18px rgba(139, 125, 255, 0.35);
  display: block;
}
.profile-avatar-fallback {
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 60%, var(--al));
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}
.profile-avatar-actions {
  flex: 1;
  min-width: 0;
}
.readonly-input-wrap {
  position: relative;
}
.readonly-input-wrap input {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--text-2) !important;
  border-color: rgba(148, 163, 214, 0.12) !important;
  cursor: not-allowed !important;
}
.profile-password-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.profile-password-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

