/* Công cụ vận hành: ưu tiên dễ đọc, trạng thái rõ. Màu theo trang kế hoạch (xanh ngọc trên nền xám lạnh). */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface2: #e9eef0;
  --fg: #14232a;
  --muted: #52646c;
  --line: #d5dde0;
  --accent: #0e6f66;
  --accent-fg: #ffffff;
  --accent-soft: #d8efec;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --warn: #8a5200;
  --warn-soft: #fbecd0;
  --ok: #17692f;
  --ok-soft: #d9f2e0;
  --log-bg: #0f1c22;
  --log-fg: #d6e6e3;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e171b; --surface: #152228; --surface2: #1c2d34; --fg: #e4eef0; --muted: #93a8af; --line: #27393f;
    --accent: #4fc4b6; --accent-fg: #062b27; --accent-soft: #17403c; --danger: #ff8a7a; --danger-soft: #3d1d19;
    --warn: #f0b45a; --warn-soft: #3a2c12; --ok: #6fd58b; --ok-soft: #173826; --log-bg: #0a1216; --log-fg: #cfe3e0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e171b; --surface: #152228; --surface2: #1c2d34; --fg: #e4eef0; --muted: #93a8af; --line: #27393f;
  --accent: #4fc4b6; --accent-fg: #062b27; --accent-soft: #17403c; --danger: #ff8a7a; --danger-soft: #3d1d19;
  --warn: #f0b45a; --warn-soft: #3a2c12; --ok: #6fd58b; --ok-soft: #173826; --log-bg: #0a1216; --log-fg: #cfe3e0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 var(--font);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface2); padding: 1px 6px; border-radius: 4px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* đăng nhập */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; }
.login-card { width: min(100%, 400px); display: flex; flex-direction: column; gap: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card .btn { margin-top: 12px; }
.login-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 10px 0 14px; }
.login-steps li { flex: 1; text-align: center; font-size: 12px; padding: 6px 4px; border-radius: 6px; background: var(--surface2); color: var(--muted); }
.login-steps li.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.login-steps li.done { color: var(--ok); }

/* khung */
.topbar { max-width: 1040px; margin: 0 auto; padding-block: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; margin-right: auto; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.chip.low { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.wrap { max-width: 1040px; margin: 0 auto; padding-block: 8px 64px; display: flex; flex-direction: column; gap: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface2); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
td.actions-cell { text-align: right; white-space: nowrap; }
.btn.small { padding: 4px 10px; font-size: 13px; }
td.actions-cell .btn { margin-left: 4px; }

/* nút và ô nhập */
label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 4px; }
input[type="text"], input[type="password"], input[type="email"], input[type="file"] {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
}
.btn { font: inherit; font-weight: 500; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 8px 16px; cursor: pointer; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.preview { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 14px 0 0; padding: 10px 14px; background: var(--surface2); border-radius: 8px; font-size: 13px; }
.preview dt { color: var(--muted); }
.preview dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

fieldset { border: 0; padding: 0; margin: 20px 0 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; font-size: 15px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 5px; accent-color: var(--accent); }
.choice b { display: block; }
.choice small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.legacy { margin: 8px 0 0 32px; }
progress { width: 100%; height: 10px; margin-top: 8px; accent-color: var(--accent); }
.more { margin-top: 16px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 14px; }

.error { background: var(--danger-soft); color: var(--danger); padding: 8px 12px; border-radius: 8px; margin-top: 12px; font-size: 14px; }
.warn { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; margin-top: 8px; font-size: 13px; }

/* trạng thái */
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.pill.ok, .pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.incomplete { background: var(--danger-soft); color: var(--danger); }
.pill.running, .pill.inactive, .pill.unknown { background: var(--warn-soft); color: var(--warn); }

.log { background: var(--log-bg); color: var(--log-fg); border-radius: 10px; padding: 14px; margin: 0; font: 12.5px/1.55 var(--mono); max-height: 380px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.result { background: var(--ok-soft); color: var(--fg); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.result.bad { background: var(--danger-soft); }
.result .line { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.recent button:hover { background: var(--surface2); }
.recent .when { margin-left: auto; font-size: 12px; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); padding: 20px; width: min(92vw, 520px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h3 { margin-bottom: 8px; }
dialog form p { margin-bottom: 4px; }
#logs-dialog { width: min(94vw, 760px); }

/* thông báo nhỏ */
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); max-width: min(92vw, 420px); background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; z-index: 20; }
.toast.bad { background: var(--danger); color: #fff; }
