/* Giao diện chung App Yagi Songs — sáng, thoáng, màu nhấn tím mận Yagi dùng tiết chế */
:root {
  --bg: #f5f4f2; --surface: #ffffff; --surface-2: #faf9f7; --line: #e8e5e0; --line-2: #f0ede9;
  --ink: #1c1a17; --ink-2: #4a4640; --muted: #8a847b;
  --brand: #741b47; --brand-ink: #5c1538; --brand-soft: #f6eaf0;
  --ok: #1f7a4d; --ok-soft: #e7f4ec; --warn: #9a6200; --warn-soft: #fdf3e1; --bad: #b42318; --bad-soft: #fdecea;
  --info: #2457a6; --info-soft: #eaf1fb;
  --r: 12px; --r-sm: 8px; --shadow: 0 1px 2px rgba(28,26,23,.04), 0 2px 8px rgba(28,26,23,.04);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- khung ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 10px 10px 20px; margin-bottom: 8px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 118px; height: auto; display: block; opacity: .92; }
.brand .tagline { width: 100%; text-align: center; font-size: 8.6px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--ink-2);
  padding: 4px 0; border-top: 1px solid #cfc9c1; border-bottom: 1px solid #cfc9c1; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side .foot { margin-top: auto; padding: 10px 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line-2); }
.side .foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }
.main { min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.wrap-narrow { max-width: 880px; }

/* ---------- thẻ ---------- */
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.card-b { padding: 14px 18px; }
.card-b.flush { padding: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------- số nhanh ---------- */
.kpi { padding: 16px 18px; }
.kpi .lab { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 650; letter-spacing: -.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; min-height: 18px; }
.kpi.bad .val { color: var(--bad); } .kpi.ok .val { color: var(--ok); }

/* ---------- bảng ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: none; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t td.n, .t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.t td.c, .t th.c { text-align: center; }
.scroll-x { overflow-x: auto; }

/* ---------- nhãn ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.mute { background: var(--line-2); color: var(--muted); }
.code-X { background: var(--bad-soft); color: var(--bad); } .code-S, .code-C { background: var(--warn-soft); color: var(--warn); }

/* ---------- dòng thời gian ---------- */
.tl { list-style: none; margin: 0; padding: 4px 0; }
.tl li { display: grid; grid-template-columns: 54px 18px 1fr auto; align-items: start; gap: 10px; padding: 8px 18px; }
.tl li:hover { background: var(--surface-2); }
.tl .time { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; padding-top: 1px; }
.tl .mark { width: 10px; height: 10px; border-radius: 50%; margin: 6px auto 0; border: 2px solid var(--line); background: var(--surface); }
.tl li.ok .mark { background: var(--ok); border-color: var(--ok); }
.tl li.loi .mark { background: var(--bad); border-color: var(--bad); }
.tl li.qua .mark { background: var(--line); border-color: var(--line); }
.tl li.next .mark { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.tl li.sap .name, .tl li.next .name { color: var(--ink); }
.tl li.qua .name { color: var(--muted); }
.tl .err { color: var(--bad); font-size: 12px; }

/* ---------- nút + form ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { border-color: #cfc9c1; background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); padding: 6px 8px; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.run-group + .run-group { margin-top: 14px; }
.run-group h3 { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 8px; }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=date] { width: auto; }
textarea { min-height: 72px; resize: vertical; }
label.f { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12.5px; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.seg input { width: auto; margin-top: 3px; accent-color: var(--brand); }
.seg b { display: block; } .seg span { color: var(--muted); font-size: 12.5px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink); }
.check input { width: auto; accent-color: var(--brand); }

/* ---------- thông báo ---------- */
.msg { padding: 10px 14px; border-radius: 10px; font-size: 13.5px; margin-top: 12px; border: 1px solid transparent; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border-color: #cfe9d9; }
.msg.err { background: var(--bad-soft); color: var(--bad); border-color: #f7cfca; }
.msg.warn { background: var(--warn-soft); color: var(--warn); border-color: #f2ddb3; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.empty.left { text-align: left; padding: 4px 0; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.tabs button { font: inherit; font-size: 12.5px; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
details.log summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.log summary::-webkit-details-marker { display: none; }
pre.logbox { margin: 0; background: #17150f; color: #d8d3c8; padding: 14px 16px; font: 12px/1.55 Consolas, "Cascadia Mono", monospace; max-height: 320px; overflow: auto; white-space: pre-wrap; border-radius: 0 0 var(--r) var(--r); }
.ads-mkt + .ads-mkt { border-top: 1px solid var(--line); }
.ads-mkt .head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: baseline; padding: 14px 18px 10px; }
.ads-mkt .head b { font-size: 15px; }
.ads-mkt .head span { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.frame { width: 100%; height: calc(100vh - 120px); border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); }

/* ---------- lịch nghỉ cả tuần ---------- */
table.lw th.c { line-height: 1.25; padding-left: 6px; padding-right: 6px; }
table.lw td:first-child { white-space: nowrap; }
table.lw .wd { display: block; font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: none; margin-bottom: 1px; }
table.lw th.cn .wd { color: var(--bad); }
table.lw .today { background: var(--brand-soft); }
table.lw th.today .wd, table.lw th.today { color: var(--brand-ink); font-weight: 700; }

/* ---------- kinh doanh ---------- */
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kd-tiles { gap: 0; border-bottom: 1px solid var(--line-2); }
.kd-tiles .kpi + .kpi { border-left: 1px solid var(--line-2); }
.kd-tiles .val { font-size: 24px; }
table.kd td { vertical-align: top; }
.nxl { list-style: none; margin: 0; padding: 0; min-width: 260px; }
.nxl li { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; line-height: 1.45; padding: 1px 0; }
.nx { flex: none; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; margin-top: 2px; }
.nx.ok { background: var(--ok-soft); color: var(--ok); } .nx.warn { background: var(--warn-soft); color: var(--warn); } .nx.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- màn nhỏ ---------- */
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; }
  .g-5, .g-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kd-tiles .kpi + .kpi { border-left: 0; } }
.side .foot.staff a { font-weight: 600; }
@media (max-width: 820px) {
  .side .foot.staff { display: block; margin: 0 0 0 auto; border: 0; padding: 0 6px; white-space: nowrap; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 12px 0 4px; margin: 0; border: 0; } .brand img { width: 84px; } .brand .tagline, .side .foot { display: none; }
  .nav { display: flex; gap: 4px; } .nav a { white-space: nowrap; }
  .main { padding: 18px 14px 40px; }
  .form-grid, .seg, .g-2 { grid-template-columns: 1fr; }
}
