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

:root {
  --bg: #f4f6fa;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);

  --primary: #4f46e5;
  --primary-soft: rgba(79, 70, 229, 0.09);
  --danger: #e11d48;
  --success: #059669;

  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;

  /* Màu nền tảng */
  --pf-tiktok: #111827;
  --pf-shopee: #ee4d2d;
  --pf-zalo: #0068ff;
  --pf-facebook: #4267b2;
  --pf-other: #7c3aed;

  --font-h: 'Outfit', sans-serif;
  --font-b: 'Plus Jakarta Sans', sans-serif;
  --radius: 14px;
}

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

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.04) 0, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-b);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.16); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.28); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.8rem; }
.ta-right { text-align: right; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem; }
.mt { margin-top: 12px; }

.glass-panel {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(31, 38, 135, 0.05);
}

/* ============ MÀN HÌNH ĐĂNG NHẬP ============ */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  background-image:
    radial-gradient(at 20% 10%, rgba(99, 102, 241, 0.12) 0, transparent 55%),
    radial-gradient(at 80% 90%, rgba(168, 85, 247, 0.1) 0, transparent 55%);
  display: grid; place-items: center; padding: 20px;
}
.auth-card { width: 100%; max-width: 400px; padding: 28px; background: var(--card-solid); }
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.auth-brand h1 { font-family: var(--font-h); font-size: 1.1rem; font-weight: 800; }
.auth-title { font-family: var(--font-h); font-size: 1.3rem; font-weight: 800; }
.auth-desc { font-size: 0.8rem; color: var(--muted); margin: 4px 0 16px; line-height: 1.5; }
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }

/* ============ NGƯỜI DÙNG & ĐỒNG BỘ ============ */
.user-chip {
  display: flex; align-items: center; gap: 7px;
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 20px; padding: 3px 6px 3px 4px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff;
  font-family: var(--font-h); font-weight: 800; font-size: 0.66rem;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta > span:first-child { font-size: 0.78rem; font-weight: 600; }
.user-role { font-size: 0.63rem; color: var(--muted); }

.sync-badge { font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.sync-badge:empty { display: none; }
.sync-badge.dot { background: rgba(217, 119, 6, 0.12); color: var(--text-warning); }
.sync-badge.ok { background: rgba(5, 150, 105, 0.12); color: var(--success); }
.sync-badge.err { background: rgba(225, 29, 72, 0.12); color: var(--danger); }

.row-off { opacity: 0.5; }

/* ============ HEADER ============ */
header {
  position: sticky; top: 0; z-index: 90;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 22px 0;
  display: flex; flex-direction: column; gap: 10px;
}
.header-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.logo-container { display: flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.logo-container h1 { font-family: var(--font-h); font-size: 1.18rem; font-weight: 800; letter-spacing: -0.02em; }
.logo-badge {
  font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(79, 70, 229, 0.2);
}
.header-actions { display: flex; gap: 6px; align-items: center; }

.backup-notice { font-size: 0.74rem; border-radius: 8px; padding: 6px 11px; line-height: 1.4; }
.backup-notice.ok { background: rgba(15, 23, 42, 0.04); color: var(--muted); }
.backup-notice.warn { background: rgba(251, 191, 36, 0.14); border: 1px solid rgba(217, 119, 6, 0.3); color: var(--text-warning); }
.backup-notice.warn strong { color: #92400e; }

.nav-tabs { display: flex; gap: 2px; overflow-x: auto; }
.nav-tab {
  font-family: var(--font-h); font-size: 0.86rem; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 9px 14px; cursor: pointer; white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.filter-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.switch-label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-2); cursor: pointer; }
.switch-label input { accent-color: var(--primary); width: 15px; height: 15px; }

/* ============ LAYOUT ============ */
.main-content { padding: 20px 22px 60px; max-width: 1800px; margin: 0 auto; }
.tab-pane { display: none; animation: fade 0.2s ease; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel { padding: 18px; margin-bottom: 20px; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.section-title { font-family: var(--font-h); font-size: 1rem; font-weight: 700; }
.sub-title { font-family: var(--font-h); font-size: 0.88rem; font-weight: 700; margin: 16px 0 8px; }
.section-desc { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ============ NÚT & INPUT ============ */
.btn {
  font-family: var(--font-b); font-size: 0.82rem; font-weight: 600;
  padding: 8px 14px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-xs { padding: 4px 8px; font-size: 0.72rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-outline { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(15, 23, 42, 0.05); color: var(--text); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { background: rgba(225, 29, 72, 0.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #be123c; }

.text-input {
  width: 100%; font-family: var(--font-b); font-size: 0.85rem;
  padding: 8px 11px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.text-input { resize: vertical; }
.input-sm { width: auto; min-width: 150px; padding: 6px 10px; font-size: 0.8rem; }
.input-group { margin-bottom: 12px; }
.input-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.input-label.sm { font-size: 0.7rem; }
.req { color: var(--danger); }
.hint { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline .text-input { flex: 1; }
.row-actions { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }

/* ============ ĐIỀU HƯỚNG THỜI GIAN ============ */
.period-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.period-title { display: flex; flex-direction: column; min-width: 190px; text-align: center; }
.period-title > span:first-child { font-family: var(--font-h); font-size: 1.05rem; font-weight: 700; }
.period-sub { font-size: 0.76rem; color: var(--muted); }
.period-spacer { flex: 1; }
.period-stats { font-size: 0.82rem; color: var(--text-2); background: var(--primary-soft); padding: 6px 12px; border-radius: 20px; }
.period-stats strong { color: var(--primary); }

/* ============ LỊCH TUẦN ============ */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--card-solid); }
.week-table { width: 100%; border-collapse: collapse; min-width: 1080px; }
.week-table th, .week-table td { border: 1px solid var(--border); vertical-align: top; }
.week-table thead th {
  position: sticky; top: 0; z-index: 3; background: #f8fafc;
  padding: 8px 6px; text-align: center; font-family: var(--font-h); font-size: 0.78rem;
}
.week-table thead th .dow { display: block; font-weight: 700; }
.week-table thead th .dnum { display: block; font-size: 0.7rem; color: var(--muted); font-weight: 500; }
.week-table thead th.is-today { background: var(--primary-soft); color: var(--primary); }
.week-table thead th.day-head { cursor: pointer; transition: background 0.15s; }
.week-table thead th.day-head:hover { background: var(--primary-soft); }
.week-table thead th.day-head:hover .dow { text-decoration: underline; text-underline-offset: 2px; }
.week-table td { padding: 5px; width: 12.4%; }
.week-table td.is-today { background: rgba(79, 70, 229, 0.035); }

.col-channel { width: 240px; min-width: 240px; text-align: left !important; padding: 8px 10px !important; background: #fcfcfd; position: sticky; left: 0; z-index: 2; }
.ch-shop { font-size: 0.74rem; color: var(--text-2); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.ch-name { font-family: var(--font-h); font-weight: 600; font-size: 0.86rem; margin-top: 2px; word-break: break-all; }

.brand-row td {
  background: linear-gradient(90deg, var(--bc-soft), rgba(255, 255, 255, 0) 62%);
  border-left: 4px solid var(--bc) !important;
  padding: 9px 12px !important; position: sticky; left: 0;
}
.brand-row-name { font-family: var(--font-h); font-weight: 800; font-size: 0.95rem; color: var(--bc); vertical-align: middle; }
.brand-row-meta { font-size: 0.75rem; color: var(--muted); margin-left: 10px; }

/* Huy hiệu tròn chữ cái đầu, tô màu nhận diện của brand */
.brand-badge {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 24px; height: 24px; border-radius: 7px; margin-right: 8px;
  background: var(--bc); color: #fff;
  font-family: var(--font-h); font-weight: 800; font-size: 0.68rem; letter-spacing: -0.01em;
  box-shadow: 0 2px 6px var(--bc-soft, rgba(0, 0, 0, 0.12));
}
.brand-badge.lg { width: 34px; height: 34px; border-radius: 10px; font-size: 0.9rem; margin-right: 11px; }
.brand-badge.sm { width: 18px; height: 18px; border-radius: 5px; font-size: 0.58rem; margin-right: 6px; }
.channel-row:hover .col-channel { background: #f8fafc; }

.chip {
  position: relative;
  border-left: 3px solid var(--pf-other); background: rgba(124, 58, 237, 0.06);
  border-radius: 6px; padding: 4px 18px 4px 6px; margin-bottom: 4px; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12); }
.chip-time { display: block; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.76rem; font-weight: 700; }
.chip-time sup { font-size: 0.6rem; color: var(--muted); }
.chip-tech { display: block; font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.is-extra { border-style: dashed; }
.chip-flag { font-size: 0.6rem; font-weight: 700; background: #fde68a; color: #92400e; padding: 1px 5px; border-radius: 8px; }

.cell-add {
  width: 100%; border: 1px dashed transparent; background: none; color: transparent;
  border-radius: 6px; padding: 6px 0; cursor: pointer; font-size: 0.9rem; font-weight: 700;
}
td:hover .cell-add { border-color: var(--border-strong); color: var(--muted); }
.cell-add:hover { border-color: var(--primary) !important; color: var(--primary) !important; background: var(--primary-soft); }

.empty-cell { text-align: center; padding: 32px; color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 0.75rem; color: var(--text-2); }
.legend-item { display: flex; align-items: center; gap: 5px; }

/* Màu theo nền tảng */
.pf-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.pf-dot.pf-tiktok { background: var(--pf-tiktok); }
.pf-dot.pf-shopee { background: var(--pf-shopee); }
.pf-dot.pf-zalo { background: var(--pf-zalo); }
.pf-dot.pf-facebook { background: var(--pf-facebook); }
.pf-dot.pf-other { background: var(--pf-other); }

.pf-tag { font-size: 0.64rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; border: 1px solid; }
.pf-tag.pf-tiktok { color: var(--pf-tiktok); border-color: rgba(17, 24, 39, 0.25); background: rgba(17, 24, 39, 0.05); }
.pf-tag.pf-shopee { color: var(--pf-shopee); border-color: rgba(238, 77, 45, 0.3); background: rgba(238, 77, 45, 0.07); }
.pf-tag.pf-zalo { color: var(--pf-zalo); border-color: rgba(0, 104, 255, 0.3); background: rgba(0, 104, 255, 0.07); }
.pf-tag.pf-facebook { color: var(--pf-facebook); border-color: rgba(66, 103, 178, 0.3); background: rgba(66, 103, 178, 0.07); }
.pf-tag.pf-other { color: var(--pf-other); border-color: rgba(124, 58, 237, 0.3); background: rgba(124, 58, 237, 0.07); }

.chip.pf-tiktok, .m-chip.pf-tiktok, .day-item.pf-tiktok { border-left-color: var(--pf-tiktok); background: rgba(17, 24, 39, 0.05); }
.chip.pf-shopee, .m-chip.pf-shopee, .day-item.pf-shopee { border-left-color: var(--pf-shopee); background: rgba(238, 77, 45, 0.07); }
.chip.pf-zalo, .m-chip.pf-zalo, .day-item.pf-zalo { border-left-color: var(--pf-zalo); background: rgba(0, 104, 255, 0.07); }
.chip.pf-facebook, .m-chip.pf-facebook, .day-item.pf-facebook { border-left-color: var(--pf-facebook); background: rgba(66, 103, 178, 0.07); }

/* ============ ĐỒNG HỒ GMT+7 ============ */
.now-clock {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: #0f172a; color: #fff; border-radius: 8px; padding: 5px 10px;
}
.now-clock-time {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
}
.now-clock-tz { font-size: 0.6rem; font-weight: 700; opacity: 0.6; letter-spacing: 0.04em; }

/* ============ BÁO CÁO SLA ============ */
.report-toolbar {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px;
}
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.range-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-row .input-label { margin-bottom: 0; }

.report-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }
.kpi {
  background: var(--card-solid); border: 1px solid var(--border); border-radius: 11px;
  padding: 13px 15px; display: flex; flex-direction: column; gap: 1px;
}
.kpi.big { border-width: 2px; border-color: var(--border-strong); }
.kpi.big.c-ok { border-color: rgba(5, 150, 105, 0.45); background: rgba(5, 150, 105, 0.05); }
.kpi.big.c-warn { border-color: rgba(180, 83, 9, 0.4); background: rgba(217, 119, 6, 0.05); }
.kpi.big.c-no { border-color: rgba(225, 29, 72, 0.4); background: rgba(225, 29, 72, 0.05); }
.kpi-n { font-family: var(--font-h); font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.kpi.big .kpi-n { font-size: 2.2rem; }
.kpi-l { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }
.kpi-s { font-size: 0.7rem; color: var(--muted); }
.c-warn { color: var(--text-warning) !important; }

.report-note { font-size: 0.8rem; color: var(--text-2); margin-top: 12px; }

.rp-chart {
  display: flex; align-items: flex-end; gap: 3px; height: 190px;
  padding: 10px 4px 0; overflow-x: auto;
}
.rp-col { flex: 1; min-width: 16px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.rp-stack {
  flex: 1; width: 100%; max-width: 30px; display: flex; flex-direction: column;
  justify-content: flex-end; border-radius: 4px; overflow: hidden;
}
.rp-stack .seg { width: 100%; min-height: 2px; }
.seg-aired { background: var(--success); }
.seg-missed { background: var(--danger); }
.seg-pending { background: #cbd5e1; }
.seg-cancelled { background: #94a3b8; }
.rp-total { font-size: 0.62rem; color: var(--muted); font-weight: 700; height: 12px; }
.rp-label { font-size: 0.6rem; color: var(--muted); height: 13px; white-space: nowrap; margin-top: 3px; }
.lg-box { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.rate-pill {
  display: inline-block; font-weight: 800; font-size: 0.8rem;
  padding: 2px 9px; border-radius: 20px; background: rgba(15, 23, 42, 0.05);
}
.rate-pill.c-ok { background: rgba(5, 150, 105, 0.12); }
.rate-pill.c-warn { background: rgba(217, 119, 6, 0.13); }
.rate-pill.c-no { background: rgba(225, 29, 72, 0.12); }

/* ============ LỊCH NGÀY / KIỂM TRA LÊN SÓNG ============ */
.checker-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 14px;
}
.checker-bar .input-label { margin-bottom: 0; white-space: nowrap; }
.c-ok { color: var(--success) !important; }
.c-no { color: var(--danger) !important; }

.air-list { display: flex; flex-direction: column; gap: 8px; }
.air-row {
  display: grid; grid-template-columns: 62px 1fr 290px; gap: 14px; align-items: center;
  background: var(--card-solid); border: 1px solid var(--border);
  border-left: 4px solid var(--bc); border-radius: 10px; padding: 10px 13px;
}
.air-row.is-aired { background: rgba(5, 150, 105, 0.045); border-color: rgba(5, 150, 105, 0.28); }
.air-row.is-missed { background: rgba(225, 29, 72, 0.04); border-color: rgba(225, 29, 72, 0.25); }
.air-row.cancelled { opacity: 0.55; }
.air-row.cancelled .air-brand, .air-row.cancelled .air-sub { text-decoration: line-through; }

.air-time {
  font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 0.88rem; text-align: center;
}
.air-time span { display: block; font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.air-main { min-width: 0; }
.air-brand { font-family: var(--font-h); font-weight: 800; font-size: 0.9rem; color: var(--bc); display: flex; align-items: center; gap: 5px; }
.air-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.air-check { display: flex; flex-direction: column; gap: 6px; }
.air-link-row { display: flex; gap: 4px; align-items: center; }
.air-link-row .text-input { flex: 1; min-width: 0; }
.air-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.btn-air {
  font-family: var(--font-b); font-size: 0.75rem; font-weight: 700; padding: 6px 8px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: #fff;
  color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.btn-air.ok:hover { border-color: var(--success); color: var(--success); }
.btn-air.no:hover { border-color: var(--danger); color: var(--danger); }
.btn-air.ok.on { background: var(--success); border-color: var(--success); color: #fff; }
.btn-air.no.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.air-meta { font-size: 0.68rem; color: var(--muted); }
.air-meta.pending { color: var(--text-warning); font-weight: 600; }
.air-off { font-size: 0.75rem; color: var(--muted); font-style: italic; text-align: center; }

/* Dấu tick lên sóng ở góc phải dưới của phiên trong lịch tuần / tháng */
.air-tick {
  position: absolute; right: 3px; bottom: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.6rem; font-weight: 800; color: #fff; line-height: 1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}
.air-tick.ok { background: var(--success); }
.air-tick.no { background: var(--danger); }
.air-tick.inline {
  position: static; width: 14px; height: 14px; flex-shrink: 0;
  margin-left: auto; font-size: 0.56rem;
}

/* ============ LỊCH THÁNG ============ */
.month-grid-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.month-grid-head div { text-align: center; font-family: var(--font-h); font-size: 0.76rem; font-weight: 700; color: var(--text-2); padding: 4px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.m-cell {
  min-height: 108px; background: var(--card-solid); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px; cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.m-cell:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(79, 70, 229, 0.13); }
.m-cell.outside { background: rgba(255, 255, 255, 0.4); opacity: 0.55; }
.m-cell.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.m-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.m-date { font-family: var(--font-h); font-weight: 700; font-size: 0.82rem; }
.m-cell.is-today .m-date { background: var(--primary); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-size: 0.72rem; }
.m-count { font-size: 0.64rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 10px; }
.m-chip {
  border-left: 3px solid var(--pf-other); background: rgba(124, 58, 237, 0.06);
  border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; font-size: 0.68rem;
  display: flex; gap: 5px; align-items: baseline; overflow: hidden;
}
.m-time { font-family: ui-monospace, Menlo, monospace; font-weight: 700; flex-shrink: 0; color: var(--text-2); }
.m-brand {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--bc); font-weight: 700;
}
.m-more { font-size: 0.66rem; color: var(--muted); padding-left: 5px; }

/* ============ BRAND & KÊNH ============ */
.brand-tree { display: flex; flex-direction: column; gap: 14px; }
.brand-block { padding: 14px; border-left: 5px solid var(--bc); }
.brand-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; flex-wrap: wrap;
}
.brand-head-left { display: flex; align-items: center; }
.brand-title { font-family: var(--font-h); font-size: 1.05rem; font-weight: 800; color: var(--bc); }
.brand-meta { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

.shop-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: rgba(248, 250, 252, 0.6); }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.shop-title { display: flex; align-items: center; gap: 7px; font-family: var(--font-h); font-weight: 700; font-size: 0.9rem; flex-wrap: wrap; }

.ch-block { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.ch-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ch-title { font-weight: 600; font-size: 0.86rem; }
.sc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.sc-chip {
  font-family: var(--font-b); font-size: 0.72rem; background: var(--primary-soft);
  border: 1px solid rgba(79, 70, 229, 0.18); color: var(--text); border-radius: 7px;
  padding: 3px 8px; cursor: pointer; display: flex; gap: 5px; align-items: center;
}
.sc-chip:hover { border-color: var(--primary); }
.sc-tech { color: var(--muted); font-size: 0.66rem; }
.empty-inline { font-size: 0.78rem; color: var(--muted); padding: 8px 4px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ============ BẢNG DỮ LIỆU ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.data-table th {
  text-align: left; font-family: var(--font-h); font-size: 0.75rem; font-weight: 700;
  color: var(--text-2); padding: 9px 12px; background: #f8fafc; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #fafbfc; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-flat {
  font-family: var(--font-b); font-size: 0.74rem; text-align: left;
  background: #fff; border: 1px solid var(--border-strong); border-left-width: 3px;
  border-radius: 8px; padding: 5px 9px; cursor: pointer; display: flex; flex-direction: column;
}
.chip-flat:hover { border-color: var(--primary); }
.chip-flat.pf-tiktok { border-left-color: var(--pf-tiktok); }
.chip-flat.pf-shopee { border-left-color: var(--pf-shopee); }
.chip-flat.pf-zalo { border-left-color: var(--pf-zalo); }
.chip-flat.pf-facebook { border-left-color: var(--pf-facebook); }

/* ============ NHẬP TỪ SHEET ============ */
.import-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 14px; }
.import-source { display: flex; flex-direction: column; }
.msg { font-size: 0.8rem; margin-top: 10px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--danger); }

.map-controls { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.map-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.map-field { display: flex; flex-direction: column; }
.map-field .input-sm { width: 100%; min-width: 0; }
.map-days { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.map-days-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

.preview-scroll { max-height: 280px; overflow: auto; }
.preview-table { font-size: 0.75rem; white-space: nowrap; }
.preview-table td { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.import-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sum-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; display: flex; flex-direction: column; min-width: 110px;
}
.sum-n { font-family: var(--font-h); font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.sum-card span:last-child { font-size: 0.72rem; color: var(--muted); }

.issues { background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.3); border-radius: 9px; padding: 10px 14px; font-size: 0.79rem; margin-bottom: 14px; }
.issues.ok { background: rgba(5, 150, 105, 0.06); border-color: rgba(5, 150, 105, 0.25); color: var(--success); }
.issues ul { margin: 6px 0 0 18px; }
.radio-line { display: flex; align-items: flex-start; gap: 7px; font-size: 0.82rem; padding: 5px 0; cursor: pointer; }
.radio-line input { accent-color: var(--primary); margin-top: 3px; }

/* ============ MODAL ============ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-container { background: var(--card-solid); width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-wide { max-width: 620px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-solid); }
.modal-title { font-family: var(--font-h); font-size: 0.98rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-form { padding: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn:first-child { flex: 1; justify-content: center; }

/* Bộ chọn màu nhận diện brand */
.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid transparent;
  cursor: pointer; padding: 0; transition: transform 0.12s, border-color 0.12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }
.swatch.auto {
  color: #fff; opacity: 0.45;
  font-family: var(--font-h); font-weight: 800; font-size: 0.72rem;
}
.swatch.auto.on { opacity: 1; }

/* Chọn kiểu lịch: lặp hằng tuần / chỉ một ngày */
.kind-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-opt {
  display: flex; align-items: flex-start; gap: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 11px;
  transition: border-color 0.15s, background 0.15s;
}
.kind-opt:hover { border-color: var(--primary); }
.kind-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.kind-opt input { accent-color: var(--primary); margin-top: 3px; flex-shrink: 0; }
.kind-opt strong { display: block; font-size: 0.8rem; font-family: var(--font-h); }
.kind-opt em { display: block; font-size: 0.7rem; color: var(--muted); font-style: normal; line-height: 1.35; margin-top: 1px; }
.kind-opt:has(input:checked) strong { color: var(--primary); }

.day-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.day-opt { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: 7px; cursor: pointer; }
.day-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.day-opt input { accent-color: var(--primary); }

.day-summary { font-size: 0.84rem; color: var(--text-2); margin-bottom: 10px; }
.day-summary strong { color: var(--primary); }
.day-list { display: flex; flex-direction: column; gap: 7px; }
.day-item { display: flex; gap: 11px; align-items: center; border-left: 3px solid var(--pf-other); background: rgba(124, 58, 237, 0.05); border-radius: 8px; padding: 9px 11px; }
.day-item.cancelled { opacity: 0.5; text-decoration: line-through; }
.day-item-time { font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 0.82rem; text-align: center; flex-shrink: 0; }
.day-item-time span { display: block; font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.day-item-main { flex: 1; min-width: 0; }
.day-item-brand { font-family: var(--font-h); font-weight: 800; font-size: 0.88rem; color: var(--bc); display: flex; align-items: center; }
.day-item-sub { font-size: 0.73rem; color: var(--muted); }
.day-item-actions { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .main-content { padding: 14px 12px 50px; }
  header { padding: 10px 12px 0; }
  .import-sources, .map-controls, .form-row { grid-template-columns: 1fr; }
  .col-channel { width: 170px; min-width: 170px; position: static; }
  .brand-row td { position: static; }
  .brand-row-meta { display: block; margin-left: 0; }
  .m-cell { min-height: 82px; }
  .m-chip .m-brand { display: none; }
  .day-picker { grid-template-columns: repeat(2, 1fr); }
  .period-title { min-width: 140px; }
  .air-row { grid-template-columns: 52px 1fr; }
  .air-check { grid-column: 1 / -1; }
}

@media print {
  header, .btn, .cell-add, .period-nav .btn, .filter-bar { display: none !important; }
  body { background: #fff; }
  .glass-panel { box-shadow: none; border: 1px solid #ddd; }
  .tab-pane { display: none !important; }
  .tab-pane.active { display: block !important; }
}
