/* Aero Panel — a restrained desktop layout inspired by sing-box-for-desktop. */
:root {
  color-scheme: light;
  font-family: "Segoe UI", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 13px;
  font-synthesis: none;
  --page: #fafafa;
  --sidebar: #f0f0f0;
  --panel: #ffffff;
  --inset: #f4f4f4;
  --ink: #202020;
  --muted: #727272;
  --faint: #898989;
  --line: #e5e5e5;
  --strong-line: #d4d4d4;
  --hover: #e9e9e9;
  --selected: #e1e1e1;
  --accent: #252525;
  --on-accent: #ffffff;
  --good: #36755e;
  --good-bg: #e8f1ec;
  --bad: #aa5232;
  --bad-bg: #f8ede7;
  --danger: #ad3445;
  --scrim: #00000059;
  --overlay-shadow: 0 20px 70px #00000029;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --code-keyword: #8252a1;
  --code-string: #39714b;
  --code-number: #a06431;
  --code-property: #356d91;
  color: var(--ink);
  background: var(--page);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1e1e1e;
  --sidebar: #181818;
  --panel: #282828;
  --inset: #222222;
  --ink: #ededed;
  --muted: #ababab;
  --faint: #939393;
  --line: #383838;
  --strong-line: #505050;
  --hover: #303030;
  --selected: #333333;
  --accent: #ededed;
  --on-accent: #202020;
  --good: #8bc5a9;
  --good-bg: #263d32;
  --bad: #e3a27f;
  --bad-bg: #433027;
  --danger: #ed96a2;
  --scrim: #0000008c;
  --overlay-shadow: 0 20px 70px #00000066;
  --code-keyword: #d4a6ed;
  --code-string: #a4ce9b;
  --code-number: #dfb081;
  --code-property: #a2c6e3;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 7px 12px; border: 1px solid var(--strong-line);
  border-radius: 9px; background: var(--panel); color: var(--ink);
  font-weight: 500; line-height: 1.25; cursor: pointer;
  box-shadow: 0 1px 1px #00000004;
  transition: background .12s, border-color .12s;
}
button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--ink); opacity: .88; }
.danger { color: var(--danger); }
.icon { width: 17px; height: 17px; flex: 0 0 auto; }
.icon-button { width: 34px; padding: 7px; }
.hidden { display: none !important; }
.muted, small { color: var(--muted); }
small { display: block; font-size: 11px; line-height: 1.7; }
h1 { margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.7px; }
h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
p { line-height: 1.65; }
#workspace { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column;
  height: 100dvh; padding: 30px 12px 14px;
  border-right: 1px solid var(--line); background: var(--sidebar);
}
.brand {
  display: block; padding: 0 12px; font-family: var(--serif); font-size: 25px;
  font-weight: 600; letter-spacing: -.7px; text-decoration: none; color: var(--ink);
}
.nav-caption { margin: 34px 12px 12px; color: var(--faint); font-size: 10px; letter-spacing: 1px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; padding-bottom: 20px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); transition: background .12s, color .12s; }
.nav-item .icon { color: var(--faint); }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { color: var(--ink); background: var(--selected); font-weight: 600; }
.nav-item.active .icon { color: var(--ink); }
.nav-item:last-child { margin-top: auto; }
.sidebar-account { display: flex; align-items: center; gap: 10px; padding: 16px 8px 2px; border-top: 1px solid var(--line); }
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--strong-line); border-radius: 50%; }
.account-avatar .icon { width: 15px; height: 15px; }
.sidebar-account strong { font-weight: 500; font-size: 12px; }
#logout { margin-left: auto; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
#logout:hover { background: var(--hover); color: var(--ink); }
#workspace > main { min-width: 0; width: 100%; max-width: 1440px; margin: 0 auto; padding: 32px clamp(22px, 3.2vw, 48px) 48px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 38px; margin-bottom: 28px; }
.header-actions { display: flex; gap: 8px; }
.header-actions > .icon-button { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.header-actions > .icon-button:hover { background: var(--hover); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { padding: 19px 22px 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 1px 2px #00000003; }
.stat-label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.stat-label .icon { color: var(--faint); width: 16px; height: 16px; }
.stat strong { display: block; margin-top: 12px; font-size: 28px; font-weight: 500; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.toolbar input { flex: 1; min-width: 180px; margin-right: auto; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
th { padding: 13px 16px; color: var(--muted); background: var(--inset); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 500; white-space: nowrap; }
td { max-width: 300px; padding: 18px 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--hover) 35%, transparent); }
th:first-child, td:first-child { width: 48px; padding-right: 6px; }
td strong { display: block; margin-bottom: 4px; font-weight: 500; }
td:nth-child(3) { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.node-error { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; max-width: 250px; font-size: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 3px; padding: 3px 7px; border-radius: 6px; font-size: 10px; background: var(--inset); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.badge.healthy { background: var(--good-bg); color: var(--good); }
.badge.unhealthy, .badge.failed, .badge.invalid { background: var(--bad-bg); color: var(--bad); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.card { padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; overflow-wrap: anywhere; }
.card h2 { font-size: 14px; }
.card > button { margin: 4px 6px 4px 0; }
.card .actions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { min-height: 28px; padding: 5px 9px; font-size: 11px; border-radius: 7px; }
td.actions { display: table-cell; min-width: 165px; }
td.actions button { margin: 3px 4px 3px 0; }
.job-cards { grid-template-columns: 1fr; }
.job-cards .card p { font-family: var(--mono); font-size: 11px; padding: 8px 0; margin: 0; border-top: 1px solid var(--line); }
.job-cards .card p.muted { border-top: 0; padding: 0 0 12px; }
.settings-card { max-width: 650px; }
.empty { padding: 55px 22px; color: var(--muted); text-align: center; }
label { display: flex; flex-direction: column; gap: 8px; margin: 15px 0; color: var(--muted); font-size: 12px; }
input, select, textarea { min-width: 0; max-width: 100%; padding: 9px 11px; border: 1px solid var(--strong-line); border-radius: 9px; background: var(--panel); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
textarea { width: 100%; min-height: 220px; font-family: var(--mono); font-size: 12px; line-height: 1.7; }
.login { width: min(420px, calc(100% - 32px)); margin: 12vh auto; padding: 32px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.login-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 38px; }
.login .brand { padding: 0; }
.login h1 { font-size: 24px; }
.login .muted { font-size: 12px; margin-bottom: 26px; }
.login form > button { width: 100%; margin-top: 16px; min-height: 38px; }
.login [role="alert"] { color: var(--danger); }
.backdrop { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--scrim); backdrop-filter: blur(3px); }
.dialog { width: 820px; max-width: 100%; max-height: 90dvh; overflow-y: auto; padding: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--overlay-shadow); }
.dialog header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dialog h2 { margin: 0; font-family: var(--serif); font-size: 21px; }
.dialog .close { border-color: transparent; background: var(--inset); color: var(--muted); box-shadow: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.dialog footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.code { border: 1px solid var(--strong-line); border-radius: 10px; overflow: hidden; }
.cm-editor { max-height: 400px; color: var(--ink); background: var(--panel); font-size: 12px; }
.cm-editor .cm-scroller { overflow: auto; font-family: var(--mono); line-height: 1.7; }
.cm-editor .cm-gutters, .cm-editor .cm-panels { background: var(--inset); color: var(--faint); border-color: var(--line); }
.cm-editor .cm-activeLine, .cm-editor .cm-activeLineGutter { background: var(--hover); }
.cm-editor .cm-cursor { border-left-color: var(--ink); }
.cm-editor .cm-selectionBackground, .cm-editor.cm-focused .cm-selectionBackground { background: var(--selected); }
.cm-editor .cm-tooltip { background: var(--panel); color: var(--ink); border-color: var(--strong-line); }
.code-fallback { min-height: 360px; }
#preview-content { min-height: 350px; background: var(--inset); }
#toast { position: fixed; z-index: 40; bottom: 22px; left: calc(50% + 116px); transform: translateX(-50%); max-width: min(620px, calc(100vw - 40px)); max-height: 180px; overflow: auto; padding: 12px 18px; white-space: pre-wrap; color: var(--on-accent); background: var(--accent); border-radius: 11px; box-shadow: 0 5px 24px #0000001a; font-size: 12px; }
#boot-error { width: min(500px, calc(100% - 32px)); margin: 15vh auto; padding: 30px; }
#boot-error a { color: var(--ink); }
@media (max-width: 1080px) {
  #workspace { grid-template-columns: 200px minmax(0, 1fr); }
  #workspace > main { padding: 28px 24px; }
  #toast { left: calc(50% + 100px); }
  .toolbar input { flex-basis: 100%; max-width: none; }
}
@media (max-width: 720px) {
  #workspace { display: block; }
  .sidebar { position: relative; height: auto; padding: 17px 14px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0 4px; font-size: 22px; }
  .nav-caption, .sidebar-account { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 0; margin-top: 16px; }
  .nav-item { flex-shrink: 0; gap: 6px; padding: 9px 10px; font-size: 12px; }
  .nav-item:last-child { margin-top: 0; }
  .nav-item .icon { width: 15px; height: 15px; }
  /* Keep account exit reachable on small screens without taking a navigation row. */
  .sidebar-account { display: block; position: absolute; top: 13px; right: 16px; padding: 0; border: 0; }
  .sidebar-account > :not(#logout) { display: none; }
  #workspace > main { padding: 24px 16px 40px; }
  h1 { font-size: 24px; }
  .page-header { margin-bottom: 22px; }
  .stats { gap: 8px; margin-bottom: 22px; }
  .stat { padding: 14px 12px; border-radius: 12px; }
  .stat-label { font-size: 11px; gap: 3px; }
  .stat-label .icon { display: none; }
  .stat strong { font-size: 24px; margin-top: 10px; }
  .toolbar { gap: 7px; }
  .toolbar button { flex: 1; white-space: nowrap; }
  .toolbar input { width: 100%; min-width: 0; margin-bottom: 4px; }
  .table-wrap { border-radius: 12px; }
  table, tbody { display: block; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: grid; grid-template-columns: 18px minmax(0, 1fr) 104px; gap: 5px 10px; padding: 16px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td, th:first-child, td:first-child { max-width: none; width: auto; padding: 0; border: 0; }
  td:first-child { grid-column: 1; grid-row: 1 / 4; padding-top: 3px; }
  td:nth-child(2) { grid-column: 2; grid-row: 1; }
  td:nth-child(3) { grid-column: 2; grid-row: 2; align-self: start; }
  td:nth-child(4) { grid-column: 3; grid-row: 1 / 3; }
  td.actions { grid-column: 2 / 4; display: flex; min-width: 0; padding-top: 6px; }
  td.actions button { min-height: 32px; margin: 0; padding: 7px 12px; }
  .node-error { font-size: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .backdrop { padding: 12px; }
  .dialog { padding: 20px; max-height: 94dvh; }
  .dialog footer { flex-wrap: wrap; }
  .card { padding: 19px; }
  .login { margin: 8vh auto; padding: 26px; }
  #toast { left: 50%; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
