:root {
  color-scheme: light;
  --ink: #172235;
  --muted: #657189;
  --line: #dce2eb;
  --surface: #ffffff;
  --background: #f3f6fa;
  --navy: #0f2747;
  --orange: #f48120;
  --orange-dark: #c95e06;
  --green: #13795b;
  --red: #b42318;
  --shadow: 0 8px 28px rgba(25, 39, 66, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--orange); border-radius: 7px; background: var(--orange); color: #fff; font-weight: 650; padding: 9px 13px; cursor: pointer; }
button:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.secondary { background: #fff; color: var(--navy); border-color: #b9c4d3; }
button.secondary:hover { background: #edf1f6; }
button.success { background: var(--green); border-color: var(--green); }
button.danger { background: #fff; border-color: #e3a09a; color: var(--red); }
button.danger:hover { background: #fff0ee; }

.app-header { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 21px clamp(20px, 4vw, 58px); background: var(--navy); color: white; border-bottom: 4px solid var(--orange); }
.app-header h1 { margin: 2px 0 0; font-size: clamp(21px, 2.4vw, 31px); letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.status-cluster { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.status-dot, .profile-badge { border: 1px solid rgba(255,255,255,.24); border-radius: 999px; background: rgba(255,255,255,.08); padding: 6px 10px; font-size: 12px; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #e0a427; }
.status-dot.online::before { background: #54d399; }
.status-dot.offline::before { background: #ff776d; }

main { width: min(1600px, calc(100% - 34px)); margin: 24px auto 50px; }
.tabs { display: flex; overflow-x: auto; gap: 3px; padding: 0 4px; border-bottom: 1px solid var(--line); }
.tab { flex: 0 0 auto; border: 0; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); padding: 11px 14px; }
.tab:hover { background: #e9eef5; color: var(--navy); }
.tab.active { border-bottom-color: var(--orange); background: #fff; color: var(--navy); }
.panel { display: none; min-height: 340px; margin-top: 16px; padding: clamp(17px, 2.5vw, 30px); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.panel.active { display: block; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
h2 { margin: 2px 0 0; font-size: 23px; letter-spacing: -.02em; }
h3 { margin: 28px 0 10px; font-size: 16px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.lede { max-width: 900px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 15px; padding: 13px; border-radius: 8px; background: #f6f8fb; }
label { display: grid; gap: 5px; color: #3d4b61; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #b9c4d3; border-radius: 6px; background: #fff; color: var(--ink); padding: 9px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(244,129,32,.16); }
textarea { resize: vertical; }
.filters input { min-width: 260px; }
.muted { color: var(--muted); }
.filters .muted { margin: 0 0 9px auto; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #edf1f6; color: #344157; font-size: 11px; letter-spacing: .035em; text-transform: uppercase; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: #fff7ef; }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { min-width: 280px; white-space: normal; overflow-wrap: anywhere; }
th.select, td.select { width: 42px; text-align: center; }
td.select input, th.select input { width: auto; }
.boolean { display: inline-block; min-width: 48px; border-radius: 999px; padding: 2px 7px; text-align: center; font-size: 11px; font-weight: 750; }
.boolean.true { background: #daf5e9; color: #096647; }
.boolean.false { background: #eef1f5; color: #5c687a; }
.empty td { padding: 36px; color: var(--muted); text-align: center; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 14px 18px; max-width: 980px; margin: 20px 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
.form-actions { grid-column: 1 / -1; }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin: 19px 0; }
.inline-form label { min-width: min(420px, 100%); }
.result-summary { margin: 15px 0 10px; padding: 10px 12px; border-left: 3px solid var(--orange); background: #fff7ef; color: #4b5668; }

dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto; border: 0; border-radius: 11px; padding: 0; box-shadow: 0 26px 80px rgba(0,0,0,.34); }
dialog::backdrop { background: rgba(8,21,39,.62); }
dialog form { display: grid; gap: 16px; padding: 24px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; padding: 0 5px; }
.icon-button:hover { background: transparent; color: var(--navy); }
fieldset { border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 6px; color: #3d4b61; font-size: 12px; font-weight: 750; }
.tunnel-option { display: grid; grid-template-columns: 1fr 135px; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.tunnel-option:last-child { border: 0; }
.tunnel-option .check { min-width: 0; }
.file-label { border: 1px dashed #aebacc; border-radius: 7px; padding: 10px; }

.alert { margin-bottom: 15px; border-radius: 7px; padding: 12px 14px; }
.alert.error { border: 1px solid #e3a09a; background: #fff0ee; color: #8d2018; }
.busy { position: fixed; right: 22px; bottom: 22px; z-index: 20; display: flex; align-items: center; gap: 9px; border-radius: 8px; background: var(--navy); color: white; padding: 11px 14px; box-shadow: var(--shadow); }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%); max-width: min(560px, calc(100vw - 28px)); border-radius: 8px; background: var(--navy); color: #fff; padding: 11px 16px; box-shadow: var(--shadow); }
.toast.error { background: #8d2018; }
.hidden { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app-header, .panel-heading { align-items: flex-start; flex-direction: column; }
  .status-cluster, .actions { justify-content: flex-start; }
  main { width: min(100% - 18px, 1600px); margin-top: 12px; }
  .panel { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { grid-column: 1; }
  .filters .muted { margin-left: 0; }
}

.login-page { min-height: 100vh; display: grid; place-items: center; margin: 0; padding: 18px; background: #edf1f6; }
.login-card { width: min(460px, 100%); margin: 0; padding: 30px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 3px 0 8px; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.login-card .alert { margin: 16px 0 0; }
