/* Shared style cho Hub + cac trang bao cao KPI.
   Ke thua phong cach Demo-Report.html (font Be Vietnam Pro, do GearVN, the bo goc,
   pill, thanh xep hang). Mau semantic: green/amber/red. */

:root {
  --gv-red: #E30613;
  --gv-dark: #1a1d21;
  --ink: #1f2933;
  --muted: #667085;
  --line: #e6e8eb;
  --bg: #f5f6f8;
  --card: #fff;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --blue: #1a73e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
}

/* ---- Header ---- */
header { background: var(--gv-dark); color: #fff; border-bottom: 4px solid var(--gv-red); }
.head-wrap { max-width: 1180px; margin: 0 auto; padding: 18px 24px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.logo {
  background: var(--gv-red); color: #fff; font-weight: 800; letter-spacing: .5px;
  padding: 5px 11px; border-radius: 5px; font-size: 15px;
}
.brand .sub { font-size: 12.5px; color: #aeb4bb; text-transform: uppercase; letter-spacing: 1.2px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
header h1 { font-size: 25px; font-weight: 800; letter-spacing: -.2px; }
.head-note { font-size: 13.5px; color: #c3c8cf; margin-top: 5px; max-width: 760px; }
.btn-logout {
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.2);
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 16px;
  border-radius: 8px; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,.16); }
.crumb {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 18px;
}
.crumb a {
  color: var(--gv-red); text-decoration: none; font-weight: 700;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.crumb a:hover { background: var(--gv-red); color: #fff; border-color: var(--gv-red); }
.crumb #updatedAt { color: var(--muted); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 26px 24px 50px; }

/* ---- Card ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 22px; box-shadow: 0 1px 2px rgba(16,24,40,.04); margin-bottom: 22px;
}
.card h3 { font-size: 16px; font-weight: 700; color: var(--gv-dark); margin-bottom: 4px; }
.card .sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ---- Hub: 6 o KPI ---- */
.group-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin: 6px 2px 12px; }
.hub-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.hub-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.handover-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: #fff; border: 1px solid var(--line); border-top: 5px solid var(--gv-red);
  border-radius: 12px; padding: 22px 24px; margin-bottom: 16px;
  box-shadow: 0 8px 26px rgba(16,24,40,.08);
}
.handover-banner .banner-kicker {
  display: inline-flex; align-items: center; height: 24px; border-radius: 6px;
  background: rgba(227,6,19,.10); color: var(--gv-red);
  font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  padding: 0 9px; margin-bottom: 8px;
}
.handover-banner h2 {
  color: var(--gv-dark); font-size: 24px; font-weight: 800; line-height: 1.2;
}
.handover-banner p {
  color: var(--muted); max-width: 720px; margin-top: 7px; font-size: 14px;
}
.handover-banner .banner-btn {
  flex-shrink: 0; padding: 12px 18px; box-shadow: 0 6px 18px rgba(227,6,19,.22);
}
.kpi-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 8px; position: relative; border-top: 4px solid var(--line);
}
.kpi-tile.live { cursor: pointer; }
.kpi-tile.live:hover { box-shadow: 0 6px 18px rgba(16,24,40,.10); transform: translateY(-2px); transition: .15s; }
.kpi-tile.disabled { opacity: .72; cursor: default; }
.kpi-tile .kpi-no { font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi-tile .kpi-name { font-size: 17px; font-weight: 700; color: var(--gv-dark); }
.kpi-tile .kpi-sub { font-size: 13px; color: var(--muted); min-height: 34px; }
.kpi-tile .kpi-meta { font-size: 12.5px; color: #475467; display: flex; gap: 14px; flex-wrap: wrap;
  min-height: 38px; align-content: flex-start; }
.kpi-tile .kpi-meta b { color: var(--ink); font-weight: 600; }
.tile-foot { display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 12px; }

/* ---- Pills / badges ---- */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 6px; }
.pill-live { background: rgba(16,185,129,.14); color: #047857; }
.pill-soon { background: rgba(245,158,11,.16); color: #92600a; }
.pill-blocked { background: rgba(102,112,133,.15); color: #475467; }
.dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.red::before { background: var(--red); }
.dot.green::before { background: var(--green); }
.dot.amber::before { background: var(--amber); }

/* severity text colors */
.sev-green { color: #047857; font-weight: 600; }
.sev-amber { color: #92600a; font-weight: 600; }
.sev-red { color: #b91c1c; font-weight: 700; }

/* ---- KPI report: 4 the so ---- */
.statcards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.statcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 15px 16px;
  border-left: 4px solid var(--line); }
.statcard.green { border-left-color: var(--green); }
.statcard.amber { border-left-color: var(--amber); }
.statcard.red { border-left-color: var(--red); }
.statcard .l { font-size: 12.5px; color: var(--muted); }
.statcard .v { font-size: 26px; font-weight: 700; margin-top: 3px; }

/* ---- Bieu do xu huong (SVG/canvas container) ---- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---- Xep hang cua hang/bo phan ---- */
.rank-row { display: flex; align-items: center; gap: 14px; padding: 11px 4px; border-top: 1px solid var(--line); }
.rank-row:first-child { border-top: none; }
.rank-pos { width: 26px; height: 26px; border-radius: 50%; background: #eef0f2; color: #475467;
  font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-pos.top { background: var(--gv-red); color: #fff; }
.rank-name { font-weight: 600; flex: 1; min-width: 120px; }
.rank-bar { flex: 2; height: 9px; background: #eef0f2; border-radius: 5px; overflow: hidden; max-width: 320px; }
.rank-bar i { display: block; height: 100%; background: var(--red); border-radius: 5px; }
.rank-score { font-weight: 700; width: 48px; text-align: right; }

/* ---- Thanh loc sticky ---- */
.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; position: sticky; top: 0;
  background: var(--bg); padding: 12px 0; z-index: 5; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field select, .field input { height: 38px; border: 1px solid #d8dce0; border-radius: 7px;
  padding: 0 11px; font-family: inherit; font-size: 14px; background: #fff; }
.field select:focus, .field input:focus {
  outline: none; border-color: var(--gv-red); box-shadow: 0 0 0 3px rgba(227,6,19,.08); }
.btn { background: var(--gv-red); color: #fff; border: none; font-family: inherit; font-size: 14px;
  font-weight: 700; padding: 10px 18px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: #c40511; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #d8dce0; }
.btn.ghost:hover { background: #f3f4f6; }

/* ---- Bang chi tiet ---- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
table.detail { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 760px; }
table.detail thead th { background: var(--gv-dark); color: #fff; font-weight: 600; text-align: left;
  padding: 9px 11px; white-space: nowrap; font-size: 11.5px; position: sticky; top: 0; }
table.detail tbody td { padding: 8px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.detail tbody tr:nth-child(even) { background: #fafbfc; }
.mono { font-family: ui-monospace, Menlo, monospace; color: #64748b; font-size: 11.5px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px; font-size: 14px; }

/* ---- Form giai trinh ---- */
.case-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.case-grid div {
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: #fafbfc;
}
.case-grid span {
  display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 4px;
}
.case-grid b { font-size: 14px; overflow-wrap: anywhere; }
.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.field textarea {
  border: 1px solid #d8dce0; border-radius: 7px; padding: 10px 11px;
  font-family: inherit; font-size: 14px; background: #fff; resize: vertical; min-height: 108px;
}
.field textarea:focus {
  outline: none; border-color: var(--gv-red); box-shadow: 0 0 0 3px rgba(227,6,19,.08);
}
.action-row { display: flex; gap: 12px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: grid; grid-template-columns: 100px 1fr auto; gap: 12px; align-items: center;
  border-top: 1px solid var(--line); padding: 10px 0; font-size: 13px;
}
.history-item:first-child { border-top: none; }
.history-item em { color: var(--muted); font-style: normal; text-align: right; }
.mini-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 74px; height: 28px; padding: 0 9px; border-radius: 7px;
  border: 1px solid #d8dce0; background: #fff; color: var(--ink);
  text-decoration: none; font-weight: 700; font-size: 12px;
}
.mini-link:hover { border-color: var(--gv-red); color: var(--gv-red); }
.explain-pending { color: #92600a; font-weight: 700; }
.explain-waived { color: #047857; font-weight: 700; }
.explain-penalty { color: #b91c1c; font-weight: 700; }
.explain-none { color: var(--muted); }

/* ---- Daily report van hanh ---- */
.daily-section { scroll-margin-top: 18px; }
.section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.section-head .sub { margin-bottom: 0; max-width: 760px; }
.daily-form-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  margin-bottom: 14px;
}
.daily-alert {
  border: 1px solid var(--line); background: #fafbfc; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.daily-kpi-list { display: flex; flex-direction: column; gap: 14px; }
.daily-kpi {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 15px; display: flex; flex-direction: column; gap: 12px;
}
.daily-kpi-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start;
}
.daily-kpi-head b { display: block; font-size: 15px; color: var(--gv-dark); margin-bottom: 3px; }
.daily-kpi-head p { color: var(--muted); font-size: 13px; margin: 0; max-width: 760px; }
.status-segment {
  display: inline-grid; grid-template-columns: repeat(3, minmax(84px, 1fr));
  border: 1px solid #d8dce0; border-radius: 8px; overflow: hidden; background: #fff;
}
.segment {
  min-height: 36px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 10px; font-size: 12.5px; font-weight: 700; color: #475467;
  cursor: pointer; border-right: 1px solid #d8dce0; white-space: nowrap;
}
.segment:last-child { border-right: none; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment.active { background: var(--gv-dark); color: #fff; }
.daily-kpi textarea { width: 100%; }
.case-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; font-weight: 700; color: var(--gv-dark);
}
.daily-case-empty {
  border: 1px dashed #d8dce0; border-radius: 8px; padding: 14px;
}
.daily-case-table { display: flex; flex-direction: column; gap: 8px; }
.case-row {
  display: grid; grid-template-columns: 130px minmax(180px, 1.4fr) 150px 110px minmax(160px, 1fr) 34px;
  gap: 8px; align-items: center;
}
.case-row input {
  height: 36px; border: 1px solid #d8dce0; border-radius: 7px;
  padding: 0 10px; font-family: inherit; font-size: 13px; background: #fff; min-width: 0;
}
.case-row input:focus {
  outline: none; border-color: var(--gv-red); box-shadow: 0 0 0 3px rgba(227,6,19,.08);
}
.icon-btn {
  width: 34px; height: 34px; border: 1px solid #d8dce0; border-radius: 7px;
  background: #fff; color: #475467; cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover { border-color: var(--gv-red); color: var(--gv-red); }
button:disabled { opacity: .6; cursor: not-allowed; }
.row-late td { background: #fff7ed; }
.row-missing td { background: #fef2f2; color: #991b1b; font-weight: 700; }
.daily-filters { position: static; background: transparent; padding-top: 0; }

@media (max-width: 880px) {
  .handover-banner { align-items: flex-start; flex-direction: column; }
  .hub-grid { grid-template-columns: 1fr 1fr; }
  .statcards { grid-template-columns: 1fr 1fr; }
  .case-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .daily-form-grid { grid-template-columns: 1fr 1fr; }
  .daily-kpi-head { grid-template-columns: 1fr; }
  .status-segment { width: 100%; }
  .case-row { grid-template-columns: 1fr 1fr; }
  .case-row .icon-btn { width: 100%; }
  .history-item { grid-template-columns: 1fr; gap: 3px; }
  .history-item em { text-align: left; }
}
@media (max-width: 560px) {
  .hub-grid { grid-template-columns: 1fr; }
  .case-grid { grid-template-columns: 1fr; }
  .daily-form-grid { grid-template-columns: 1fr; }
  .status-segment { grid-template-columns: 1fr; }
  .segment { border-right: none; border-bottom: 1px solid #d8dce0; }
  .segment:last-child { border-bottom: none; }
  .case-row { grid-template-columns: 1fr; }
}
