@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

/* ============================================================
   Lịch cắt điện — hệ thiết kế
   Ý tưởng chủ đạo: mỗi lịch cắt điện là một "dải 24 giờ",
   phần bị tô đậm = khoảng thời gian mất điện.
   ============================================================ */

:root {
  --ink: #152232;
  --ink-soft: #24374d;
  --muted: #6b7c8f;
  --line: #dfe6ed;
  --line-soft: #eef2f6;
  --paper: #f1f4f8;
  --card: #ffffff;

  --volt: #f2a20c;
  --volt-bg: #fef6e4;
  --live: #d63437;
  --live-bg: #fdeceb;
  --done: #12916a;
  --done-bg: #e7f5ef;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(21, 34, 50, .06), 0 8px 24px -16px rgba(21, 34, 50, .25);

  --wrap: 1120px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--volt);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Thanh trên cùng ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--volt);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand__mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--volt);
  color: var(--ink);
  border-radius: 8px;
}
.brand__mark svg { width: 17px; height: 17px; }
.brand__name { font-size: 16px; }
.brand__name span { display: block; font-size: 11px; font-weight: 400; color: #9fb0c2; line-height: 1.2; }

.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topnav a {
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: #c6d2de;
}
.topnav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.topnav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .12); }

@media (max-width: 720px) {
  .topnav a { padding: 7px 9px; font-size: 13px; }
  .brand__name span { display: none; }
}

/* ---------- Cảnh báo nguồn dữ liệu ---------- */
.disclaimer {
  background: var(--volt-bg);
  border-bottom: 1px solid #f0e0bd;
  font-size: 13px;
  color: #7a5a10;
}
.disclaimer .wrap { padding-top: 9px; padding-bottom: 9px; }
.disclaimer a { text-decoration: underline; font-weight: 500; }

/* ---------- Khối tra cứu (trang chủ) ---------- */
.hero {
  background-color: var(--ink);
  background-image: radial-gradient(820px 300px at 10% -35%, #2c4360 0%, transparent 62%);
  color: #fff;
  padding: 44px 0 38px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4.4vw, 38px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  max-width: 18ch;
}
.hero p {
  margin: 0 0 22px;
  color: #a9bacb;
  max-width: 56ch;
}

/* Ô tìm kiếm lớn */
.finder { position: relative; max-width: 620px; }
.finder__field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: var(--r);
  padding: 4px 4px 4px 14px;
  box-shadow: 0 12px 30px -18px rgba(0, 0, 0, .8);
}
.finder__field svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.finder input {
  flex: 1;
  border: 0;
  padding: 12px 0;
  font-size: 16px;
  background: transparent;
}
.finder input:focus { outline: none; }
.finder__btn {
  border: 0;
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r-sm);
  font-weight: 600;
  cursor: pointer;
}
.finder__btn:hover { background: var(--ink-soft); }

.finder__results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  background: #fff;
  border-radius: var(--r);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  display: none;
  z-index: 30;
}
.finder__results.is-open { display: block; }
.finder__results a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 15px;
}
.finder__results a:hover,
.finder__results a.is-active { background: var(--line-soft); }
.finder__results em { font-style: normal; color: var(--muted); font-size: 13px; }
.finder__empty { padding: 14px; color: var(--muted); font-size: 14px; }

.hero__quick { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hero__quick b { font-size: 13px; font-weight: 500; color: #8ea0b3; margin-right: 2px; }
.chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 13px;
  background: rgba(255, 255, 255, .1);
  color: #dbe4ed;
  border: 1px solid rgba(255, 255, 255, .12);
}
.chip:hover { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- Bố cục nội dung ---------- */
.main { padding: 26px 0 46px; }
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 26px; align-items: start; }
@media (max-width: 940px) { .layout { grid-template-columns: 1fr; } }

.section { margin-bottom: 30px; }
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section__head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.section__head p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Danh sách tỉnh theo miền ---------- */
.region { margin-bottom: 22px; }
.region__title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 0 0 10px;
}
.region__title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.region__count {
  background: var(--line-soft); color: var(--muted);
  padding: 1px 8px; border-radius: 100px; font-size: 12px; font-weight: 500;
}

.province-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
}
.province-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 14.5px;
  font-weight: 500;
}
.province-grid a:hover { border-color: var(--ink); }
.province-grid a.is-hot { border-left: 3px solid var(--volt); }
.province-grid .n { font-size: 12px; font-weight: 600; color: var(--muted); }
.province-grid .n.has { color: var(--live); }

/* ---------- Trang tỉnh: tiêu đề ---------- */
.crumb { font-size: 13px; color: var(--muted); padding: 14px 0 0; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }
.crumb span { margin: 0 6px; color: #b9c4cf; }

.page-head { padding: 10px 0 18px; }
.page-head h1 {
  margin: 0 0 6px;
  font-size: clamp(23px, 3.4vw, 31px);
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-head__meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.page-head__meta b { font-weight: 500; color: var(--ink); }

/* Thẻ tóm tắt */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
@media (max-width: 560px) { .summary { grid-template-columns: 1fr; } }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}
.stat__k { font-size: 13px; color: var(--muted); }
.stat__v { font-size: 26px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
.stat--live { border-color: #f4c9c8; background: var(--live-bg); }
.stat--live .stat__v { color: var(--live); }
.stat--next { border-left: 3px solid var(--volt); }
.stat__sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Thanh lọc ---------- */
.filters {
  position: sticky;
  top: 58px;
  z-index: 20;
  background: var(--paper);
  padding: 10px 0;
  margin-bottom: 6px;
}
.filters__row { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tabs .badge { font-size: 11px; opacity: .75; margin-left: 4px; }

.filter-input, .filter-select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 14px;
  min-width: 0;
}
.filter-input { flex: 1; min-width: 180px; }
.filter-select { max-width: 240px; }

/* ---------- Nhóm theo ngày ---------- */
.day { margin-bottom: 18px; }
.day__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.day__date { font-size: 15px; font-weight: 700; }
.day__dow { font-size: 13px; color: var(--muted); }
.day__tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--ink);
  color: #fff;
}
.day__tag--tomorrow { background: var(--volt); color: #4a3406; }
.day__n { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ---------- Thẻ một lịch cắt điện ---------- */
.cut {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 8px;
}
.cut--live { border-color: #f1bfbe; box-shadow: inset 3px 0 0 var(--live); }
.cut--soon { box-shadow: inset 3px 0 0 var(--volt); }
.cut--done { opacity: .72; }

.cut__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cut__time { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.cut__dur { font-size: 13px; color: var(--muted); }
.state {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  margin-left: auto;
}
.state--live { background: var(--live-bg); color: var(--live); }
.state--soon { background: var(--volt-bg); color: #8a6108; }
.state--done { background: var(--done-bg); color: var(--done); }

/* Dải 24 giờ — điểm nhấn chính của giao diện */
.strip { margin: 10px 0 12px; }
.strip__track {
  position: relative;
  height: 12px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
}
.strip__fill {
  position: absolute;
  top: 0; bottom: 0;
  background: repeating-linear-gradient(
    135deg,
    var(--ink) 0 6px,
    var(--ink-soft) 6px 12px
  );
  border-radius: 3px;
}
.cut--live .strip__fill {
  background: repeating-linear-gradient(135deg, var(--live) 0 6px, #b92a2d 6px 12px);
}
.cut--soon .strip__fill {
  background: repeating-linear-gradient(135deg, var(--volt) 0 6px, #d8900a 6px 12px);
}
.strip__now {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--live);
}
.strip__scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #9aa9b8;
  margin-top: 3px;
}

.cut__area { font-size: 15px; line-height: 1.55; }
.cut__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
}
.cut__foot b { font-weight: 500; color: var(--ink-soft); }
.cut__reason { display: flex; align-items: center; gap: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--volt); flex: none; }

/* ---------- Trạng thái rỗng ---------- */
.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 34px 20px;
  text-align: center;
}
.empty__icon { width: 42px; height: 42px; margin: 0 auto 10px; color: var(--done); }
.empty h3 { margin: 0 0 4px; font-size: 17px; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Chọn phường/xã ---------- */
.wards { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.wards__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.wards__head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.ward-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ward-list a {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.ward-list a:hover { border-color: var(--ink); background: var(--ink); color: #fff; }
.ward-list a.is-hidden { display: none; }
.link-more {
  background: none; border: 0; padding: 0;
  color: var(--ink); font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: underline;
}

/* ---------- Cột phải ---------- */
.side { display: grid; gap: 14px; position: sticky; top: 72px; }
@media (max-width: 940px) { .side { position: static; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.panel ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.panel li a {
  display: block; padding: 7px 9px; margin: 0 -9px;
  border-radius: var(--r-sm); font-size: 14px;
}
.panel li a:hover { background: var(--line-soft); }
.panel p { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); line-height: 1.65; }
.panel p:last-child { margin-bottom: 0; }

.howto { counter-reset: step; display: grid; gap: 12px; }
.howto__item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.howto__n {
  counter-increment: step;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  border-radius: 50%; font-size: 12px; font-weight: 700;
}
.howto__n::before { content: counter(step); }
.howto h3 { margin: 2px 0 3px; font-size: 14.5px; font-weight: 600; }
.howto p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- Chân trang ---------- */
.footer { background: var(--ink); color: #9fb0c2; padding: 30px 0 22px; font-size: 13.5px; }
.footer a { color: #d7e1ea; }
.footer a:hover { text-decoration: underline; }
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; margin-bottom: 20px; }
@media (max-width: 720px) { .footer__grid { grid-template-columns: 1fr; } }
.footer h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #fff; }
.footer ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.footer__bar {
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding-top: 14px;
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between;
  font-size: 12.5px;
}

/* ---------- Nút lên đầu trang ---------- */
.totop {
  position: fixed; right: 16px; bottom: 16px;
  width: 42px; height: 42px;
  display: none; place-items: center;
  background: var(--ink); color: #fff;
  border: 0; border-radius: 50%;
  box-shadow: var(--shadow); cursor: pointer; z-index: 30;
}
.totop.is-on { display: grid; }

@media (prefers-reduced-motion: no-preference) {
  .cut--live .state--live { animation: pulse 2.4s ease-in-out infinite; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

@media print {
  .topbar, .filters, .side, .footer, .totop, .disclaimer { display: none; }
  .cut { break-inside: avoid; border-color: #ccc; }
  body { background: #fff; }
}

/* ============================================================
   v2 — theo dõi, mã khách hàng, thống kê, báo cáo, PWA
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border: 0; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--ink-soft); }
.btn--ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--line-soft); border-color: var(--ink); }
.btn[aria-pressed="true"] { background: var(--done); }
.btn svg { flex: none; }
.muted { color: var(--muted); font-size: 13.5px; }

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.action-bar [data-calendar] { display: contents; }

/* Thông báo nổi */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 120%);
  max-width: min(440px, calc(100vw - 32px));
  background: var(--ink); color: #fff; padding: 12px 16px;
  border-radius: var(--r); box-shadow: var(--shadow);
  font-size: 14px; z-index: 60; opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.toast--warn { background: #8a3b0c; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Hộp chọn kênh thông báo */
.dialog {
  position: fixed; inset: 0; display: none; place-items: center;
  background: rgba(21, 34, 50, .55); z-index: 70; padding: 16px;
}
.dialog.is-on { display: grid; }
.dialog__box {
  background: #fff; border-radius: var(--r-lg); padding: 22px;
  max-width: 440px; width: 100%; box-shadow: 0 30px 60px -30px rgba(0,0,0,.6);
}
.dialog__box h2 { margin: 0 0 6px; font-size: 18px; }
.dialog__box p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.dialog__row { display: grid; gap: 8px; }
.dialog__row .btn { justify-content: center; }

/* Khu vực đang theo dõi */
.follow-list { display: grid; gap: 8px; }
.follow-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
}
.follow-item b { font-size: 14.5px; }
.follow-item__state { font-size: 13px; color: var(--muted); }
.follow-item__state.is-warn { color: #8a6108; }
.follow-item__state.is-ok { color: var(--done); }

/* Tra theo mã khách hàng */
.code-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.code-box h2 { margin: 0 0 4px; font-size: 16px; }
.code-box > p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.code-form { display: flex; gap: 8px; flex-wrap: wrap; }
.code-form input {
  flex: 1; min-width: 180px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 15px;
  letter-spacing: .04em;
}
.code-hit { margin-top: 12px; padding: 10px 12px; background: var(--line-soft); border-radius: var(--r-sm); }
.code-hit b { display: block; font-size: 15px; }
.code-hit span { display: block; font-size: 13px; color: var(--muted); }
.code-ok { margin: 10px 0 0; color: var(--done); font-size: 14px; }
.code-list { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.code-list li {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px;
}
.code-list li span { display: block; color: var(--muted); font-size: 13px; }

/* Thống kê */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .stats-grid { grid-template-columns: 1fr; } }
.panel h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 128px; margin-bottom: 10px; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bars__bar { background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars__col:last-child .bars__bar { background: var(--volt); }
.bars__label { font-size: 10.5px; color: var(--muted); text-align: center; margin-top: 4px; }
.rank { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.rank li span { color: var(--muted); font-size: 13px; margin-left: 6px; }

/* Báo cáo mất điện đột xuất */
.live-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.live-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 11px; border-radius: var(--r-sm);
  background: var(--live-bg); border: 1px solid #f4c9c8; font-size: 14px;
}
.live-list li span { color: var(--live); font-size: 13px; font-weight: 600; }

/* Trạng thái offline */
body.is-offline .filters::after {
  content: "Đang xem bản lưu trong máy — dữ liệu có thể chưa mới nhất";
  display: block; margin-top: 8px; padding: 7px 11px;
  background: var(--volt-bg); border: 1px solid #f0e0bd; border-radius: var(--r-sm);
  font-size: 13px; color: #7a5a10;
}
