:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #667085;
  --blue: #1d64d8;
  --blue-dark: #174fa9;
  --green: #147a55;
  --amber: #9a5b00;
  --red: #c33232;
  --shadow: 0 14px 36px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.auth-locked .app-shell {
  display: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.head-action-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

button:hover,
.head-action-link:hover {
  border-color: #9aa8bd;
}

.head-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.head-action-link:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: var(--blue-dark);
}

button.danger {
  color: var(--red);
}

button.route-toggle.pause {
  border-color: #e3a328;
  background: #fff8e8;
  color: var(--amber);
}

button.route-toggle.resume {
  border-color: #6fb996;
  background: #eefbf5;
  color: var(--green);
}

button.icon-button {
  width: 40px;
  padding: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input {
  height: 40px;
  padding: 0 12px;
}

select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus,
.media-panel:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 100, 216, 0.12);
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 22px;
}

.brand-row,
.editor-head,
.panel-head,
.search-row,
.head-actions {
  display: flex;
  align-items: center;
}

.brand-row,
.editor-head,
.panel-head {
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

.brand-row p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.search-row {
  gap: 8px;
}

.search-row input {
  min-width: 0;
  flex: 1 1 auto;
}

#newBtn {
  flex: 0 0 auto;
  min-width: 64px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}

#newBtn:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.web-only-open-btn {
  width: 100%;
  border-color: #8ed8c3;
  color: var(--green);
  background: #effbf7;
}

.browser-accounts-open-btn {
  width: 100%;
  border-color: #8ed8c3;
  color: var(--green);
  background: #effbf7;
}

.web-only-dialog {
  width: min(1000px, calc(100vw - 32px));
  max-width: none;
  max-height: min(850px, calc(100vh - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.web-only-dialog::backdrop {
  background: rgba(20, 30, 48, 0.48);
}

.web-only-dialog-head,
.web-only-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.web-only-dialog-head {
  margin-bottom: 18px;
}

.web-only-dialog-head h2 {
  margin-top: 6px;
}

.web-only-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 20px;
}

.web-only-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.web-only-form label {
  display: grid;
  gap: 6px;
}

.web-only-form label span,
.web-only-list-panel h3 {
  color: var(--muted);
  font-size: 13px;
}

.web-only-form label.wide,
.web-only-form-actions {
  grid-column: 1 / -1;
}

.web-only-form-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 4px;
}

.web-only-list-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.web-only-list-panel h3 {
  margin-bottom: 10px;
}

.web-only-list {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
}

.web-only-list-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 0;
  padding: 10px;
  text-align: left;
  white-space: normal;
}

.web-only-list-item.active {
  border-color: var(--green);
  background: #effbf7;
}

.web-only-list-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.web-only-empty {
  color: var(--muted);
  font-size: 13px;
}

.enterprise-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}

.system-status-panel{margin:20px 0;padding:18px;border:1px solid var(--line);border-radius:10px;background:var(--panel);box-shadow:var(--shadow)}.system-status-actions{display:flex;align-items:center;gap:10px}.status-badge{display:inline-flex;align-items:center;min-height:30px;padding:0 11px;border-radius:999px;font-size:13px;font-weight:700}.status-badge.loading{color:var(--muted);background:#eef1f5}.status-badge.normal{color:var(--green);background:#e8f7ef}.status-badge.warning{color:var(--amber);background:#fff3d9}.status-badge.critical{color:var(--red);background:#fdeaea}.system-status-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:16px}.system-status-grid article{display:flex;flex-direction:column;gap:5px;min-width:0;padding:14px;border:1px solid #e8ecf2;border-radius:8px;background:#fafbfd}.system-status-grid span,.system-status-grid small,.system-status-meta{color:var(--muted)}.system-status-grid strong{font-size:21px}.system-status-grid small{overflow-wrap:anywhere}.system-status-meta{margin-top:12px;font-size:12px}@media(max-width:1050px){.system-status-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:700px){.system-status-grid{grid-template-columns:1fr}.system-status-panel .panel-head{align-items:flex-start;flex-direction:column}}

.enterprise-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  text-align: left;
}

.enterprise-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29, 100, 216, 0.1);
}

.enterprise-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.enterprise-name img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.enterprise-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  min-width: 0;
}

.head-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.config-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.config-grid label.wide {
  grid-column: 1 / -1;
}

.media-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.media-panel,
.api-preview,
.route-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: var(--shadow);
}

.route-panel {
  display: grid;
  gap: 14px;
}

.route-panel-head {
  align-items: flex-start;
}

.panel-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.route-actions,
.route-form-actions,
.route-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ttl-field {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.ttl-field input {
  width: 92px;
}

.route-list {
  display: grid;
  gap: 8px;
}

.route-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(240px, 2fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fafc;
}

.route-name {
  font-weight: 700;
}

.route-meta,
.route-endpoints {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.route-badge {
  display: inline-flex;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e8eef8;
  color: var(--blue-dark);
  font-size: 11px;
}

.route-badge.off {
  background: #f4e7e7;
  color: var(--red);
}

.route-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.route-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.route-form label.wide {
  grid-column: span 2;
}

.route-form .check-field {
  display: flex;
  align-items: center;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.route-form-actions {
  justify-content: flex-end;
  grid-column: 1 / -1;
}

body.third-party-auth-page .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.android-entries-page .editor > :not(#androidEntriesPanel) {
  display: none;
}

body.android-entries-page .sidebar #newBtn,
body.android-entries-page .sidebar #webOnlyBtn {
  display: none;
}

.android-entries-panel,
.android-entries-content {
  min-width: 0;
}

.client-settings-group {
  min-width: 0;
}

.client-settings-group > summary {
  padding: 12px 0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.client-settings-group > summary:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 4px;
}

.client-settings-cards {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.client-settings-cards .route-panel {
  margin-top: 0;
}

.android-entries-content {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.android-entries-panel .panel-head {
  flex-wrap: wrap;
  gap: 12px;
}

.android-entries-panel .probe-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.android-entries-panel .probe-form label,
.android-entries-panel .panel-head > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .android-entries-panel .probe-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

body.third-party-auth-page .sidebar,
body.third-party-auth-page .editor > :not(#thirdPartyAuthPanel) {
  display: none;
}

.third-party-auth-panel {
  border-color: #c7e6db;
}

.auth-provider-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.auth-provider-tab {
  border-color: #d8e7e1;
  background: #f7fbf9;
}

.auth-provider-tab.active {
  border-color: #35a77b;
  color: #177354;
  background: #eaf8f2;
  box-shadow: inset 0 0 0 1px #35a77b;
}

.auth-provider-tab small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 10px;
}

.auth-provider-content[hidden],
#thirdPartyAuthPanel[hidden] {
  display: none;
}

.auth-provider-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.auth-provider-head h4,
.auth-provider-placeholder h4 {
  margin: 0 0 6px;
}

.auth-provider-placeholder {
  min-height: 120px;
  padding: 22px;
  border: 1px dashed #c9d8d2;
  border-radius: 8px;
  color: var(--muted);
  background: #fafcfb;
}

.auth-provider-placeholder p {
  margin: 0;
}

.secret-reveal-btn {
  justify-self: start;
  width: auto;
  min-width: 88px;
}

.huawei-account-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.huawei-account-form {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.huawei-account-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 12px;
}

.huawei-account-meta span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #f4faf7;
}

.enterprise-description-panel textarea {
  min-height: 130px;
}

.probe-form {
  display: grid;
  grid-template-columns: 1fr 2fr 140px 180px auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.probe-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.probe-form .check-field {
  display: flex;
  align-items: center;
  padding-bottom: 9px;
}

.probe-form .route-form-actions {
  grid-column: auto;
  padding-bottom: 1px;
}

.probe-health {
  font-weight: 700;
  color: var(--red);
}

.probe-health.ok {
  color: var(--green);
}

.route-history {
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.route-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.media-panel.dragging {
  border-color: var(--green);
  background: #f1fbf7;
}

.hidden-input {
  display: none;
}

.logo-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px dashed #a8b3c5;
  border-radius: 8px;
  margin-top: 12px;
  color: var(--muted);
  overflow: hidden;
  background: #f8fafc;
  text-align: center;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  min-height: 160px;
  margin-top: 12px;
}

.image-tile {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #f8fafc;
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-tile button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  min-height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--red);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed #a8b3c5;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.api-preview pre {
  margin: 12px 0 0;
  min-height: 160px;
  max-height: 280px;
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
}

.login-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}

.hidden {
  display: none;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;
  }

  .config-grid,
  .media-grid,
  .route-form,
  .probe-form {
    grid-template-columns: 1fr;
  }

  .route-form label.wide {
    grid-column: auto;
  }

  .probe-form .route-form-actions {
    grid-column: auto;
  }

  .route-row {
    grid-template-columns: 1fr;
  }

  .web-only-layout {
    grid-template-columns: 1fr;
  }

  .web-only-list-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 0 0;
  }
}

@media (max-width: 560px) {
  .editor,
  .sidebar {
    padding: 16px;
  }

  .editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .head-actions {
    width: 100%;
    justify-content: stretch;
  }

  .head-actions button,
  .head-actions .head-action-link {
    flex: 1;
  }

  .web-only-dialog {
    padding: 16px;
  }

  .web-only-form {
    grid-template-columns: 1fr;
  }

  .web-only-form label.wide,
  .web-only-form-actions {
    grid-column: auto;
  }

  .web-only-form-actions button {
    flex: 1 1 auto;
  }
}
#relayControlPanel select, #relayControlPanel button { min-height: 44px; }
#relayControlPanel[hidden], #relayControlPanel [hidden] { display: none !important; }
#relayControlPanel label { min-width: 0; }
#relayControlStatus { overflow-wrap: anywhere; }
