:root {
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #182129;
  background: #f3f5f7;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --surface-3: #edf1f3;
  --border: #dce2e5;
  --border-strong: #c5ced3;
  --text: #182129;
  --muted: #66727c;
  --subtle: #89949d;
  --primary: #0f766e;
  --primary-hover: #0b625c;
  --primary-soft: #e8f4f2;
  --primary-contrast: #ffffff;
  --focus: #2563eb;
  --green: #178455;
  --blue: #2b6cb0;
  --amber: #a76008;
  --danger: #c23b3b;
  --shadow: 0 18px 50px rgba(26, 38, 46, .18);
}

:root[data-theme="dark"] {
  color: #e7ecef;
  background: #15191d;
  --bg: #15191d;
  --surface: #1d2227;
  --surface-2: #23292f;
  --surface-3: #2c333a;
  --border: #343c43;
  --border-strong: #4a555e;
  --text: #e7ecef;
  --muted: #a5afb7;
  --subtle: #7e8992;
  --primary: #55c7b8;
  --primary-hover: #6dd3c5;
  --primary-soft: #203b39;
  --primary-contrast: #102523;
  --focus: #72a7f6;
  --green: #55bd86;
  --blue: #78aee3;
  --amber: #e0a44f;
  --danger: #ef7777;
  --shadow: 0 18px 50px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #root { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: var(--bg); font-size: 13px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:disabled { opacity: .42; cursor: not-allowed; }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 8px 10px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 16%, transparent); }
textarea { min-height: 96px; resize: vertical; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code, .mono, .log-view, .config-view, .code-input { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.app-shell { display: grid; grid-template-rows: 56px minmax(0, 1fr) 28px; width: 100%; height: 100%; background: var(--bg); }
.app-shell.is-busy { cursor: progress; }
.app-shell.is-busy button { pointer-events: none; }
.operation-progress { position: fixed; z-index: 60; top: 0; left: 0; width: 34%; height: 2px; background: var(--primary); animation: operation-progress 1.1s ease-in-out infinite; }
@keyframes operation-progress { from { transform: translateX(-110%); } to { transform: translateX(390%); } }
@media (prefers-reduced-motion: reduce) { .operation-progress { width: 100%; animation: none; } }

.topbar { display: flex; align-items: center; min-width: 0; color: var(--text); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { width: 244px; height: 100%; display: flex; flex: 0 0 auto; align-items: center; gap: 10px; padding: 0 16px; border-right: 1px solid var(--border); }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--primary-contrast); background: var(--primary); border-radius: 7px; font-size: 10px; font-weight: 800; }
.brand > div { display: flex; align-items: baseline; gap: 7px; }
.brand strong { font-size: 16px; }
.brand span:last-child { color: var(--subtle); font-size: 10px; text-transform: uppercase; }
.menu-strip { display: flex; align-items: stretch; align-self: stretch; }
.menu-strip button { min-width: 76px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 12px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.menu-strip button:hover { color: var(--text); background: var(--surface-2); }
.menu-strip button.active { color: var(--primary); border-bottom-color: var(--primary); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.mobile-only { display: none !important; }
.lucide-icon { width: 17px; height: 17px; display: block; flex: 0 0 auto; }
.connection-button { height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.connection-button:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.connection-button.connected { color: var(--text); }
.connection-dot, .status-led { width: 8px; height: 8px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 13%, transparent); }
.connected .connection-dot, .status-led.online { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 13%, transparent); }

.icon-button, .command-button, .button, .text-button {
  min-height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer;
}
.icon-button { width: 36px; padding: 0; display: inline-grid; place-items: center; flex: 0 0 auto; }
.command-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; white-space: nowrap; }
.button { padding: 0 15px; }
.text-button { min-height: 28px; padding: 0 8px; color: var(--muted); background: transparent; border-color: transparent; }
.icon-button:hover, .command-button:hover, .button:hover { border-color: var(--border-strong); background: var(--surface-3); }
.command-button.primary { color: var(--primary-contrast); background: var(--primary); border-color: var(--primary); }
.command-button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.command-button.full { width: 100%; }
.icon-button.danger, .danger-text { color: var(--danger); }
.icon-button.success { color: var(--green); }
.icon-button.active { color: var(--primary); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }

.workspace { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 0; }
.sidebar { min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-heading { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 13px; color: var(--subtle); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.sidebar-heading strong, .sidebar-heading button { margin-left: auto; }
.sidebar-heading .icon-button { width: 28px; min-height: 28px; border-color: transparent; background: transparent; }
.sidebar-heading .lucide-icon { width: 14px; height: 14px; }
.group-list, .sidebar-subscriptions { padding: 3px 8px 8px; }
.group-list button, .sidebar-subscriptions > button { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 9px; padding: 0 9px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.group-list button:hover, .sidebar-subscriptions > button:hover { color: var(--text); background: var(--surface-2); }
.group-list button.active { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.group-list button span, .sidebar-subscriptions button span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-list small, .sidebar-subscriptions small { color: var(--subtle); font-variant-numeric: tabular-nums; }
.sidebar-subscriptions { margin-top: 3px; overflow-y: auto; border-top: 1px solid var(--border); }
.sidebar-subscriptions .sidebar-heading { margin: 0 -8px 2px; }
.sidebar-core { margin-top: auto; padding: 13px; background: var(--surface-2); border-top: 1px solid var(--border); }
.sidebar-core > div { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.sidebar-core p { margin: 7px 0 6px; color: var(--muted); font-size: 10px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-core small { color: var(--subtle); font-size: 10px; }

.main-content { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.overview-band { min-height: 96px; display: grid; grid-template-columns: minmax(230px, 1fr) minmax(420px, 1.8fr) auto; align-items: center; gap: 22px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.core-overview { min-width: 0; display: flex; align-items: center; gap: 12px; }
.core-emblem { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.core-emblem.running { color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--surface)); border-color: color-mix(in srgb, var(--green) 28%, var(--border)); }
.core-emblem.unavailable { color: var(--danger); }
.core-overview > div { min-width: 0; display: grid; gap: 2px; }
.eyebrow { color: var(--subtle); font-size: 9px; font-weight: 750; text-transform: uppercase; }
.core-overview strong { font-size: 17px; }
.core-overview small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.runtime-facts > div { min-width: 0; display: grid; gap: 5px; padding: 2px 18px; border-left: 1px solid var(--border); }
.runtime-facts span { color: var(--subtle); font-size: 10px; }
.runtime-facts strong { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.core-controls { display: flex; align-items: center; gap: 6px; }
.exposure-notice { min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 6px 18px; color: var(--amber); background: color-mix(in srgb, var(--amber) 7%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); }
.exposure-notice span { min-width: 0; flex: 1; }
.exposure-notice button { color: inherit; background: transparent; border: 0; cursor: pointer; font-weight: 700; }

.node-workspace { min-height: 0; display: flex; flex: 1; flex-direction: column; }
.list-header { min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.list-title { min-width: 82px; display: flex; align-items: baseline; gap: 7px; }
.list-title strong { font-size: 14px; }
.list-title span { color: var(--subtle); font-size: 10px; }
.search-box { width: min(360px, 36vw); height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.search-box .lucide-icon { color: var(--subtle); width: 15px; height: 15px; }
.search-box input { min-height: 32px; padding: 4px 0; background: transparent; border: 0; box-shadow: none; }
.search-box kbd { color: var(--subtle); font-size: 10px; }
.selection-actions { min-width: 0; margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.mobile-group-filter { display: none; }
.table-wrap { min-height: 0; flex: 1; overflow: auto; }
.profile-table { width: 100%; min-width: 850px; border-collapse: separate; border-spacing: 0; }
.profile-table th { position: sticky; z-index: 2; top: 0; height: 36px; padding: 0 12px; color: var(--subtle); background: var(--surface-2); border-bottom: 1px solid var(--border-strong); text-align: left; font-size: 10px; font-weight: 750; }
.profile-table td { height: 54px; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.profile-table tbody tr:hover td { background: var(--surface-2); }
.profile-table tbody tr.selected td { background: color-mix(in srgb, var(--focus) 7%, var(--surface)); }
.profile-table tbody tr.active-profile td:first-child { box-shadow: inset 3px 0 var(--primary); }
.check-cell { width: 38px; padding: 0 !important; text-align: center !important; }
.check-cell input { width: 15px; min-height: 15px; accent-color: var(--primary); }
.numeric { text-align: right !important; font-variant-numeric: tabular-nums; }
.name-cell { width: 29%; max-width: 330px; }
.name-cell > div { display: flex; align-items: center; gap: 7px; min-width: 0; }
.name-cell strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.protocol, .active-flag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 750; }
.protocol { color: #ffffff; }
.active-flag { color: var(--primary); background: var(--primary-soft); }
.protocol-vless { background: #31795d; } .protocol-vmess { background: #356da4; } .protocol-trojan { background: #75509a; }
.protocol-shadowsocks { background: #a86731; } .protocol-socks { background: #596974; } .protocol-http { background: #287d90; } .protocol-custom { background: #725158; }
.endpoint-cell { max-width: 260px; }
.endpoint-cell strong { display: inline-block; max-width: calc(100% - 50px); overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.endpoint-cell small { color: var(--subtle); }
.transport-cell strong, .transport-cell small { display: block; font-size: 10px; }
.transport-cell small { margin-top: 3px; }
.security-on { color: var(--green); font-weight: 700; }
.muted { color: var(--muted); }
.delay.good { color: var(--green); font-weight: 700; } .delay.slow { color: var(--amber); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.row-actions .icon-button { width: 30px; min-height: 30px; background: transparent; border-color: transparent; }
.row-actions .icon-button:hover { background: var(--surface-3); border-color: var(--border); }
.row-actions .lucide-icon { width: 15px; height: 15px; }
.mobile-profile-list { display: none; }

.bottom-panel { flex: 0 0 auto; background: var(--surface); border-top: 1px solid var(--border); }
.bottom-tabs { height: 38px; display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; background: var(--surface-2); }
.bottom-tabs > button:not(.icon-button):not(.text-button) { height: 38px; display: flex; align-items: center; gap: 6px; padding: 0 13px; background: transparent; border: 0; border-right: 1px solid var(--border); cursor: pointer; }
.bottom-tabs > button.active { color: var(--primary); background: var(--surface); box-shadow: inset 0 -2px var(--primary); }
.bottom-tabs .icon-button { width: 34px; min-height: 34px; background: transparent; border: 0; }
.log-view, .config-view { height: 176px; overflow: auto; margin: 0; padding: 9px 12px; color: #d8dfe3; background: #171b1f; font-size: 11px; line-height: 1.55; }
.log-line { display: grid; grid-template-columns: 78px 55px minmax(0, 1fr); gap: 8px; }
.log-line time { color: #78858e; } .log-line > span { color: #8fb2cb; text-transform: uppercase; } .log-line pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.log-error pre, .log-stderr pre { color: #ff9e9e; } .log-system pre { color: #8fd8b6; }
.log-empty { height: 100%; display: grid; place-items: center; color: #76818a; }
.config-view { color: #d6e3ed; white-space: pre-wrap; }

.statusbar { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 0 10px; color: var(--subtle); background: var(--surface-2); border-top: 1px solid var(--border); font-size: 10px; }
.statusbar > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.statusbar .status-led { width: 6px; height: 6px; }
.status-spacer { flex: 1; }

.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(12, 18, 22, .56); }
.modal { width: min(580px, 100%); max-height: min(840px, calc(100vh - 40px)); display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); }
.modal-wide { width: min(980px, 100%); }
.modal-header { min-height: 68px; display: flex; align-items: center; padding: 11px 14px 11px 20px; border-bottom: 1px solid var(--border); }
.modal-header > div { min-width: 0; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.modal-header .icon-button { margin-left: auto; background: transparent; border-color: transparent; }
.modal-body { min-height: 0; overflow: auto; padding: 20px; }
.modal-footer { min-height: 60px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 20px; background: var(--surface-2); border-top: 1px solid var(--border); }
.modal-footer .footer-left { margin-right: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 650; }
.field-wide { grid-column: 1 / -1; }
.field small { color: var(--subtle); font-weight: 400; line-height: 1.45; }
.field input, .field select, .field textarea { color: var(--text); font-weight: 400; }
.code-input { min-height: 240px; line-height: 1.5; white-space: pre; }
.toggle-row { min-height: 38px; display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 12px; cursor: pointer; }
.toggle-row input { width: 16px; min-height: 16px; accent-color: var(--primary); }
.section-title { grid-column: 1 / -1; margin-top: 7px; padding-top: 17px; color: var(--text); border-top: 1px solid var(--border); font-size: 12px; font-weight: 750; }
.form-error { padding: 10px 12px; color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); border-radius: 6px; }
.connection-summary { min-height: 58px; display: flex; align-items: center; gap: 11px; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.connection-summary > div { min-width: 0; display: grid; gap: 3px; }
.connection-summary small { overflow-wrap: anywhere; color: var(--muted); font-weight: 400; }
.runtime-paths { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px 11px; padding-top: 15px; color: var(--muted); border-top: 1px solid var(--border); font-size: 11px; }
.runtime-paths code { min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.tun-readiness { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding-bottom: 13px; border-bottom: 1px solid var(--border); }
.tun-readiness span { min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.tun-readiness i { width: 18px; height: 18px; display: inline-grid; place-items: center; flex: 0 0 auto; font-style: normal; border: 1px solid var(--border-strong); border-radius: 50%; }
.tun-readiness .ok { color: var(--green); } .tun-readiness .ok i { border-color: var(--green); }
.tun-readiness .bad { color: var(--danger); } .tun-readiness .bad i { border-color: var(--danger); }
.subscription-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 0; }
.subscription-form { align-self: start; display: grid; gap: 12px; padding-right: 20px; border-right: 1px solid var(--border); }
.subscription-form h3 { margin: 0 0 2px; font-size: 13px; }
.subscription-list { min-width: 0; display: flex; flex-direction: column; gap: 7px; padding-left: 20px; }
.subscription-item { min-height: 68px; display: flex; align-items: center; gap: 7px; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.subscription-main { min-width: 0; flex: 1; }
.subscription-main strong, .subscription-main p, .subscription-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subscription-main p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.subscription-main small { margin-top: 4px; color: var(--subtle); }
.subscription-main small.error { color: var(--danger); }
.routing-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.segmented button { min-height: 36px; padding: 0 13px; background: var(--surface); border: 0; border-right: 1px solid var(--border); cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { color: var(--primary-contrast); background: var(--primary); }
.rule-list { display: flex; flex-direction: column; gap: 7px; }
.rule-row { display: grid; grid-template-columns: 130px minmax(145px, 1fr) minmax(145px, 1fr) 80px 96px 88px 36px; gap: 7px; align-items: center; }
.backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.backup-action { min-height: 110px; display: flex; align-items: center; gap: 14px; padding: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; cursor: pointer; text-align: left; }
.backup-action:hover { border-color: var(--primary); background: var(--primary-soft); }
.backup-action strong, .backup-action small { display: block; }
.backup-action small { margin-top: 5px; color: var(--muted); }
.empty-state { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; color: var(--muted); text-align: center; }
.empty-state > .lucide-icon { width: 32px; height: 32px; color: var(--subtle); }
.empty-state h3 { margin: 13px 0 4px; color: var(--text); font-size: 15px; }
.empty-state p { margin: 0 0 16px; }
.empty-state.compact { min-height: 130px; }
.disconnected-empty > .lucide-icon { color: var(--danger); }
.toast-stack { position: fixed; z-index: 50; right: 14px; bottom: 42px; width: min(370px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 7px; }
.toast { min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 10px 13px; color: var(--text); background: var(--surface); border: 1px solid color-mix(in srgb, var(--green) 45%, var(--border)); border-radius: 6px; box-shadow: 0 9px 28px rgba(20, 31, 38, .17); }
.toast.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

@media (max-width: 1100px) {
  .brand, .workspace { --sidebar-size: 210px; }
  .brand { width: 210px; }
  .workspace { grid-template-columns: 210px minmax(0, 1fr); }
  .menu-strip button { min-width: 66px; padding: 0 9px; }
  .overview-band { grid-template-columns: minmax(210px, 1fr) minmax(290px, 1.3fr) auto; gap: 12px; }
  .runtime-facts > div { padding: 2px 11px; }
  .runtime-facts > div:nth-child(3) { display: none; }
  .runtime-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .app-shell { grid-template-rows: 54px minmax(0, 1fr) 28px; }
  .brand { width: auto; min-width: 132px; padding: 0 12px; border-right: 0; }
  .brand-mark { width: 28px; height: 28px; }
  .brand span:last-child { display: none; }
  .menu-strip { position: fixed; z-index: 25; top: 50px; right: 10px; display: none; width: 180px; height: auto; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; box-shadow: var(--shadow); }
  .menu-strip.open { display: flex; }
  .menu-strip button { min-height: 42px; justify-content: flex-start; border: 0; border-radius: 5px; }
  .mobile-only { display: inline-grid !important; }
  .connection-button .lucide-icon { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .overview-band { min-height: 112px; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px; }
  .core-emblem { width: 38px; height: 38px; }
  .runtime-facts { grid-column: 1 / -1; grid-row: 2; }
  .runtime-facts > div { padding: 0 12px 0 0; border-left: 0; border-right: 1px solid var(--border); }
  .runtime-facts > div:last-child { padding-left: 12px; border-right: 0; }
  .core-controls .icon-button:first-child { display: none; }
  .exposure-notice { padding: 7px 12px; font-size: 11px; }
  .list-header { min-height: 102px; flex-wrap: wrap; padding: 9px 10px; gap: 7px; }
  .list-title { order: 1; min-width: 58px; }
  .mobile-group-filter { order: 2; display: block; width: min(150px, calc(50% - 36px)); }
  .mobile-group-filter select { min-height: 36px; }
  .search-box { order: 3; width: 100%; }
  .selection-actions { order: 1; flex: 1; }
  .selection-actions .command-button:not(.primary), .selection-actions .icon-button:not([data-open="import"]) { display: none; }
  .desktop-profile-list { display: none; }
  .mobile-profile-list { min-height: 0; display: block; flex: 1; overflow: auto; padding: 8px; background: var(--bg); }
  .profile-card { min-height: 92px; display: flex; align-items: center; gap: 8px; margin-bottom: 7px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
  .profile-card.active-profile { border-left: 3px solid var(--primary); }
  .profile-card-main { min-width: 0; flex: 1; }
  .profile-card-title, .profile-card-meta { min-width: 0; display: flex; align-items: center; gap: 7px; }
  .profile-card-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile-card-meta { margin-top: 7px; }
  .profile-card-meta .mono { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .profile-card-main > small { display: block; margin-top: 7px; overflow: hidden; color: var(--subtle); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .profile-card .row-actions { flex-direction: column; }
  .bottom-panel.open .log-view, .bottom-panel.open .config-view { height: min(190px, 28vh); }
  .statusbar { gap: 10px; }
  .desktop-status { display: none !important; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal, .modal-wide { width: 100%; max-height: calc(100vh - 30px); border-radius: 8px 8px 0 0; border-bottom: 0; }
  .modal-header { min-height: 60px; padding: 10px 12px 10px 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { min-height: 58px; padding: 9px 14px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .field-wide, .section-title { grid-column: 1; }
  .subscription-layout { grid-template-columns: 1fr; }
  .subscription-form { padding: 0 0 18px; border-right: 0; border-bottom: 1px solid var(--border); }
  .subscription-list { padding: 14px 0 0; }
  .routing-toolbar { align-items: stretch; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .rule-row { min-width: 800px; }
  .rule-list { overflow-x: auto; }
  .tun-readiness { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backup-actions { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .top-actions { gap: 4px; padding: 0 8px 0 0; }
  .connection-button { padding: 0 9px; }
  .connection-button .connection-dot { width: 7px; height: 7px; }
  .overview-band { min-height: 108px; }
  .core-overview small { max-width: 190px; }
  .core-controls .icon-button { display: none; }
  .selection-actions .icon-button { display: none; }
  .command-button { padding: 0 11px; }
  .empty-state { min-height: 230px; }
  .modal-footer .footer-left { display: none; }
}
