/* style.css — Giao diện Nhật ký truyền thanh điện tử. Màu chủ đạo xanh #1E3A8A, nhấn đỏ #C8102E. Chữ cơ sở 16px. */
:root {
  --primary: #1E3A8A; --primary-2: #1e40af; --accent: #C8102E; --accent-2: #a50d25;
  --bg: #f4f6fb; --surface: #ffffff; --text: #111827; --muted: #4b5563; --border: #d1d5db;
  --row-hover: #eef2ff; --mark: #fde68a; --err-bg: #fee2e2; --err-tx: #991b1b; --warn-bg: #fef3c7; --warn-tx: #92400e;
  --ok: #047857; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(30,58,138,.06); --radius: 12px;
}
[data-theme="dark"] {
  --primary: #93b4ff; --primary-2: #bcd0ff; --accent: #ff6b81; --accent-2: #ff8fa0;
  --bg: #0b1220; --surface: #121a2b; --text: #e5e7eb; --muted: #a8b3c7; --border: #2b3a55;
  --row-hover: #1b2740; --mark: #854d0e; --err-bg: #3f1518; --err-tx: #fecaca; --warn-bg: #3d2e0a; --warn-tx: #fde68a; --ok: #34d399;
  --shadow: 0 1px 3px rgba(0,0,0,.5);
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.55; color: var(--text); background: var(--bg); min-width: 320px; }
body.noscroll { overflow: hidden; }
a { color: var(--primary); }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 3px; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; color: #000; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
.muted { color: var(--muted); }
.err { color: var(--err-tx); }
[hidden] { display: none !important; }

/* Header */
.site-header { background: linear-gradient(135deg, #1E3A8A, #172f73); color: #fff; border-bottom: 4px solid #C8102E; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand .logo { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 3px; flex: none; object-fit: contain; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand small { font-size: .78rem; opacity: .9; text-transform: uppercase; letter-spacing: .03em; }
.brand strong { font-size: 1.15rem; line-height: 1.25; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.main-nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 0; scrollbar-width: none; }
.main-nav a { color: #e0e7ff; text-decoration: none; padding: 10px 14px; border-radius: 8px 8px 0 0; font-weight: 600; white-space: nowrap; }
.main-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.main-nav a.active { background: var(--bg); color: var(--primary); }
[data-theme="dark"] .main-nav a.active { color: #fff; }
.btn-icon { background: transparent; border: 1px solid rgba(255,255,255,.4); color: inherit; border-radius: 8px; min-width: 40px; min-height: 40px; font-size: 1.1rem; cursor: pointer; }
.modal .btn-icon { border-color: var(--border); color: var(--text); }
.updated-bar { padding-top: 10px; color: var(--muted); font-size: .95rem; }
.offline-bar { background: #92400e; color: #fff; text-align: center; padding: 8px; font-weight: 600; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
[data-theme="dark"] .btn-primary { background: #2f55c8; }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-accent, .btn-danger { background: #C8102E; color: #fff; }
.btn-accent:hover, .btn-danger:hover { background: #a50d25; }
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--row-hover); }
.btn-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; min-height: 42px; width: 100%; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95rem; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.inline input { width: auto; min-height: auto; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
legend { font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-btns input { width: auto; flex: 1 1 180px; }

/* Layout */
.layout { display: grid; grid-template-columns: 290px 1fr; gap: 20px; padding-top: 12px; padding-bottom: 32px; align-items: start; }
.filters { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.filters-head { display: flex; justify-content: space-between; align-items: center; }
.filters h2 { margin: 0 0 12px; font-size: 1.15rem; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { font: inherit; font-size: .9rem; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.quick button:hover { border-color: var(--primary); color: var(--primary); }
.content { min-width: 0; }
.searchbar { display: flex; gap: 8px; }
.search { flex: 1; }
.search input { min-height: 50px; font-size: 1.05rem; padding-left: 14px; border: 2px solid var(--border); }
.search input:focus { border-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 1px solid var(--primary); background: var(--row-hover); color: var(--primary); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: .88rem; cursor: pointer; }
.badge { background: #C8102E; color: #fff; border-radius: 999px; padding: 0 7px; font-size: .8rem; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin: 8px 0 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface); padding: 4px; border-radius: 10px; box-shadow: var(--shadow); }
.tabs button { border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.tabs button[aria-selected="true"] { background: var(--primary); color: #fff; }
[data-theme="dark"] .tabs button[aria-selected="true"] { background: #2f55c8; }
.export { display: flex; flex-wrap: wrap; gap: 6px; }
.only-mobile { display: none !important; }

/* Bảng / thẻ */
.result-count { color: var(--muted); margin: 4px 0 10px; }
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { background: var(--row-hover); color: var(--primary); font-size: .92rem; position: sticky; top: 0; z-index: 1; }
[data-theme="dark"] table.data th { color: #dbe4ff; }
table.data tbody tr[data-id] { cursor: pointer; }
table.data tbody tr:hover { background: var(--row-hover); }
td.nd { min-width: 280px; }
.sort { background: none; border: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; padding: 0; text-align: left; }
.tag { display: inline-block; background: var(--row-hover); color: var(--primary); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: .85rem; font-weight: 600; }
.tag-red { background: var(--err-bg); color: var(--err-tx); border-color: transparent; }
.tag-yellow { background: var(--warn-bg); color: var(--warn-tx); border-color: transparent; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 14px 0; }
.pager label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.pager select { width: auto; }
tr.total td { font-weight: 700; background: var(--row-hover); }

/* Lịch */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 1.3rem; }
.cal-head input { width: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-cell { min-height: 86px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; align-items: flex-start; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.cal-cell.empty-cell { background: transparent; border: 0; cursor: default; }
.cal-cell .d { font-weight: 700; }
.cal-cell.has { border-color: var(--primary); }
.cal-cell.has .n { background: var(--primary); color: #fff; border-radius: 6px; padding: 0 6px; font-size: .85rem; margin-top: 4px; }
[data-theme="dark"] .cal-cell.has .n { background: #2f55c8; }
.cal-cell .l { font-size: .8rem; color: var(--muted); }
.cal-cell.today { box-shadow: inset 0 0 0 2px #C8102E; }
.cal-cell:hover { background: var(--row-hover); }

/* Dòng thời gian */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; border-left: 3px solid var(--primary); }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 12px; position: relative; padding: 10px 12px; margin: 0 0 10px 12px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: #C8102E; border: 2px solid var(--bg); }
.tl-time { font-weight: 700; color: var(--primary); display: flex; flex-direction: column; }
.tl-time small { color: var(--muted); font-weight: 500; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; color: var(--muted); font-size: .9rem; }

/* Thống kê */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 4px solid var(--primary); display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-weight: 600; }
.stat strong { font-size: 1.7rem; color: var(--primary); line-height: 1.2; }
.stat-red { border-top-color: #C8102E; }
.stat-red strong { color: var(--accent); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box { margin: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.chart-box.wide { grid-column: 1 / -1; }
.chart-box figcaption { font-weight: 700; margin-bottom: 8px; }
.cv { position: relative; height: 320px; }

/* Báo cáo */
.report-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.report-form label { min-width: 150px; }
.rep-title { margin: 8px 0; color: var(--primary); }

/* Trống / khung chờ */
.empty { text-align: center; padding: 40px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-icon { font-size: 2.6rem; }
.empty h3 { margin: 6px 0; }
.skeleton { height: 54px; border-radius: 10px; margin-bottom: 8px; background: linear-gradient(90deg, var(--surface) 25%, var(--row-hover) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Toast & modal */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #1f2937; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); border-left: 5px solid #60a5fa; transition: opacity .4s, transform .4s; }
.toast-ok { border-left-color: #10b981; }
.toast-err { border-left-color: #ef4444; }
.toast.out { opacity: 0; transform: translateY(10px); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 12px; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.2rem; color: var(--primary); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
dl.detail { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; margin: 0; }
dl.detail dt { font-weight: 700; color: var(--muted); }
dl.detail dd { margin: 0; white-space: pre-wrap; }

/* Footer */
.site-footer { background: var(--surface); border-top: 3px solid var(--primary); padding: 18px 0; color: var(--muted); font-size: .95rem; text-align: center; }

/* Quản trị */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 14px 0; }
.card h2 { margin-top: 0; color: var(--primary); font-size: 1.25rem; }
.login-card { max-width: 420px; margin: 40px auto; }
.login-card form { display: grid; gap: 12px; }
.admin-tabs { margin-top: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grid-form .span2 { grid-column: 1 / -1; }
.dropzone { margin-top: 12px; border: 3px dashed var(--border); border-radius: var(--radius); padding: 36px 16px; text-align: center; cursor: pointer; background: var(--bg); }
.dropzone.over, .dropzone:hover { border-color: var(--primary); background: var(--row-hover); }
.steps li { margin-bottom: 4px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.preview-summary { margin: 10px 0; }
.preview-wrap { max-height: 70vh; }
table.preview td[contenteditable] { outline: 1px dashed transparent; }
table.preview td[contenteditable]:focus { outline: 2px solid var(--primary); background: var(--surface); }
tr.row-err td { background: var(--err-bg); color: var(--err-tx); }
tr.row-dup td { background: var(--warn-bg); color: var(--warn-tx); }
.dm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 12px; }
.logo-preview { display: flex; align-items: center; gap: 12px; }
.logo-preview img { border-radius: 50%; background: #fff; padding: 3px; border: 1px solid var(--border); }
td.actions { white-space: nowrap; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; }

/* Máy tính bảng */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 250px 1fr; }
  .grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Điện thoại / máy tính bảng dọc: bộ lọc thành ngăn trượt, bảng thành thẻ */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex !important; }
  .filters { position: fixed; top: 0; left: 0; bottom: 0; width: min(340px, 88vw); max-height: none; border-radius: 0; z-index: 100; transform: translateX(-105%); transition: transform .25s; }
  .filters.open { transform: none; }
  .charts { grid-template-columns: 1fr; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border-bottom: 6px solid var(--bg); padding: 8px 4px; }
  table.cards td { border: 0; padding: 4px 10px; display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
  table.cards td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: .88rem; }
  table.cards td.nd { min-width: 0; }
  .table-wrap { background: transparent; box-shadow: none; }
  table.cards tr { background: var(--surface); border-radius: 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 10px; }
  .brand strong { font-size: 1rem; }
  .cal-cell { min-height: 62px; padding: 4px; font-size: .85rem; }
  .cal-cell .l { display: none; }
  .cal-cell.has .n { font-size: .75rem; padding: 0 4px; }
  .timeline li { grid-template-columns: 1fr; }
  dl.detail { grid-template-columns: 1fr; gap: 2px; }
  dl.detail dd { margin-bottom: 8px; }
  .grid-form { grid-template-columns: 1fr; }
  .cv { height: 260px; }
  .toolbar .export .btn { padding: 6px 10px; }
  .tabs button { padding: 8px 10px; }
}

/* In khổ A4 */
.print-area { display: none; }
@page { size: A4; margin: 15mm 12mm; }
@media print {
  body.printing > *:not(.print-area) { display: none !important; }
  body.printing .print-area { display: block; color: #000; font-family: "Times New Roman", serif; font-size: 13pt; }
  body:not(.printing) .site-header, body:not(.printing) .filters, body:not(.printing) .toolbar, body:not(.printing) .searchbar, body:not(.printing) .site-footer, body:not(.printing) .pager { display: none !important; }
  .p-head { width: 100%; text-align: center; border-collapse: collapse; }
  .p-head td { width: 50%; vertical-align: top; }
  .b { font-weight: bold; } .u { text-decoration: underline; } .i { font-style: italic; margin-top: 6px; } .c { text-align: center; }
  .p-title { text-align: center; font-size: 16pt; margin: 18px 0 2px; }
  .p-sub { text-align: center; font-style: italic; margin: 0 0 12px; }
  .p-table { width: 100%; border-collapse: collapse; }
  .p-table th, .p-table td { border: 1px solid #000; padding: 4px 6px; vertical-align: top; }
  .p-table thead { display: table-header-group; }
  .p-table tr { page-break-inside: avoid; }
  .p-sign { width: 100%; margin-top: 24px; text-align: center; page-break-inside: avoid; }
  .p-sign td { width: 50%; }
  .p-sign .space { height: 70px; }
  .p-foot { font-size: 10pt; font-style: italic; text-align: right; }
}
