:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d8dde6;
  --text: #172033;
  --muted: #687386;
  --accent: #1261a6;
  --accent-strong: #0b4b82;
  --danger: #a33b2b;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 650;
}

#subtitle,
.muted {
  color: var(--muted);
}

.topbar-actions,
.panel-header,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.signed-out-panel {
  display: grid;
  min-height: min(360px, calc(100vh - 150px));
  place-items: center;
}

.signed-out-panel button {
  min-height: 44px;
  padding: 0 22px;
  font-size: 17px;
}

.identity {
  color: var(--muted);
  font-size: 14px;
}

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  border-color: #b9c1ce;
  background: #c8ced8;
  cursor: not-allowed;
}

button.secondary {
  border-color: var(--border);
  background: white;
  color: var(--text);
}

button.secondary:hover {
  background: #eef2f7;
}

main {
  display: grid;
  gap: 16px;
}

[hidden] {
  display: none !important;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 12px;
  min-width: 0;
}

.operation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.operation-grid:has(.section-detail-header) {
  grid-template-columns: 1fr;
}

.operation {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  min-height: 160px;
  min-width: 0;
}

.section-card {
  min-height: 140px;
}

.operation h3 {
  margin: 0;
  font-size: 16px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.route-status span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.route-status.enabled {
  border-color: #78a878;
  color: #2f6b35;
}

.route-status.enabled span {
  background: #2f9e44;
}

.route-status.disabled {
  border-color: #d08378;
  color: #9a3427;
}

.route-status.disabled span {
  background: #d43c2f;
}

.route-status.unknown {
  border-color: #d6a84b;
  color: #7a5612;
}

.route-status.unknown span {
  background: #d6a84b;
}

.operation p {
  color: var(--muted);
  line-height: 1.4;
}

.operation-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
}

.chip.medium {
  border-color: #d6a84b;
  color: #7a5612;
}

.chip.low {
  border-color: #78a878;
  color: #2f6b35;
}

.operation footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.section-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.section-detail-header h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.section-detail-header p {
  color: var(--muted);
  line-height: 1.4;
}

.action-row {
  grid-template-columns: 1fr;
  min-height: 0;
}

.action-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.action-controls {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center !important;
  gap: 12px !important;
}

.action-controls .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-controls button {
  justify-self: end;
}

.back-button {
  align-self: start;
  justify-self: start;
}

.output {
  min-width: 0;
  min-height: 90px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #101827;
  color: #d9e4f2;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 51, 0.45);
}

dialog form {
  display: grid;
  gap: 14px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .panel-header,
  .section-detail-header,
  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .signed-out-panel {
    min-height: min(300px, calc(100vh - 120px));
  }

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

  .action-controls {
    grid-template-columns: 1fr auto;
  }
}
