/* BreadTalk Sync — hệ thống giao diện thống nhất (màu & font theo breadtalkvietnam.com)
   Màu thương hiệu: cam #F6780A, cam nhạt #F9A747, nền kem #FCF8F0 / #F7F1E5
   Font: Work Sans (nội dung, tiêu đề — hỗ trợ đầy đủ tiếng Việt), Barlow Condensed (số liệu, nhãn)
   Chữ nhỏ nhất 13px. Nền sáng, không dùng nền tối. */
:root {
  --brand: #F6780A;
  --brand-light: #F9A747;
  --brand-strong: #C2570C;
  --brand-strong-hover: #A3480A;
  --brand-50: #FFF6EB;
  --brand-100: #FDE8CC;
  --cream: #FCF8F0;
  --cream-2: #F7F1E5;
  --surface: #FFFFFF;
  --ink: #2B2118;
  --ink-2: #4A3F35;
  --muted: #6B5E50;
  --border: #EADFCB;
  --border-strong: #D9C9AE;
  --ok: #15803D;
  --ok-bg: #ECFDF3;
  --warn: #B45309;
  --warn-bg: #FFF7E6;
  --err: #B91C1C;
  --err-bg: #FEF2F2;
  --info: #1D4ED8;
  --info-bg: #EFF5FF;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(43, 33, 24, .06), 0 4px 16px rgba(43, 33, 24, .05);
  --shadow-lg: 0 12px 40px rgba(43, 33, 24, .16);
  --font: "Work Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-num: var(--font); /* một font thống nhất cho chữ, số, tiền, % */
  --sidebar-w: 256px;
  --focus: 0 0 0 3px rgba(246, 120, 10, .35);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--cream); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font); margin: 0; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }
a { color: var(--brand-strong); }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.ic-sm { width: 16px; height: 16px; }

/* ---------- Đăng nhập ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--brand-100), transparent 60%), radial-gradient(900px 500px at 110% 110%, #FFE7C2, transparent 55%), var(--cream); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.wordmark { font-family: var(--font); font-weight: 700; font-size: 26px; letter-spacing: -.02em; color: var(--brand); line-height: 1; }
.wordmark b { color: var(--ink); font-weight: 700; }
.wordmark-sub { font-family: var(--font); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* ---------- Khung ứng dụng ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; z-index: 60; }
.sidebar .brand { padding: 4px 10px 12px; border-bottom: 1px solid var(--border); }
.nav-group-title { font-family: var(--font); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 9px 12px; border: 0; background: transparent; border-radius: 10px; color: var(--ink-2); font: 500 14px var(--font); text-align: left; cursor: pointer; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--cream-2); color: var(--ink); }
.nav-item.active { background: var(--brand-50); color: var(--brand-strong); font-weight: 600; }
.nav-item .count { margin-left: auto; font: 600 13px var(--font-num); background: var(--err-bg); color: var(--err); padding: 0 7px; border-radius: 999px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(252, 248, 240, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .title { min-width: 0; }
.topbar .title h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-100); color: var(--brand-strong); display: grid; place-items: center; font: 700 14px var(--font-num); }
.role-tag { font: 600 13px var(--font-num); letter-spacing: .04em; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.scrim { display: none; }

/* ---------- Thành phần cơ bản ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .hint { font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

label, .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=time], input[type=month], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; font: 400 14px var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input:disabled, select:disabled { background: var(--cream-2); color: var(--muted); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-strong); cursor: pointer; }
.field { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-strong); color: #fff; }
.btn-primary:hover { background: var(--brand-strong-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-outline:hover { background: var(--cream-2); border-color: var(--brand-light); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--cream-2); }
.btn-danger { background: var(--surface); border-color: #F3B4B4; color: var(--err); }
.btn-danger:hover:not(:disabled) { background: var(--err-bg); }
.btn-danger.confirming { background: var(--err); border-color: var(--err); color: #fff; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 34px; padding: 5px 12px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--brand-light); }
.chip.active { background: var(--brand-50); border-color: var(--brand); color: var(--brand-strong); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; min-height: 38px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--brand-50); color: var(--brand-strong); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font: 600 13px var(--font-num); letter-spacing: .03em; white-space: nowrap; }
.b-SUCCESS, .b-OK { background: var(--ok-bg); color: var(--ok); }
.b-WARNING { background: var(--warn-bg); color: var(--warn); }
.b-FAILED, .b-ERROR { background: var(--err-bg); color: var(--err); }
.b-RUNNING { background: var(--info-bg); color: var(--info); }
.b-CANCELLED, .b-MISSING, .b-SKIPPED { background: var(--cream-2); color: var(--muted); }
.b-ADMIN { background: var(--brand-50); color: var(--brand-strong); }
.b-VIEWER { background: var(--info-bg); color: var(--info); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 14px; }
.notice.warn { background: var(--warn-bg); border-color: #F5D9A8; color: #7A3E06; }
.notice.info { background: var(--info-bg); border-color: #C9D8FB; color: #1E3A8A; }
.notice.err { background: var(--err-bg); border-color: #F3B4B4; color: #7F1D1D; }
.notice.ok { background: var(--ok-bg); border-color: #BBE5C9; color: #14532D; }

/* Bảng */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--cream); font-weight: 600; font-size: 13px; color: var(--ink-2); white-space: nowrap; z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--brand-strong); }
tbody tr:hover td { background: #FFFBF4; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td input[type=text], td input[type=number], td select { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.delta { font: 600 13px var(--font-num); white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }
.delta.flat { color: var(--muted); }
.store-cell { display: flex; flex-direction: column; min-width: 160px; }
.store-cell .s1 { font-weight: 600; }
.store-cell .s2 { font-size: 13px; color: var(--muted); }
.bar-cell { position: relative; min-width: 120px; }
.bar-cell .bar { height: 8px; border-radius: 999px; background: var(--cream-2); overflow: hidden; margin-top: 4px; }
.bar-cell .bar i { display: block; height: 100%; background: var(--brand-light); border-radius: 999px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.kpi.primary { background: var(--brand-50); border-color: #F7CFA0; }
.kpi .k-label { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.3; min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpi .k-value { font: 700 28px/1.2 var(--font-num); letter-spacing: -.01em; color: var(--ink); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-value small { font-size: 17px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi .k-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.kpi .spark { height: 34px; margin-top: 6px; }

/* Bộ lọc báo cáo */
.filters { position: sticky; top: 65px; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 12px; }
.filters .f-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .f-row .field { width: 158px; }
.filters .f-row .field.wide { width: 220px; }
.filters .f-row .field.narrow { width: 112px; }
.filters .f-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.filter-toggle { display: none; }
.coverage { margin-top: 14px; }

/* Chọn nhiều cửa hàng */
.ms { position: relative; }
.ms-btn { width: 100%; min-height: 40px; padding: 8px 34px 8px 12px; text-align: left; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: 400 14px var(--font); color: var(--ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.ms-btn::after { content: ""; position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
.ms-panel { position: absolute; top: calc(100% + 6px); left: 0; width: 320px; max-width: calc(100vw - 32px); max-height: 380px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px; z-index: 50; }
.ms-panel .opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ms-panel .opt:hover { background: var(--cream-2); }
.ms-panel .grp { font: 600 13px var(--font-num); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 8px 2px; }

/* Biểu đồ */
.chart { width: 100%; height: 340px; }
.chart.sm { height: 260px; }
.chart.lg { height: 420px; }
.legend-note { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 9px 12px; min-height: 40px; font: 500 14px var(--font); color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--brand-strong); border-bottom-color: var(--brand); font-weight: 600; }

/* Bước chạy dữ liệu */
.pbar { height: 12px; background: var(--cream-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.pbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-light), var(--brand)); border-radius: 999px; transition: width .4s ease; }
.pbar-fill.running { background-image: linear-gradient(45deg, rgba(255,255,255,.3) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.3) 50%, rgba(255,255,255,.3) 75%, transparent 75%, transparent), linear-gradient(90deg, var(--brand-light), var(--brand)); background-size: 22px 22px, 100% 100%; animation: stripes 1s linear infinite; }
.pbar-fill.st-SUCCESS { background: var(--ok); }
.pbar-fill.st-WARNING { background: #D97706; }
.pbar-fill.st-FAILED { background: var(--err); }
.pbar-fill.st-CANCELLED { background: #A8998A; }
@keyframes stripes { from { background-position: 0 0, 0 0; } to { background-position: 22px 0, 0 0; } }
.pct { font: 700 18px var(--font-num); min-width: 48px; text-align: right; }
.steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 18px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 14px; border-bottom: 1px dashed var(--border); }
.step-ic { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px; display: inline-flex; align-items: center; justify-content: center; font: 700 13px var(--font-num); margin-top: 1px; }
.ic-PENDING { border: 2px solid var(--border-strong); }
.ic-RUNNING { border: 2px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.ic-OK { background: var(--ok-bg); color: var(--ok); }
.ic-ERROR { background: var(--err-bg); color: var(--err); }
.ic-SKIPPED { background: var(--cream-2); color: var(--muted); }
.ic-CANCELLED { background: var(--warn-bg); color: var(--warn); }
@keyframes spin { to { transform: rotate(360deg); } }
.step-note { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }
.step-note.err { color: var(--err); }
.result { border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 16px; border: 1px solid; }
.result h4 { margin: 0 0 6px; }
.res-SUCCESS { background: var(--ok-bg); border-color: #BBE5C9; color: #14532D; }
.res-WARNING { background: var(--warn-bg); border-color: #F5D9A8; color: #7A3E06; }
.res-FAILED { background: var(--err-bg); border-color: #F3B4B4; color: #7F1D1D; }
.res-CANCELLED { background: var(--cream-2); border-color: var(--border-strong); color: var(--ink-2); }
.err-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.err-list li { margin-bottom: 6px; }
.tb { background: var(--cream); color: var(--ink-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 13px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; margin-top: 8px; }
pre.console { background: var(--cream); color: var(--ink-2); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius-sm); font-size: 13px; overflow: auto; max-height: 360px; margin: 0; }

/* Lịch dữ liệu */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-head div { font: 600 13px var(--font-num); letter-spacing: .04em; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { min-height: 92px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.cal-day:hover { border-color: var(--brand-light); }
.cal-day.blank { visibility: hidden; }
.cal-day .d { font: 700 16px var(--font-num); }
.cal-day .v { font: 600 14px var(--font-num); color: var(--ink-2); }
.cal-day .s { font-size: 13px; color: var(--muted); }
.cal-day.st-OK { background: #F3FBF5; border-color: #BBE5C9; }
.cal-day.st-WARNING { background: #FFFAF0; border-color: #F5D9A8; }
.cal-day.st-FAILED, .cal-day.st-CANCELLED { background: #FEF5F5; border-color: #F3B4B4; }
.cal-day.st-MISSING { background: repeating-linear-gradient(45deg, #FFFFFF, #FFFFFF 6px, #F7F1E5 6px, #F7F1E5 12px); }
.cal-day.st-FUTURE { opacity: .5; cursor: default; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.cal-legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border-strong); }
.cal-legend .l-ok::before { background: #F3FBF5; border-color: #BBE5C9; }
.cal-legend .l-warn::before { background: #FFFAF0; border-color: #F5D9A8; }
.cal-legend .l-err::before { background: #FEF5F5; border-color: #F3B4B4; }
.cal-legend .l-miss::before { background: repeating-linear-gradient(45deg, #fff, #fff 3px, #F7F1E5 3px, #F7F1E5 6px); }

/* Danh sách bất thường */
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid #F3B4B4; background: var(--err-bg); border-radius: var(--radius-sm); font-size: 14px; }
.alert-list li .ic { color: var(--err); margin-top: 2px; }

/* Thẻ cửa hàng */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.store-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.store-card .top { display: flex; align-items: center; gap: 10px; }
.abbr { display: inline-grid; place-items: center; min-width: 46px; height: 30px; padding: 0 8px; border-radius: 8px; background: var(--brand-50); color: var(--brand-strong); font: 700 15px var(--font-num); letter-spacing: .04em; }
.store-card .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.store-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 13px; padding: 1px 8px; border-radius: 6px; background: var(--cream-2); color: var(--ink-2); }

/* Modal / ngăn kéo */
.modal-backdrop { position: fixed; inset: 0; background: rgba(43, 33, 24, .38); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 200; }
.modal-box { background: var(--surface); border-radius: 16px; width: 100%; max-width: 1120px; max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow-lg); }
.modal-box.narrow { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 300; max-width: 420px; font-size: 14px; }
.skeleton { background: linear-gradient(90deg, var(--cream-2), #FFF, var(--cream-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-overlay { position: relative; }
.loading-overlay.busy::after { content: ""; position: absolute; inset: 0; background: rgba(252, 248, 240, .55); border-radius: var(--radius); }

/* ---------- Đáp ứng ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .g-21, .g-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 284px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(43, 33, 24, .35); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .filters { top: 61px; }
}
@media (max-width: 760px) {
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 12px 8px; }
  .kpi .k-value { font-size: 24px; }
  .kpi .spark { display: none; }
  .topbar .title h1 { font-size: 17px; }
  .user-chip .uname, .user-chip .role-tag { display: none; }
  .user-chip { padding: 3px; }
  .filter-toggle { display: inline-flex; }
  .filters { position: static; }
  .filters .f-more { display: none; }
  .filters.expanded .f-more { display: flex; }
  .filters.expanded .field.f-more { display: block; }
  .filters .f-row .field, .filters .f-row .field.wide, .filters .f-row .field.narrow { width: calc(50% - 6px); }
  .filters .f-actions { margin-left: 0; width: 100%; }
  .filters .f-actions .btn { flex: 1; }
  .chart { height: 300px; }
  .chart.lg { height: 360px; }
  .cal-grid, .cal-head { gap: 4px; }
  .cal-day { min-height: 64px; padding: 5px; }
  .cal-day .v, .cal-day .s { display: none; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 94vh; border-radius: 16px 16px 0 0; padding: 18px 16px; }
  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  th, td { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.nowrap { white-space: nowrap; }
.btn-outline.confirming { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

/* Số liệu: cùng font Work Sans, chữ số đều cột để so sánh dễ */
body, .num, td, .kpi .k-value, .delta, .badge, .pct, .cal-day .v, .legend-list { font-variant-numeric: tabular-nums; }
/* Biểu đồ tròn + chú giải HTML (không đè chữ) */
.chart.donut { height: 230px; }
.donut-wrap { display: flex; flex-direction: column; gap: 10px; }
.legend-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; border-top: 1px solid var(--border); }
.legend-list li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid #F2EADB; font-size: 13px; }
.legend-list li i, .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch { margin-right: 8px; vertical-align: -1px; }
.legend-list li.muted { display: block; color: var(--muted); text-align: center; padding: 12px 2px; }
.legend-list .lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list .lg-val { font-weight: 600; text-align: right; }
.legend-list .lg-pct { color: var(--muted); text-align: right; }

/* ---- Chi tiết phiên (modal) ---- */
.modal-box.job-box { padding: 0; display: flex; flex-direction: column; overflow: hidden; max-width: min(1480px, 96vw); }
.jm-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.jm-title h2 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 20px; }
.jm-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.jm-actions .is-disabled { pointer-events: none; opacity: .45; }
.jm-body { overflow-y: auto; padding: 18px 22px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; overscroll-behavior: contain; }
.jm-body > * { min-width: 0; }
.jm-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; padding: 3px 10px; border-radius: 999px; font: 600 13px var(--font); white-space: nowrap; }
.p-ok { background: var(--ok-bg); color: var(--ok); } .p-warn { background: var(--warn-bg); color: var(--warn); }
.p-err { background: #FEF2F2; color: var(--err); } .p-info { background: var(--info-bg); color: var(--info); } .p-muted { background: #F3EEE6; color: var(--muted); }
.jm-status { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.jm-status.s-ok { background: #F6FDF8; border-color: #BBE5C9; } .jm-status.s-warn { background: #FFFBF3; border-color: #F5D9A8; }
.jm-status.s-err { background: #FEF6F6; border-color: #F3C4C4; } .jm-status.s-info { background: #F5F8FF; border-color: #C9D8FB; }
.jm-verdict { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.jm-verdict b { font-size: 17px; }
.s-ok .jm-verdict .ic { color: var(--ok); } .s-warn .jm-verdict .ic { color: var(--warn); } .s-err .jm-verdict .ic { color: var(--err); } .s-info .jm-verdict .ic { color: var(--info); }
.jm-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.jm-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.jm-stat .l { font-size: 13px; color: var(--muted); } .jm-stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jm-stat .s { font-size: 13px; color: var(--muted); }
.jm-sec h3 { margin: 0 0 10px; font-size: 16px; }
.jm-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.jm-sec-head h3 { margin: 0; } .jm-sec-head input { width: 220px; }
.jm-todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.jm-todo li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 14px; }
.jm-todo .t-ok { background: var(--ok-bg); } .jm-todo .t-ok .ic { color: var(--ok); }
.jm-todo .t-warn { background: var(--warn-bg); } .jm-todo .t-warn .ic { color: var(--warn); }
.jm-todo .t-err { background: #FEF2F2; } .jm-todo .t-err .ic { color: var(--err); }
.jm-todo .t-info { background: var(--info-bg); } .jm-todo .t-info .ic { color: var(--info); }
.jm-todo .ic { margin-top: 2px; flex: none; }
.jm-warn { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
.jm-warn summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; cursor: pointer; list-style: none; }
.jm-warn summary::-webkit-details-marker { display: none; }
.jm-warn summary::after { content: "Xem"; margin-left: auto; font-size: 13px; color: var(--brand-strong); font-weight: 600; }
.jm-warn[open] summary::after { content: "Thu gọn"; }
.jm-warn .jm-desc { flex-basis: 100%; }
.jm-warn ul { margin: 0; padding: 4px 14px 12px 30px; max-height: 320px; overflow: auto; font-size: 13px; display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.jm-adv { margin-top: 4px; color: var(--ink-2); }
.jm-arts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.jm-art { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.jm-art .small { grid-column: 1 / -1; } .jm-art.bad { border-color: #F3C4C4; background: #FEF6F6; }
.jm-table { overflow-x: auto; }
.jm-table table { width: 100%; min-width: 900px; }
.jm-table th, .jm-table td { padding: 9px 10px; }
.jm-table thead th { position: static; background: var(--surface-2, #FBF6EE); }
.jm-table tfoot td { background: var(--surface-2, #FBF6EE); font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.jm-table .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 160px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--border); }
.jm-table thead .sticky-col, .jm-table tfoot .sticky-col { z-index: 3; background: var(--surface-2, #FBF6EE); }
.jm-table td.num, .jm-table th.num { white-space: nowrap; }
.jm-table tr.row-bad td { background: #FEF6F6; }
.jm-table tbody tr:hover td, .jm-table tbody tr:hover td.sticky-col { background: #FFFBF4; }
@media (max-width: 900px) { .jm-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .modal-box.job-box { max-height: 94vh; }
  .jm-head { padding: 14px 16px 12px; } .jm-body { padding: 14px 16px 20px; }
  .jm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .jm-actions .btn { justify-content: center; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  .jm-title h2 { font-size: 18px; }
  .jm-sec-head input { width: 100%; }
  .jm-table .sticky-col { min-width: 130px; max-width: 150px; }
}
.jm-arts-tbl { min-width: 860px !important; }
.jm-note { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jm-table td.muted.num { color: var(--muted); width: 44px; }

/* Xuất file Excel */
.xl-list { margin: 6px 0 0; padding-left: 18px; }
.xl-list li { margin: 4px 0; overflow-wrap: anywhere; }
.xl-list li .btn { margin-left: 6px; vertical-align: middle; }
.mt-s { margin-top: 8px; }
#xl-run-send.confirming, #xd-now.confirming { background: var(--warn-bg); }
