/* ============================================================================
   YouTube Manager � Fleet Control - theme indigo, s�ng/t?i, mobile-first.
   ============================================================================ */

:root {
  --app-bg: #f6f7f9;
  --panel: #ffffff;
  --head-bg: #f3f4f6;
  --text: #14161a;
  --text2: #565d6b;
  --line: #e7e9ec;
  --line-strong: #d9dce1;
  --blue: #5b5bd6;
  --blue-600: #4a4ac4;
  --blue-dim: #edecfc;
  --accent-ring: rgba(91, 91, 214, .30);
  --accent-border: rgba(91, 91, 214, .28);
  --red: #ef4444;
  --red-dim: #fdecec;
  --green: #16a34a;
  --green-dim: #e8f7ee;
  --amber: #d97706;
  --amber-dim: #fdf2e3;
  --sans: 'Fira Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Fira Code', ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, .06);
  --shadow-md: 0 6px 20px rgba(20, 22, 26, .10);
  --radius: 12px;
}

:root[data-theme="dark"] {
  --app-bg: #0d0e12;
  --panel: #16181d;
  --head-bg: #1c1f26;
  --text: #edeef1;
  --text2: #a3a9b5;
  --line: #262a33;
  --line-strong: #343945;
  --blue: #7d7df3;
  --blue-600: #6a6af0;
  --blue-dim: rgba(125, 125, 243, .16);
  --accent-ring: rgba(125, 125, 243, .38);
  --accent-border: rgba(125, 125, 243, .35);
  --red-dim: rgba(239, 68, 68, .14);
  --green-dim: rgba(22, 163, 74, .16);
  --amber-dim: rgba(217, 119, 6, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--app-bg); color: var(--text); font-family: var(--sans);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; }
.hidden { display: none !important; }
a { color: var(--blue); }

/* Focus r� r�ng cho b�n ph�m */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--blue);
}

/* ===== Logo YouTube (v�ng d? nh?p nh�y + tam gi�c play) ===== */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.2px; color: var(--text); min-width: 0; }
.brand-dim { color: var(--text2); font-weight: 500; }
.yt-logo { position: relative; width: 28px; height: 28px; flex: none; display: inline-grid; place-items: center; }
.yt-logo .yt-core { position: relative; z-index: 2; width: 100%; height: 100%; border-radius: 50%; background: #ff2a2a; }
.yt-logo .yt-core::before {
  content: ''; position: absolute; top: 50%; left: 54%; transform: translate(-50%, -50%);
  border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent #fff;
}
.yt-logo .yt-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #ff2a2a; opacity: 0; animation: yt-pulse 2.4s ease-out infinite; }
.yt-logo .yt-ring:nth-child(1) { animation-delay: 0s; }
.yt-logo .yt-ring:nth-child(2) { animation-delay: .8s; }
.yt-logo .yt-ring:nth-child(3) { animation-delay: 1.6s; }
@keyframes yt-pulse { 0% { transform: scale(.7); opacity: .6; } 100% { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .yt-logo .yt-ring { animation: none; } }

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 10px 16px; font-size: 13.5px; font-weight: 600; font-family: var(--sans);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--blue); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text2); }
.btn-ghost:hover { background: var(--head-bg); color: var(--text); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }
.btn-block { width: 100%; }
.btn-icon { min-width: 44px; padding: 10px; font-size: 16px; }

/* ===== Form elements ===== */
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text2); margin: 14px 0 6px; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px 12px;
  font-size: 13.5px; color: var(--text); font-family: var(--sans); background: var(--panel);
  transition: border-color .15s, box-shadow .15s; min-height: 44px;
}
textarea { min-height: 0; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
select { cursor: pointer; }
.radio-row { display: flex; flex-wrap: wrap; gap: 14px 20px; margin: 4px 0 10px; }
.radio { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text2); cursor: pointer; min-height: 32px; }
.radio input { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; }

/* ===== Alerts ===== */
.alert { border-radius: 9px; padding: 10px 14px; font-size: 13px; margin: 14px 0; border: 1px solid transparent; }
.alert-error { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.alert-success { background: var(--green-dim); color: var(--green); border-color: var(--green); }

/* ===== Toast ===== */
.toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); border-radius: 10px;
  padding: 12px 16px; font-size: 13px; box-shadow: var(--shadow-md); opacity: 1; transition: opacity .25s, transform .25s;
}
.toast-success { border-color: var(--green); }
.toast-error { border-color: var(--red); }
.toast-out { opacity: 0; transform: translateY(6px); }

/* ===== Login ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow-md); }
.auth-card h1 { font-size: 19px; margin: 18px 0 6px; }
.auth-sub { font-size: 12.5px; color: var(--text2); margin: 0 0 16px; line-height: 1.5; }

/* ===== Layout chung ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-email { font-size: 12.5px; color: var(--text2); }

.layout { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 18px; max-width: 1280px; margin: 0 auto; }
.layout-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

@media (min-width: 1024px) {
  .layout { grid-template-columns: 300px 1fr; align-items: start; }
  .panel-machines { position: sticky; top: 78px; }
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 700; }

/* ===== Chips ===== */
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip-muted { background: var(--head-bg); color: var(--text2); border: 1px solid var(--line-strong); }
.chip-view { background: var(--blue-dim); color: var(--blue); }
.chip-status { text-transform: none; }
.chip-status-active, .chip-status-running, .chip-status-pending { background: var(--head-bg); color: var(--text2); border: 1px solid var(--line-strong); }
.chip-status-running { background: rgba(91, 91, 214, .12); color: var(--blue); }
.chip-status-done { background: var(--green-dim); color: var(--green); }
.chip-status-error { background: var(--red-dim); color: var(--red); }
.chip-status-canceled { background: var(--red-dim); color: var(--red); }

/* ===== M�y (khu A) ===== */
.machines-list { display: flex; flex-direction: column; gap: 4px; max-height: 460px; overflow: auto; }
.machine-item { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 9px 8px; border-radius: 9px; font-size: 13px; }
.machine-item:hover { background: var(--head-bg); }
.machine-name {
  flex: 1; min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500;
  border: 0; background: transparent; padding: 0; text-align: left; font-family: var(--sans); font-size: 13px;
  color: var(--text); cursor: pointer; min-height: auto;
}
.machine-name:hover { color: var(--blue); text-decoration: underline; }
.machine-time { color: var(--text2); font-size: 11.5px; white-space: nowrap; }
.machine-actions { display: flex; gap: 4px; margin-left: auto; }
.machine-btn {
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text2); border-radius: 7px;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px; padding: 0; flex: none;
}
.machine-btn:hover { background: var(--head-bg); border-color: var(--blue); color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-online { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.dot-offline { background: var(--line-strong); }

.empty-hint { color: var(--text2); font-size: 12.5px; padding: 8px 2px; margin: 0; line-height: 1.5; }

/* ===== Form t?o l?nh (khu B) ===== */
.cfg-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 768px) { .cfg-grid { grid-template-columns: 1fr 1fr; } }
.cfg-group { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 16px; background: var(--head-bg); }
.cfg-group-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px; color: var(--text); padding: 12px 0 4px; border-bottom: 1px dashed var(--line-strong); margin-bottom: 4px; }
.step-badge { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; }
@media (min-width: 768px) { .cfg-span-2 { grid-column: 1 / -1; } }

.row-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .row-4 { grid-template-columns: repeat(4, 1fr); } }

.machine-picker { margin-top: 8px; }
.machine-picker-list { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 6px; background: var(--panel); }

/* Segmented control (T?t c? m�y / Ch?n m�y c? th?) */
.segmented { display: inline-flex; background: var(--head-bg); border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; gap: 3px; margin: 4px 0 10px; }
.seg-btn { border: 0; background: transparent; color: var(--text2); font-family: var(--sans); font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 7px; cursor: pointer; min-height: 38px; transition: background .15s, color .15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--panel); color: var(--blue); box-shadow: var(--shadow-sm); }

/* Thanh t�m t?t "s? ch?y" */
.run-summary { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 11px 14px; border-radius: 9px; background: var(--blue-dim); color: var(--blue); font-size: 13px; font-weight: 600; }
.run-summary .icon { flex: none; }
.run-summary b { font-weight: 800; }
.run-summary-empty { background: var(--head-bg); color: var(--text2); }

/* Accordion ch?n m�y + x? h? so (Bu?c 2) */
.mp-machine { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.mp-on { border-color: var(--accent-border); box-shadow: inset 3px 0 0 var(--blue); }
.mp-readonly { background: var(--head-bg); }
.mp-readonly .mp-row { padding: 8px 12px; gap: 10px; min-height: 46px; }
.mp-readonly .mp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mp-stat { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
.mp-badge { flex: none; }
.mp-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.mp-check { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-height: 44px; }
.mp-check input { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; flex: none; }
.mp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mp-toggle { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 10px; font-size: 11.5px; font-weight: 600; color: var(--text2); font-family: var(--sans); cursor: pointer; min-height: 34px; white-space: nowrap; }
.mp-toggle:hover { border-color: var(--blue); color: var(--text); }
.mp-sel-label { font-variant-numeric: tabular-nums; }
.mp-profiles { padding: 4px 8px 8px; border-top: 1px solid var(--line); background: var(--head-bg); }

/* Picker h? so (d�ng chung: du?i m?i m�y) - tick c? thu m?c l?n t?ng h? so */
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 6px; }
.picker-all { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.picker-count { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.picker-group { margin-bottom: 4px; }
.picker-folder { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 7px; background: var(--panel); }
.picker-folder:hover { background: var(--head-bg); }
.picker-folder-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: transparent; border: 0; padding: 6px 2px; cursor: pointer; font-family: var(--sans); text-align: left; color: var(--text); min-height: 38px; }
.picker-folder-toggle:hover { color: var(--blue); }
.picker-folder-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-folder-name .icon { color: var(--blue); vertical-align: -0.15em; }
.picker-profiles { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 7px 6px 7px 26px; border-radius: 7px; font-size: 13px; cursor: pointer; min-height: 40px; }
.picker-item:hover { background: var(--panel); }
.mp-profiles input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; flex: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-actions .schedule-times-input { width: auto; flex: 1 1 200px; min-width: 160px; }

/* ===== Chi?n d?ch d� luu (khu B2) ===== */
.campaigns-list { display: flex; flex-direction: column; gap: 8px; }
.campaign-item { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.campaign-info { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.campaign-name { font-weight: 600; font-size: 13.5px; }
.campaign-meta { width: 100%; font-size: 12px; color: var(--text2); }
.campaign-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== L?ch t? ch?y (khu B3) ===== */
.schedules-list { display: flex; flex-direction: column; gap: 8px; }
.schedule-item { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.schedule-info { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.schedule-name { font-weight: 600; font-size: 13.5px; }
.schedule-meta { width: 100%; font-size: 12px; color: var(--text2); }
.schedule-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== L?nh g?n d�y (khu C) ===== */
.commands-list { display: flex; flex-direction: column; gap: 8px; }
.command-item { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.command-summary {
  width: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; text-align: left;
  background: var(--panel); border: 0; padding: 12px 14px; cursor: pointer; font-family: var(--sans); min-height: 44px;
}
.command-summary:hover { background: var(--head-bg); }
.command-target { flex: 1; min-width: 120px; font-size: 12.5px; color: var(--text2); }
.command-time { font-size: 11.5px; color: var(--text2); white-space: nowrap; }
.command-caret { color: var(--text2); font-size: 11px; }
.command-body { padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--head-bg); display: flex; flex-direction: column; gap: 10px; }

.runs-list { display: flex; flex-direction: column; gap: 6px; }
.run-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.run-machine { font-weight: 600; min-width: 90px; }
.run-msg { flex: 1; min-width: 120px; color: var(--text2); overflow-wrap: anywhere; }
.run-time { color: var(--text2); font-size: 11px; white-space: nowrap; }

/* ===== Danh s�ch h? so (d�ng trong chi ti?t m�y) ===== */
.profiles-list { display: flex; flex-direction: column; gap: 6px; }
.profile-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 12.5px; }
.profile-name { font-weight: 600; min-width: 100px; }
.profile-meta { flex: 1; min-width: 140px; color: var(--text2); }

/* Gom h? so theo thu m?c - b?m ti�u d? d? x? ra / thu g?n (ch?u s? lu?ng l?n) */
.card-head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#profiles-toggle-all { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }
.folder-group { display: flex; flex-direction: column; gap: 6px; }
.folder-group + .folder-group { margin-top: 8px; }
.folder-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer;
  font-weight: 700; font-size: 12.5px; color: var(--text); font-family: var(--sans);
  background: var(--head-bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 42px;
}
.folder-head:hover { border-color: var(--blue); }
.folder-caret { color: var(--text2); font-size: 10px; width: 12px; flex: none; }
.folder-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-size: 11px; font-weight: 600; color: var(--text2); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; flex: none; }
.folder-items { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.folder-group .profile-item { margin-left: 14px; }
.folder-stat { font-size: 11px; font-weight: 600; color: var(--text2); white-space: nowrap; }
.mini-bar { width: 54px; height: 6px; border-radius: 999px; background: var(--line-strong); overflow: hidden; flex: none; }
.mini-bar > i { display: block; height: 100%; background: var(--green); }
@media (max-width: 460px) { .folder-stat { display: none; } }

/* ===== Dashboard / b�o c�o s? li?u ===== */
.stat-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stat-strip { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); } }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--head-bg); display: flex; flex-direction: column; gap: 4px; }
.stat-val { display: flex; align-items: baseline; gap: 8px; }
.stat-num { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.stat-pct { font-size: 12px; font-weight: 700; color: var(--blue); }
.stat-label { font-size: 11.5px; color: var(--text2); font-weight: 500; }

/* s? li?u du?i m?i m�y (khu A) */
.machine-stat { width: 100%; font-size: 11px; color: var(--text2); padding-left: 18px; font-variant-numeric: tabular-nums; }

/* ===== Icon SVG (b? Lucide) - canh theo ch?, d?ng b? n�t ===== */
.icon { width: 1.05em; height: 1.05em; flex: none; vertical-align: -0.15em; }
.icon-sm { width: .9em; height: .9em; }
.icon.rot180 { transform: rotate(180deg); transition: transform .18s ease; }
.icon-wrap { display: inline-flex; align-items: center; vertical-align: -0.15em; }
h2 .icon-wrap, h3 .icon-wrap { color: var(--blue); }
.detail-title-wrap { display: inline-flex; align-items: center; gap: 8px; }
.detail-title-wrap .icon-wrap { color: var(--blue); }
.folder-caret { display: inline-flex; align-items: center; }
.folder-caret .icon { width: 15px; height: 15px; }
.command-caret { display: inline-flex; align-items: center; }
.machine-btn .icon { width: 15px; height: 15px; }

/* ===== S? li?u: font mono + canh c?t (kh�ng nh?y khi d?i s?) ===== */
.stat-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat-pct, .folder-count, .folder-stat { font-variant-numeric: tabular-nums; }
.machine-time, .command-time, .run-time, #machines-count, #profiles-count { font-variant-numeric: tabular-nums; }

/* ===== Hover t� d�ng (data-dense: d? qu�t) + chuy?n d?ng mu?t 150-300ms ===== */
.profile-item, .campaign-item, .schedule-item, .run-item { transition: background .16s ease, border-color .16s ease; }
.profile-item:hover, .campaign-item:hover, .schedule-item:hover { background: var(--head-bg); border-color: var(--line-strong); }
.run-item:hover { border-color: var(--line-strong); }

/* ===== Chi ti?t m�y (d?i ch? trong khung n?i dung) ===== */
#machine-detail { display: flex; flex-direction: column; gap: 18px; }
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { font-size: 16px; font-weight: 700; flex: 1; min-width: 120px; }
#machine-detail .card h3 { font-size: 13.5px; font-weight: 700; margin: 0; }
.machine-item-active { background: var(--blue-dim); box-shadow: inset 3px 0 0 var(--blue); }
.machine-item-active .machine-name { color: var(--blue); }

/* � nh?p link Google Sheet */
.sheet-src-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-src-row input { flex: 1; min-width: 200px; }

/* 3 n�t h�nh d?ng */
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 150px; }

/* ===== Modal xem tru?c ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10, 12, 16, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: min(640px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--head-bg); }
.preview-summary { font-size: 13px; margin: 0 0 12px; line-height: 1.55; }
.preview-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.preview-table th, .preview-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.preview-table th { background: var(--head-bg); color: var(--text2); font-weight: 600; position: sticky; top: 0; }
.preview-table tr:last-child td { border-bottom: 0; }

/* ===== Mobile fine-tune (<480px) ===== */
@media (max-width: 480px) {
  .topbar { padding: 12px 14px; }
  .layout { padding: 12px; gap: 14px; }
  .card { padding: 14px; }
  .auth-card { padding: 22px 18px; }
  .row-4, .row-2 { grid-template-columns: 1fr; }
}
