/* admincp · OpenCode Console — giao diện */
:root {
  /* ---- Bảng màu theme (mặc định: Đêm xanh) ---- */
  --bg: #0d1017;
  --bg-2: #0a0d13;
  --panel: #141a27;
  --panel-2: #1a2233;
  --line: #243049;
  --text: #e8ecf5;
  --muted: #8b96ad;
  --accent: #4f8cff;
  --accent-2: #79a9ff;
  --green: #3ecf8e;
  --red: #f2555a;
  --amber: #f5b544;
  --mono: Consolas, "Cascadia Mono", "JetBrains Mono", "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;

  /* ---- Màu phái sinh (được theme ghi đè khi cần) ---- */
  --topbar-1: #121828;
  --topbar-2: #0f1420;
  --field-bg: #0f1522;
  --card-bg: #101625;
  --hover-line: #33436b;
  --hover-bg: #212c44;
  --active-bg: #131c31;
  --term-text: #cfe0ff;
  --result-text: #a9ffd5;
  --job-ws: #6f7a90;

  /* Trạng thái (nền/viền/chữ) */
  --danger-bg: #43191d;
  --danger-line: #7a2a2f;
  --danger-text: #ffb3b6;
  --danger-bg-hover: #592126;
  --alert-error-bg: #2a1115;
  --alert-error-line: #6b2529;
  --alert-error-text: #ffb3b6;
  --alert-ok-bg: #0f2a1e;
  --alert-ok-line: #1e5c40;
  --alert-ok-text: #8ff0c0;
  --alert-info-bg: #12203a;
  --alert-info-line: #2b4a80;
  --alert-info-text: #a9c8ff;
  --green-line: #1e5c40;
  --amber-line: #6b5220;
  --accent-line: #2b4a80;

  /* Nút primary + gradient */
  --primary-1: #3f7ef0;
  --primary-2: #2f66d0;
  --primary-1h: #4f8cff;
  --primary-2h: #3a73e0;

  /* Thanh cuộn */
  --sb-track: #0f1522;
  --sb-thumb: #2c3a57;
  --sb-thumb-hover: #3b4d72;
  --sb-thumb-active: var(--accent);
}

/* ================= THEME: 4 bảng màu thay thế ================= */

/* 2. Sáng (Light) */
html[data-theme="light"] {
  --bg: #eef1f6;
  --bg-2: #e6eaf2;
  --panel: #ffffff;
  --panel-2: #f1f4fa;
  --line: #d3dae6;
  --text: #1b2331;
  --muted: #66708a;
  --accent: #2f6fe0;
  --accent-2: #2358b8;
  --topbar-1: #ffffff;
  --topbar-2: #f4f7fc;
  --field-bg: #ffffff;
  --card-bg: #f7f9fd;
  --hover-line: #b9c4d8;
  --hover-bg: #e9eef8;
  --active-bg: #e4ecfb;
  --term-text: #22304a;
  --result-text: #10693f;
  --job-ws: #8a93a8;
  --danger-bg: #fdeceb;
  --danger-line: #e5a3a0;
  --danger-text: #a32620;
  --danger-bg-hover: #fbdcd9;
  --alert-error-bg: #fdeceb;
  --alert-error-line: #e5a3a0;
  --alert-error-text: #a32620;
  --alert-ok-bg: #e7f7ee;
  --alert-ok-line: #9ad3b4;
  --alert-ok-text: #10693f;
  --alert-info-bg: #e8f0fe;
  --alert-info-line: #a9c2ef;
  --alert-info-text: #1d4ea8;
  --green-line: #9ad3b4;
  --amber-line: #dcc07a;
  --accent-line: #a9c2ef;
  --primary-1: #3b7cf0;
  --primary-2: #2a5fc8;
  --primary-1h: #4d8bf5;
  --primary-2h: #3569d6;
  --sb-track: #e6eaf2;
  --sb-thumb: #b6c0d4;
  --sb-thumb-hover: #98a4bd;
}

/* 3. Xanh đại dương (Ocean) */
html[data-theme="ocean"] {
  --bg: #071b24;
  --bg-2: #05161d;
  --panel: #0d2a36;
  --panel-2: #123646;
  --line: #1c4a5c;
  --text: #dff4fb;
  --muted: #7fa9b8;
  --accent: #14b8c4;
  --accent-2: #4fd8e0;
  --green: #2fd39a;
  --red: #ff6b6b;
  --amber: #f5c451;
  --topbar-1: #0c2b38;
  --topbar-2: #08202a;
  --field-bg: #0a2430;
  --card-bg: #0a2430;
  --hover-line: #2a6274;
  --hover-bg: #164050;
  --active-bg: #0f3846;
  --term-text: #c9f3f7;
  --result-text: #8ef5cd;
  --job-ws: #6e9aa9;
  --danger-bg: #3a1418;
  --danger-line: #6f2a2f;
  --danger-text: #ffb3b6;
  --danger-bg-hover: #4d1b20;
  --alert-error-bg: #2a1114;
  --alert-error-line: #6b2529;
  --alert-error-text: #ffb3b6;
  --alert-ok-bg: #0d2c26;
  --alert-ok-line: #1e5c4c;
  --alert-ok-text: #8ff0cf;
  --alert-info-bg: #0b2a36;
  --alert-info-line: #1f5a6b;
  --alert-info-text: #a5e6f0;
  --green-line: #1e5c4c;
  --amber-line: #6b5a20;
  --accent-line: #1f5a6b;
  --sb-track: #0a2430;
  --sb-thumb: #225a6c;
  --sb-thumb-hover: #2f7287;
}

/* 4. Tím hoàng hôn (Purple) */
html[data-theme="purple"] {
  --bg: #120f1f;
  --bg-2: #0d0a18;
  --panel: #1c1730;
  --panel-2: #251e3e;
  --line: #352c52;
  --text: #ece7f8;
  --muted: #9a90b8;
  --accent: #a06bff;
  --accent-2: #c39bff;
  --green: #3ecf8e;
  --red: #ff6b8a;
  --amber: #f5b544;
  --topbar-1: #1d1733;
  --topbar-2: #151026;
  --field-bg: #151027;
  --card-bg: #171230;
  --hover-line: #4a3d70;
  --hover-bg: #2a2148;
  --active-bg: #221b3c;
  --term-text: #dcd2ff;
  --result-text: #b8ffd9;
  --job-ws: #8a7fae;
  --danger-bg: #3c1420;
  --danger-line: #6f2739;
  --danger-text: #ffaebd;
  --danger-bg-hover: #4e1b2b;
  --alert-error-bg: #2b1018;
  --alert-error-line: #6b2535;
  --alert-error-text: #ffaebd;
  --alert-ok-bg: #10291f;
  --alert-ok-line: #1e5c40;
  --alert-ok-text: #8ff0c0;
  --alert-info-bg: #1d1636;
  --alert-info-line: #43316f;
  --alert-info-text: #cbb4ff;
  --green-line: #1e5c40;
  --amber-line: #6b5220;
  --accent-line: #43316f;
  --sb-track: #131024;
  --sb-thumb: #443a6b;
  --sb-thumb-hover: #574a86;
}

/* 5. Rừng (Forest) */
html[data-theme="forest"] {
  --bg: #0c1510;
  --bg-2: #08110c;
  --panel: #14231a;
  --panel-2: #1b2f23;
  --line: #274333;
  --text: #e4f0e8;
  --muted: #8aa694;
  --accent: #35c07a;
  --accent-2: #6fe0a6;
  --green: #4ade80;
  --red: #f2726f;
  --amber: #e8b64c;
  --topbar-1: #15271c;
  --topbar-2: #101d15;
  --field-bg: #0f1d15;
  --card-bg: #102018;
  --hover-line: #345741;
  --hover-bg: #1f3829;
  --active-bg: #193024;
  --term-text: #cfeedd;
  --result-text: #9df7c4;
  --job-ws: #7d9a88;
  --danger-bg: #331614;
  --danger-line: #642e2b;
  --danger-text: #ffb3b1;
  --danger-bg-hover: #45201d;
  --alert-error-bg: #261110;
  --alert-error-line: #5c2b28;
  --alert-error-text: #ffb3b1;
  --alert-ok-bg: #0d2a1c;
  --alert-ok-line: #1e5c3c;
  --alert-ok-text: #9df0c0;
  --alert-info-bg: #10251c;
  --alert-info-line: #2b5c47;
  --alert-info-text: #a6e8cf;
  --green-line: #1e5c3c;
  --amber-line: #6b5a20;
  --accent-line: #2b5c47;
  --sb-track: #0f1d15;
  --sb-thumb: #2c4f3a;
  --sb-thumb-hover: #3a6549;
}

/* ---------------- Thanh cuộn (đồng bộ theme) ---------------- */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-thumb) var(--sb-track);
}
/* Chromium/WebKit (Chrome, Edge, Safari) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 8px;
  border: 2px solid var(--sb-track);       /* tạo khoảng hở quanh thumb */
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--sb-thumb-hover);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
  background: var(--sb-thumb-active);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: var(--sb-track); }
/* Thanh cuộn ngang gọn hơn */
::-webkit-scrollbar:horizontal { height: 9px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body.page {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(180deg, var(--topbar-1), var(--topbar-2));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--green));
  box-shadow: 0 0 12px rgba(79, 140, 255, .8);
}
.brand-sub { font-weight: 500; font-size: 12.5px; color: var(--muted); margin-left: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- Chọn theme (topbar) ---------------- */
.theme-wrap { position: relative; display: inline-flex; }
.theme-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 210px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; gap: 2px;
}
.theme-menu[hidden] { display: none; }
.theme-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: transparent; color: var(--text);
  font: 600 13px var(--sans); text-align: left;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
}
.theme-item:hover { background: var(--hover-bg); }
.theme-item.active { background: var(--active-bg); color: var(--accent-2); }
.theme-item.active::after { content: '✓'; margin-left: auto; color: var(--accent); }
.theme-swatch {
  width: 16px; height: 16px; border-radius: 5px; flex: none;
  border: 1px solid var(--line);
}
.theme-swatch[data-swatch="dark"] { background: linear-gradient(135deg, #0d1017 50%, #4f8cff 50%); }
.theme-swatch[data-swatch="light"] { background: linear-gradient(135deg, #eef1f6 50%, #2f6fe0 50%); }
.theme-swatch[data-swatch="ocean"] { background: linear-gradient(135deg, #071b24 50%, #14b8c4 50%); }
.theme-swatch[data-swatch="purple"] { background: linear-gradient(135deg, #120f1f 50%, #a06bff 50%); }
.theme-swatch[data-swatch="forest"] { background: linear-gradient(135deg, #0c1510 50%, #35c07a 50%); }

/* ---------------- Buttons / badge ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font: 600 13.5px var(--sans);
  cursor: pointer; transition: .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--hover-line); background: var(--hover-bg); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--primary-1), var(--primary-2)); border-color: var(--primary-1); }
.btn.primary:hover { background: linear-gradient(180deg, var(--primary-1h), var(--primary-2h)); }
.btn.danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-text); }
.btn.danger:hover { background: var(--danger-bg-hover); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; }
.badge {
  font-size: 11.5px; padding: 4px 9px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel);
}
.badge.ok { color: var(--green); border-color: var(--green-line); }
.badge.warn { color: var(--amber); border-color: var(--amber-line); }

/* ---------------- Layout ---------------- */
.wrap { max-width: 1600px; margin: 0 auto; padding: 16px; }
.console-layout {
  display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 14px;
  align-items: stretch; min-height: calc(100vh - 76px);
}
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }
.main-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; }
.main-col > .main-console { flex: 1 1 auto; min-height: 320px; }
.main-col > .log-panel { flex: 0 0 auto; max-height: 300px;}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; max-height: 600px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02);
}
.panel-head h2 { margin: 0; font-size: 13.5px; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); }
.panel-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: auto; scrollbar-width: thin;}
.panel-foot {
  display: flex; gap: 9px; padding: 12px 14px;
  border-top: 1px solid var(--line); background: rgba(255, 255, 255, .02);
}
.panel-foot .btn { flex: 1; }
.side .panel.grow { flex: 1; min-height: 160px; max-height:300px;scrollbar-width: thin;}

/* ---------------- Form ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field > span em { font-style: normal; font-weight: 400; opacity: .8; }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.field-row .btn { height: 36px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--field-bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: 13.5px var(--sans); outline: none;
}
textarea { font-family: var(--mono); resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,140,255,.18); }
select:disabled { opacity: .5; }
.check input:disabled { cursor: not-allowed; }
.check.is-disabled { opacity: .5; cursor: not-allowed; }
.radio, .check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); cursor: pointer; }
.radio input, .check input { accent-color: var(--accent); }
.checks { display: flex; flex-direction: column; gap: 7px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.field > span code, .hint code { font-size: 11.5px; }

/* ---------------- Tabs / chips ---------------- */
.tabs { display: flex; gap: 6px; background: var(--field-bg); border: 1px solid var(--line); border-radius: 9px; padding: 4px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: 600 13px var(--sans); padding: 7px 10px; border-radius: 7px;
}
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  font: 12px var(--mono); padding: 4px 9px; border-radius: 20px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

/* ---------------- Jobs ---------------- */
.jobs { gap: 7px; padding: 10px; scrollbar-width: thin;}
.job {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: var(--card-bg);
}
.job:hover { border-color: var(--hover-line); }
.job.active { border-color: var(--accent); background: var(--active-bg); }
.job-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.job-dot.running { background: var(--accent); animation: pulse 1.2s infinite; }
.job-dot.done { background: var(--green); }
.job-dot.error { background: var(--red); }
.job-dot.stopped { background: var(--amber); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.job-main { flex: 1; min-width: 0; }
.job-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-sub { font-size: 11px; color: var(--muted); white-space: normal; }
.job-dur { color: var(--accent-2); white-space: nowrap; }
.job-ws { font-size: 10px; color: var(--job-ws); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.job-del {
  flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 3px 6px; border-radius: 6px;
}
.job-del:hover { color: var(--danger-text); background: var(--danger-bg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; max-width: 610px;}
.center { text-align: center; }
.right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------------- Console ---------------- */
.console-panel { }
.console-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.console-title { display: flex; align-items: center; gap: 9px; font-weight: 600; min-width: 0; }
.console-title > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.running { background: var(--accent); animation: pulse 1.2s infinite; }
.status-dot.done { background: var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.stopped { background: var(--amber); }
.console-actions { display: flex; align-items: center; gap: 7px; }
.console-actions .mono { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terminal {
  flex: 1; margin: 0; overflow: auto; padding: 14px 16px;
  background: var(--bg-2); color: var(--term-text);
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap; word-break: break-word;
  min-height: 300px;
  scrollbar-width: thin;
  /* Terminal nền tối hơn -> track trùng nền để không lộ vệt */
  scrollbar-color: var(--sb-thumb) var(--bg-2);
}
.terminal::-webkit-scrollbar-track { background: var(--bg-2); }
.terminal::-webkit-scrollbar-thumb { border-color: var(--bg-2); }
/* Khối kết quả cuối cùng của prompt -> highlight để dễ nhận biết */
.result-final {
  white-space: pre-wrap; word-break: break-word;
  margin: 8px 0 10px; padding: 10px 12px;
  background: rgba(62, 207, 142, .10);
  border-left: 3px solid var(--green);
  border-radius: 6px;
  color: var(--result-text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, .18);
}
.console-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; border-top: 1px solid var(--line);
  font-size: 12px; background: rgba(255,255,255,.02);
}

/* ---------------- Log Promt ---------------- */
.log-list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin;}
.log-item { border: 1px solid var(--line); border-radius: 9px; background: var(--card-bg); padding: 8px 10px; }
.log-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-item-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.log-item-text {
  margin: 5px 0 0; font: 12.5px/1.5 var(--mono); color: var(--term-text);
  white-space: pre-wrap; word-break: break-word; max-height: 110px; overflow: auto; scrollbar-width:thin;
}
.tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px; padding: 2px 7px;
  border-radius: 20px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase;
}
.tag.prompt { color: var(--accent-2); border-color: var(--accent-line); }
.tag.command { color: var(--amber); border-color: var(--amber-line); }

/* ---------------- Alerts / auth / settings ---------------- */
.alert { padding: 10px 13px; border-radius: 9px; font-size: 13.5px; border: 1px solid; }
.alert.error { background: var(--alert-error-bg); border-color: var(--alert-error-line); color: var(--alert-error-text); }
.alert.ok { background: var(--alert-ok-bg); border-color: var(--alert-ok-line); color: var(--alert-ok-text); }
.alert.info { background: var(--alert-info-bg); border-color: var(--alert-info-line); color: var(--alert-info-text); }

.auth-page { display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.auth-wrap { width: 100%; max-width: 520px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.auth-head { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.auth-head h1 { margin: 0; font-size: 22px; }
.auth-head p { margin: 2px 0 0; font-size: 13px; }
.auth-card form { display: flex; flex-direction: column; gap: 13px; margin-top: 8px; }
.auth-card .btn.block { margin-top: 6px; }
details.adv { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
details.adv summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
details.adv .field { margin-top: 12px; }

.settings-page { max-width: 1200px; margin: 0 auto; }
.settings-head { margin-bottom: 14px; }
.settings-head h1 { margin: 0 0 4px; font-size: 21px; }
.settings-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.settings-grid form { display: flex; flex-direction: column; gap: 12px; }
.settings-page .alert { margin-bottom: 14px; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast-item {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  color: var(--text); padding: 10px 13px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: slide .18s ease-out;
}
.toast-item.error { border-left-color: var(--red); }
.toast-item.ok { border-left-color: var(--green); }
@keyframes slide { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------------- Modal xem chi tiết ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4, 7, 12, .72);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(1100px, 96vw); height: min(88vh, 920px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-head-actions { display: flex; align-items: center; gap: 7px; }
.modal-body {
  flex: 1; margin: 0; overflow: auto; padding: 14px 16px;
  background: var(--bg-2); color: var(--term-text);
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap; word-break: break-word; scrollbar-width: thin;
  /* Nền tối như terminal -> track trùng nền */
  scrollbar-color: var(--sb-thumb) var(--bg-2);
}
.modal-body::-webkit-scrollbar-track { background: var(--bg-2); }
.modal-body::-webkit-scrollbar-thumb { border-color: var(--bg-2); }
.modal-foot { padding: 7px 14px; border-top: 1px solid var(--line); font-size: 12px; background: rgba(255, 255, 255, .02); }

/* ---------------- Modal "Tệp sửa đổi" ---------------- */
.console-foot #btnChangedFiles { margin-left: 6px; }
.icon-btn { font-size: 14px; line-height: 1; padding: 3px 8px; }
.files-scope {
  padding: 6px 14px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; background: rgba(255, 255, 255, .02);
  word-break: break-all;
}
.modal.files-modal { width: min(820px, 96vw); height: min(78vh, 800px); }
.files-body { display: block; overflow: auto; padding: 12px 14px; }
.file-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card-bg); margin-bottom: 7px;
}
.file-row:last-child { margin-bottom: 0; }
.file-name { font: 12.5px var(--mono); color: var(--term-text); word-break: break-all; flex: 1; min-width: 0; }
.file-path { font-size: 11px; color: var(--muted); word-break: break-all; }
.file-stats { display: flex; gap: 8px; align-items: center; flex: none; font: 11.5px var(--mono); }
.file-add { color: var(--green); }
.file-del { color: var(--red); }
.tag.file-created { color: var(--green); border-color: var(--green-line); }
.tag.file-modified { color: var(--amber); border-color: var(--amber-line); }

/* ---------------- Modal "Backup / Khôi phục" ---------------- */
.backup-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card-bg); margin-bottom: 7px;
}
.backup-row:last-child { margin-bottom: 0; }
.backup-main { flex: 1; min-width: 0; }
.backup-name { font: 12.5px var(--mono); color: var(--term-text); word-break: break-all; }
.backup-meta { font-size: 11px; color: var(--muted); word-break: break-all; }
.backup-ws { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; font-size: 11px; }
.backup-ws-label { color: var(--muted); flex: none; }
.backup-ws code { font-size: 11px; padding: 1px 5px; word-break: break-all; }
.tag.backup-ws-other { color: var(--amber); border-color: var(--amber-line); }
.backup-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.confirm-modal { width: min(560px, 96vw); height: auto; max-height: 90vh; }
.confirm-body { padding: 14px; overflow: auto; font-size: 13.5px; line-height: 1.6; }
.confirm-body code { word-break: break-all; }
.confirm-foot { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.warn-check { align-items: flex-start; line-height: 1.5; }
.warn-check input { margin-top: 3px; }
.confirm-actions { display: flex; gap: 9px; justify-content: flex-end; }
.confirm-warn {
  padding: 9px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px;
  background: var(--alert-error-bg); border: 1px solid var(--alert-error-line); color: var(--alert-error-text);
}

/* ---------------- Modal "Xem thư mục" ---------------- */
.label-with-btn { display: flex; align-items: center; gap: 7px; }
.icon-mini {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 6px; padding: 1px 6px; font-size: 11px; line-height: 1.5; cursor: pointer;
  font-weight: 400;
}
.icon-mini:hover { border-color: var(--hover-line); background: var(--hover-bg); }
.browse-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .02);
}
.browse-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.browse-body { display: block; padding: 8px; }
.browse-row {
  display: flex; align-items: center; gap: 9px; padding: 6px 9px;
  border-radius: 7px; cursor: pointer; user-select: none;
}
.browse-row:hover { background: var(--hover-bg); }
.browse-row.dir .browse-name { font-weight: 600; }
.browse-icon { width: 18px; text-align: center; flex: none; font-size: 13px; }
.browse-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.browse-meta { font: 11px var(--mono); color: var(--muted); flex: none; }
.browse-row.up { border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 6px; }
.browse-foot { padding: 7px 14px; }
.browse-empty { padding: 10px; }

/* ---------------- Thông báo (settings) ---------------- */
.notify-block {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px; background: var(--card-bg);
}
.notify-block h3 { margin: 0; font-size: 14px; }
.notify-ch {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 9px; margin: 0;
}
.notify-ch legend { padding: 0 4px; }
.notify-ch .hint { margin: 0; }
.notify-test { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- Modal zoom section ---------------- */
.head-actions { display: flex; align-items: center; gap: 7px; }
.zoom-btn { font-size: 14px; line-height: 1; padding: 4px 9px; }
.modal.zoom-modal { width: min(1400px, 97vw); height: min(92vh, 1100px); }
.zoom-body {
  padding: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--panel);
}
/* Section được phóng to: bỏ viền/bo góc + bỏ giới hạn chiều cao để lấp đầy modal */
.zoom-body > .panel {
  flex: 1 1 auto; min-height: 0; max-height: none;
  border: 0; border-radius: 0; box-shadow: none;
}
.zoom-body .panel-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.zoom-body .jobs,
.zoom-body .log-list { overflow: auto; }
.zoom-body .terminal { flex: 1 1 auto; min-height: 0; }
/* Panel có vùng cuộn riêng bên trong panel-body -> không cuộn panel-body */
.zoom-body > .panel.pos-zoom .panel-body { overflow: hidden; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .console-layout { grid-template-columns: 1fr; min-height: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .console-panel { min-height: 60vh; }
  .terminal { min-height: 46vh; }
}
@media (max-width: 640px) {
  .topbar { padding: 9px 12px; }
  .brand-sub { display: none; }
  .wrap { padding: 10px; }
  .console-actions .mono { display: none; }
}
