:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #d9dee5;
  --head: #eef1f5;
  --accent: #0b5cad;
  --ok: #17794a;
  --ok-bg: #eaf6f0;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --bad: #b3261e;
  --bad-bg: #fdecea;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 56px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 10px 18px;
  margin-bottom: -1px;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.coming-soon { padding: 56px 16px; text-align: center; color: var(--muted); font-size: 17px; font-weight: 600; }

h1 { margin: 2px 0 4px; font-size: 26px; }
.app-logo { width: 34px; height: 34px; margin-right: 10px; vertical-align: -7px; }
.week-info { margin: 0 0 20px; font-weight: 600; color: var(--accent); }

section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

h2 { margin: 0 0 4px; font-size: 17px; }
.optional { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.app-version { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
code { font-family: Consolas, monospace; font-size: 12.5px; background: var(--head); padding: 1px 4px; border-radius: 3px; }

.slots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }

.slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 132px;
  padding: 10px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
}
.slot.drag { border-color: var(--accent); background: #eef5fc; }
.slot.ok { border: 1.5px solid var(--ok); background: var(--ok-bg); }
.slot.warn { border: 1.5px solid var(--warn); background: var(--warn-bg); }
.slot.bad { border: 1.5px solid var(--bad); background: var(--bad-bg); }

.slot-day { font-weight: 700; }
.slot-date { font-size: 13px; color: var(--muted); }
.slot-file { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.slot-msg { font-size: 12px; }
.slot.warn .slot-msg { color: var(--warn); }
.slot.bad .slot-msg { color: var(--bad); }

.slot-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }

.btn {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { background: #eef5fc; }
.btn:focus-within, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.plain { border-color: var(--line); color: var(--muted); }
.btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.prev-slot { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.prev-slot .slot-actions { margin: 0; padding: 0; }

.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice ul { margin: 4px 0 0; padding-left: 20px; }
.notice strong { display: block; }
.notice li { margin-top: 6px; }
.notice-where { display: block; font-weight: 600; }

.report-title { margin: 8px 0 14px; text-align: center; font-size: 16px; }

.incident-text { padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px; line-height: 1.7; white-space: pre-wrap; tab-size: 4; }
.incident-text:empty { display: none; }
.typical-summary { margin-top: 14px; }
.typical-table td.tick, .typical-table th.tick { width: 40px; padding: 4px; text-align: center; }
.typical-table input[type="checkbox"] { width: 16px; height: 16px; vertical-align: middle; cursor: pointer; }
.typical-table td.stt { width: 48px; text-align: center; }
.typical-table td.time { width: 84px; text-align: center; white-space: nowrap; }
.typical-table td.detail-text { white-space: pre-line; }
.typical-table tr.date-row td { font-weight: 700; }
.typical-form th { background: #fce4d6; font-weight: 700; }

.table-wrap { overflow-x: auto; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border: 1px solid var(--line); padding: 5px 8px; }
th { background: var(--head); font-weight: 600; text-align: center; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.label { white-space: nowrap; }
td.group { font-weight: 600; text-align: center; background: var(--head); }
td.key { font-weight: 600; background: #f8f9fb; }

.bottom { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.bottom .table-wrap { margin-bottom: 0; }

.subhead { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.incidents { margin-top: 18px; }
.incidents .table-wrap { margin-bottom: 0; }
.incident-table td.group { width: 130px; }
.incident-table td.num { text-align: center; padding: 8px 6px; }
.incident-table .group-start,
.incident-table tbody td:nth-child(3n+2) { border-left: 2px solid #aab3bf; }
.incident-table tbody td:nth-child(3n+4) { background: #f3f5f8; font-weight: 700; }
.incident-table td.up { color: var(--bad); font-weight: 600; }
.incident-table td.down { color: var(--ok); font-weight: 600; }
input.prev.count { width: 62px; text-align: center; }
.cut-sum { margin: 0 0 8px; font-size: 14px; }
.cut-sum b { font-variant-numeric: tabular-nums; }
.cut-note { margin: 6px 0 0; }

.assess { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.assess li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.assess li:last-child { border-bottom: 0; }
.assess b { font-variant-numeric: tabular-nums; }
.assess .cmp { display: block; color: var(--muted); font-size: 13px; }

input.prev {
  width: 118px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
input.prev:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.prev-assess { margin-left: 4px; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.filters select { background: var(--surface); color: var(--text); }
#typicalDay, .pick-toggle { min-height: 44px; padding: 9px 12px; font-size: 16px; }
#typicalDay { width: 320px; max-width: 100%; }
.day-label { font-size: 15px; font-weight: 700; }
.pick-label { display: block; margin-bottom: 3px; font-size: 13px; color: var(--muted); }
.pick-drop { position: relative; }
.pick-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.pick-toggle:hover:not([disabled]) { border-color: var(--accent); }
.pick-toggle[disabled] { color: var(--muted); cursor: default; }
.pick-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  width: 720px;
  max-width: calc(100vw - 64px);
  max-height: 380px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(28, 36, 48, .18);
}
.pick-band { padding: 5px 12px; background: var(--head); font-size: 13px; font-weight: 700; }
.filters .pick-item { flex-direction: row; align-items: center; gap: 10px; padding: 7px 12px; font-size: 14px; color: var(--text); cursor: pointer; border-top: 1px solid var(--line); }
.pick-item:hover { background: #f4f8fd; }
.pick-item.on { background: #eef5fc; }
.filters .pick-item input { flex: none; width: 16px; height: 16px; padding: 0; cursor: pointer; }
.pick-stt { flex: none; width: 24px; text-align: center; color: var(--muted); }
.pick-time { flex: none; width: 52px; }
.pick-name { flex: 1; min-width: 0; }
.pick-more { flex: none; font-size: 12.5px; color: var(--muted); }
.pick-type { flex: none; width: 76px; text-align: right; font-size: 12.5px; color: var(--muted); }
.filters input, .filters select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  color: var(--text);
}
.filters input[type="search"] { width: 260px; }
.filters input[type="number"] { width: 90px; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.line-summary { margin: 0; padding-bottom: 6px; font-size: 14px; }

td.center { text-align: center; }

.line-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.line-toggle:hover { text-decoration: underline; }
.line-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.line-toggle::before { content: "▸ "; }
.line-toggle[aria-expanded="true"]::before { content: "▾ "; }

tr.detail > td { padding: 8px 8px 12px 24px; background: #f8f9fb; }
tr.detail table { font-size: 13px; background: var(--surface); }
tr.detail td.time { white-space: nowrap; }
.empty { margin: 0; padding: 12px 0; color: var(--muted); font-size: 14px; }

.export-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }
.btn.primary { padding: 7px 16px; background: var(--accent); color: #fff; font-size: 14px; }
.btn.primary:hover { background: #094c8f; }
.btn[disabled], .btn[disabled]:hover {
  border-color: var(--line);
  background: var(--head);
  color: var(--muted);
  cursor: not-allowed;
}
#exportInfo.bad, #dailyExportInfo.bad { color: var(--bad); }
#exportInfo.ok, #dailyExportInfo.ok { color: var(--ok); font-weight: 600; }

/* Báo cáo ngày: xem trước mục V */
.plan-table td { vertical-align: top; }
.plan-table td.stt { width: 44px; text-align: center; }
.plan-table td.time { width: 64px; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan-table td.detail-text { white-space: pre-line; }
.plan-table td.ptt { width: 150px; font-size: 13px; }
.plan-table td.target { width: 120px; }
.plan-table select { padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.plan-table tr.part td { background: var(--head); font-weight: 700; }
.plan-table tr.struck td.name { text-decoration: line-through; color: var(--muted); }
.plan-note { font-size: 12px; color: var(--muted); }

.picked-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 8px;
}
.picked-head .subhead { margin: 0; }
/* Bản sạch của bảng, chỉ dùng để sao chép sang Word. */
.offscreen { position: absolute; left: -99999px; top: 0; width: 1100px; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; }

@media (max-width: 1000px) {
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom { grid-template-columns: minmax(0, 1fr); }
}
#dailyPreparer { width: 260px; max-width: 100%; }

/* Số liệu ngày (BCTONGHOP) */
.drop-zone { min-height: 64px; }
.drop-zone.drag { border-color: var(--accent); background: #eef5fc; }
.th-date { margin-top: 12px; align-items: center; }
.th-date .hint { margin: 16px 0 0; }
.th-table td.label { white-space: nowrap; }
.th-table tr.key td { font-weight: 700; background: #f8f9fb; }
.th-table .at { margin-left: 6px; color: var(--muted); font-weight: 400; }
.th-table .miss { color: var(--bad); font-weight: 600; }
.th-table .tmp { margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.th-chart { margin: 0; }
.th-chart svg { width: 100%; max-width: 760px; height: auto; display: block; }
.th-chart .grid { stroke: var(--line); stroke-width: 1; }
.th-chart .tick { fill: var(--muted); font-size: 11px; }
.th-chart path { fill: none; stroke-width: 2; }
.th-chart path.total { stroke: var(--accent); }
.th-chart path.kv { stroke: #d9822b; }
.th-chart figcaption { font-size: 13px; color: var(--muted); }
.th-chart .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: -1px; }
.th-chart .dot.total { background: var(--accent); margin-left: 0; }
.th-chart .dot.kv { background: #d9822b; }
.force-row { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--bad); }
.th-part { margin-top: 14px; }
.th-part-title { margin: 0 0 2px; font-size: 15px; }
.th-part .hint { margin-bottom: 8px; }
.hotline-note { color: #c00000; white-space: pre-line; }
