:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #17211f;
  --muted: #61706b;
  --line: #dce6e2;
  --brand: #087568;
  --brand-2: #0e8f74;
  --blue: #315ecf;
  --ok: #11845b;
  --ok-bg: #e4f6ed;
  --warn: #ad6a00;
  --warn-bg: #fff0d1;
  --bad: #b83232;
  --bad-bg: #ffe2e2;
  --maint: #4f46a5;
  --maint-bg: #ecebff;
  --shadow: 0 18px 55px rgba(23, 33, 31, 0.1);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(49, 94, 207, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.icon-sprite {
  display: none;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 18px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(244, 247, 246, 0.88);
  border-bottom: 1px solid rgba(220, 230, 226, 0.84);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand small,
.sync-stamp {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.sync-stamp {
  min-width: 150px;
  text-align: right;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.danger-ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

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

.primary-button:hover {
  background: var(--brand-2);
}

.secondary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button:hover {
  background: #263430;
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover {
  border-color: #b9c7c2;
}

.danger-button {
  background: var(--bad);
  color: #fff;
}

.danger-button:hover {
  background: #9f2424;
}

.danger-ghost-button {
  background: #fff;
  color: var(--bad);
  border-color: #f1b4b4;
}

.danger-ghost-button:hover {
  background: var(--bad-bg);
}

.icon-text {
  gap: 8px;
}

main {
  padding: 22px clamp(16px, 3vw, 34px) 42px;
}

.overview-band {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: clamp(18px, 4vw, 48px);
  align-items: stretch;
  padding: clamp(22px, 4vw, 42px);
  background: linear-gradient(135deg, #fdfefe 0%, #edf7f4 56%, #f7fbff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.overview-copy {
  align-self: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 740px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 4.5vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
  letter-spacing: 0;
}

.overview-copy p {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.system-map {
  position: relative;
  min-height: 260px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(8, 117, 104, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(49, 94, 207, 0.08) 1px, transparent 1px),
    #ffffff;
  background-size: 44px 44px;
  border: 1px solid var(--line);
  overflow: hidden;
}

.map-route {
  position: absolute;
  inset: 52px 34px 70px;
  border: 3px solid rgba(8, 117, 104, 0.26);
  border-left-style: dashed;
  border-radius: 36px;
}

.map-node {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 82px;
  min-height: 34px;
  border: 1px solid rgba(8, 117, 104, 0.25);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(23, 33, 31, 0.08);
}

.node-app {
  left: 28px;
  top: 34px;
}

.node-api {
  right: 34px;
  top: 48px;
}

.node-iot {
  left: 24%;
  bottom: 32px;
}

.node-pay {
  right: 18%;
  bottom: 46px;
}

.map-scooter {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 150px;
  height: 88px;
  transform: translate(-50%, -50%);
}

.scooter-base,
.handle {
  position: absolute;
  background: var(--ink);
  border-radius: 999px;
}

.scooter-base {
  left: 25px;
  right: 18px;
  bottom: 26px;
  height: 8px;
}

.handle {
  right: 34px;
  top: 16px;
  width: 8px;
  height: 52px;
  transform: rotate(-12deg);
  transform-origin: bottom center;
}

.handle::before {
  content: "";
  position: absolute;
  right: -18px;
  top: 0;
  width: 30px;
  height: 7px;
  background: var(--brand);
  border-radius: 999px;
}

.wheel {
  position: absolute;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border: 7px solid var(--brand);
  border-radius: 50%;
  background: #fff;
}

.wheel-left {
  left: 16px;
}

.wheel-right {
  right: 6px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.page-section {
  margin-top: 18px;
}

.metric {
  min-height: 116px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 2.8vw, 2.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.admin-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: stretch;
  padding: clamp(22px, 4vw, 34px);
  background: linear-gradient(135deg, #fdfefe 0%, #edf7f4 62%, #f7fbff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-hero h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.admin-hero p {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
}

.pin-box {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.pin-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.status-workspace,
.operator-panel,
.incident-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-workspace {
  padding: 18px;
}

.operator-panel {
  position: sticky;
  top: 94px;
  padding: 18px;
}

.admin-panel {
  position: static;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.search-input,
.select-input,
input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

input,
select,
textarea {
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.search-input {
  width: min(300px, 34vw);
  padding: 10px 12px;
}

.select-input {
  width: 190px;
  padding: 10px 12px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.system-list {
  display: grid;
  gap: 12px;
}

.admin-system-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.admin-system-item h3 {
  margin: 0 0 5px;
  font-size: 1.05rem;
}

.admin-system-item p {
  margin-bottom: 8px;
  color: var(--muted);
}

.admin-system-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 360px;
}

.system-card {
  display: grid;
  gap: 14px;
  min-height: 230px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.system-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.system-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.system-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill,
.severity-pill,
.incident-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-operational {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-degraded {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-partial_outage,
.status-outage {
  background: var(--bad-bg);
  color: var(--bad);
}

.status-maintenance {
  background: var(--maint-bg);
  color: var(--maint);
}

.system-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini-metric {
  min-height: 76px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mini-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
}

.system-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.form-stack:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.form-stack label,
.segmented legend,
.pin-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.confirm-line {
  display: flex !important;
  grid-template-columns: none;
  align-items: flex-start;
  color: var(--ink) !important;
}

.confirm-line input {
  width: auto;
  min-height: auto;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  font-size: 0.82rem;
}

.segmented input:checked + span {
  border-color: var(--brand);
  background: #e2f6f1;
  color: var(--brand);
}

.incident-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.incident-column {
  min-height: 320px;
  padding: 18px;
}

.incident-list,
.activity-list,
.public-incident-list,
.fault-list {
  display: grid;
  gap: 12px;
}

.incident-card,
.activity-item,
.public-incident,
.fault-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.incident-searchbar {
  margin-bottom: 12px;
}

.public-incident {
  overflow: hidden;
}

.public-incident summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.public-incident summary::-webkit-details-marker {
  display: none;
}

.incident-summary-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.incident-summary-main strong {
  overflow: hidden;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-summary-main small,
.last-update {
  color: var(--muted);
}

.incident-summary-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 800;
}

.public-incident-body {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
}

.public-incident-body p {
  margin-bottom: 0;
}

.incident-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.fault-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
}

.fault-item h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.fault-item p {
  margin-bottom: 8px;
  color: var(--muted);
}

.fault-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 360px;
}

.incident-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.incident-card h3 {
  margin-bottom: 4px;
}

.incident-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.severity-minor {
  background: var(--warn-bg);
  color: var(--warn);
}

.severity-major,
.severity-critical {
  background: var(--bad-bg);
  color: var(--bad);
}

.timeline {
  display: grid;
  gap: 10px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 3px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.timeline-item strong,
.activity-item strong {
  font-size: 0.9rem;
}

.timeline-item span,
.activity-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.timeline-item p,
.activity-item p {
  margin-bottom: 0;
}

.activity-item,
.empty-state {
  padding: 14px;
}

.empty-state {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

@media (max-width: 1180px) {
  .main-layout,
  .incident-layout,
  .admin-grid,
  .admin-hero {
    grid-template-columns: 1fr;
  }

  .operator-panel {
    position: static;
  }
}

@media (max-width: 840px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .sync-stamp {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .overview-band {
    grid-template-columns: 1fr;
  }

  .pin-actions,
  .admin-system-item,
  .fault-item,
  .public-incident summary {
    grid-template-columns: 1fr;
  }

  .admin-system-actions,
  .fault-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .metric-row,
  .system-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input,
  .select-input {
    width: 100%;
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 12px;
  }

  .overview-band,
  .status-workspace,
  .operator-panel,
  .incident-column {
    padding: 14px;
  }

  .form-grid,
  .system-metrics,
  .segmented {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button,
  .danger-ghost-button {
    width: 100%;
  }
}
