:root {
  --bg: #090e1a;
  --sidebar: #0d1424;
  --panel: #111a2e;
  --panel-alt: #16213a;
  --panel-hover: #1b2846;
  --border: #233252;
  --border-light: #2e4168;
  --text: #e6edf7;
  --text-dim: #93a4c3;
  --text-muted: #647594;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --emerald: #10b981;
  --emerald-hover: #059669;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 13.5px; line-height: 1.45;
}

/* LAYOUT */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main-area { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1440px; }

/* SIDEBAR */
.brand-box { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-title { font-size: 16.5px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--emerald); box-shadow: 0 0 8px rgba(16,185,129,0.6); }
.dot-amber { background: var(--amber); box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.dot-gray { background: var(--text-muted); }

.nav-section { padding: 14px 12px 6px; }
.nav-heading {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); padding: 0 8px 8px; display: flex; justify-content: space-between; align-items: center;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent;
  color: var(--text-dim); padding: 9px 11px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; text-align: left; transition: all 0.14s; margin-bottom: 3px;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,0.16); color: #93c5fd; border: 1px solid rgba(59,130,246,0.32); }
.nav-badge {
  margin-left: auto; background: var(--panel-alt); color: var(--text-dim);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
.nav-badge.hot { background: rgba(245,158,11,0.2); color: #fbbf24; }
.ch-code-tag {
  font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 5px;
  background: var(--panel-alt); color: #93c5fd; border: 1px solid var(--border);
}
.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); }

/* HEADER & BUTTONS */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.page-title { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.page-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; font-weight: 600;
  font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  color: #fff; text-decoration: none; transition: all 0.14s; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-primary { background: var(--blue); }
.btn-emerald { background: var(--emerald); }
.btn-amber { background: #d97706; }
.btn-danger { background: rgba(239,68,68,0.16); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.btn-ghost { background: var(--panel-alt); color: var(--text); border-color: var(--border-light); }

/* KPI GRID */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 17px; }
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-val { font-size: 27px; font-weight: 800; margin-top: 5px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* CARDS & TABS */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card-hero { background: linear-gradient(135deg, #111a2e 0%, #0d2722 100%); border-color: #1f4e42; }
.card-picker { background: linear-gradient(135deg, #111a2e 0%, #162240 100%); border-color: #2c4373; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.tabs-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; padding-bottom: 1px; }
.tab-btn {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--text-dim);
  padding: 10px 16px; font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all 0.14s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: #60a5fa; border-bottom-color: var(--blue); }

/* ALERTS */
.alert-list { display: grid; gap: 8px; margin-bottom: 18px; }
.alert-item {
  padding: 10px 14px; border-radius: 9px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.32); color: #fcd34d;
}
.alert-item.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #fca5a5; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 11px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 11px; border-bottom: 1px solid rgba(35,50,82,0.55); vertical-align: middle; }
tr:hover td { background: rgba(27,40,70,0.45); }
.num { text-align: right; white-space: nowrap; }
.vpd-txt { color: #fb923c; font-weight: 700; }

/* BADGES / PILLS */
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pill-chinh { background: rgba(239,68,68,0.18); color: #fca5a5; border: 1px solid rgba(239,68,68,0.35); }
.pill-phu { background: rgba(59,130,246,0.18); color: #93c5fd; border: 1px solid rgba(59,130,246,0.35); }
.pill-green { background: rgba(16,185,129,0.16); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.35); }
.pill-amber { background: rgba(245,158,11,0.16); color: #fcd34d; border: 1px solid rgba(245,158,11,0.35); }
.pill-sky { background: rgba(14,165,233,0.16); color: #7dd3fc; }
.pill-purple { background: rgba(168,85,247,0.16); color: #d8b4fe; }
.pill-gray { background: rgba(100,117,148,0.2); color: #cbd5e1; }

/* BATCH CARD */
.batch-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.batch-card.latest { background: linear-gradient(135deg, #111a2e 0%, #0e2621 100%); border-color: #1f5143; }
.batch-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.batch-meta { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.batch-stat { background: #0b1120; border: 1px solid var(--border-light); padding: 4px 10px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.batch-sugg { background: rgba(16,185,129,0.16); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7; padding: 4px 10px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.slot-list { display: grid; gap: 7px; }
.slot-row {
  display: flex; align-items: center; gap: 10px; background: rgba(9,14,26,0.68);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; flex-wrap: wrap;
}
.slot-info { flex: 1; min-width: 220px; }
.slot-title { font-weight: 600; color: var(--text); font-size: 13px; }
.slot-url { color: #60a5fa; text-decoration: none; font-size: 12px; }
.slot-url:hover { text-decoration: underline; }
.slot-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dur-badge { background: var(--panel-alt); border: 1px solid var(--border-light); padding: 3px 9px; border-radius: 6px; font-weight: 800; font-size: 12.5px; }

/* FORMS & INPUTS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #cbd5e1; }
.field .hint { font-size: 11px; color: var(--text-muted); }
input[type="text"], input[type="number"], input[type="password"], input[type="time"], select, textarea {
  background: #090e1a; border: 1px solid var(--border-light); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 13px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.chip-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.chip {
  background: var(--panel-alt); border: 1px solid var(--border-light); color: #93c5fd;
  border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.chip:hover, .chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.day-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn {
  width: 38px; height: 32px; border-radius: 7px; border: 1px solid var(--border-light);
  background: #090e1a; color: var(--text-dim); font-weight: 700; font-size: 12px; cursor: pointer;
}
.day-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

/* MODALS */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3,7,18,0.78); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 18px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border-light); border-radius: 16px;
  width: 100%; max-width: 820px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.65);
}
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.wizard-steps { display: flex; gap: 8px; margin-bottom: 18px; }
.wiz-step {
  flex: 1; padding: 9px 12px; border-radius: 9px; background: #090e1a; border: 1px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--text-muted); display: flex; align-items: center; gap: 8px;
}
.wiz-step.active { border-color: var(--blue); color: #93c5fd; background: rgba(59,130,246,0.12); }
.wiz-step.done { border-color: rgba(16,185,129,0.4); color: #6ee7b7; }

.probe-box {
  background: #090e1a; border: 1px solid var(--border-light); border-radius: 10px;
  padding: 12px 14px; margin-top: 10px; font-size: 12.5px;
}

/* TOAST & LOGS */
.toast-box { position: fixed; bottom: 22px; right: 22px; display: grid; gap: 8px; z-index: 2000; }
.toast {
  background: #1e293b; border: 1px solid var(--border-light); color: #fff;
  padding: 11px 16px; border-radius: 10px; font-weight: 600; font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.toast.ok { border-left: 4px solid var(--emerald); }
.toast.err { border-left: 4px solid var(--red); }

pre.log-view {
  background: #050811; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-size: 12px; color: #cbd5e1; max-height: 360px; overflow: auto; margin: 0;
}

@media (max-width: 880px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main-area { padding: 16px; }
}
