:root {
  color-scheme: dark;
  --bg: #070b18;
  --bg-deep: #040711;
  --panel: rgba(15, 23, 42, 0.88);
  --panel-strong: rgba(10, 16, 31, 0.96);
  --panel-soft: rgba(22, 33, 55, 0.72);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(45, 212, 191, 0.38);
  --text: #f8fafc;
  --muted: #93a4ba;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --green: #34d399;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #fb7185;
  --pink: #f472b6;
  --blue: #60a5fa;
  --purple: #c084fc;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius: 18px;
  --font-sans: "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Orbitron", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 16% 0%, rgba(8, 145, 178, 0.12), transparent 30rem),
    radial-gradient(circle at 92% 12%, rgba(190, 24, 93, 0.09), transparent 30rem),
    linear-gradient(145deg, #070b18 0%, #080d1d 46%, #050812 100%);
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  opacity: 0.16;
  filter: blur(90px);
  pointer-events: none;
}

.page-glow-a {
  top: -12rem;
  left: 8%;
  background: var(--cyan);
}

.page-glow-b {
  right: -10rem;
  bottom: -12rem;
  background: var(--pink);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 14px clamp(18px, 2.3vw, 38px);
  border-bottom: 1px solid rgba(244, 114, 182, 0.2);
  background: rgba(5, 9, 20, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(45, 212, 191, 0.55);
  border-radius: 14px;
  color: #061018;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  background: linear-gradient(145deg, var(--cyan), var(--teal));
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.24);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(17px, 1.5vw, 23px);
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand em {
  color: var(--pink);
  font-style: normal;
}

.brand small {
  margin-top: 3px;
  color: #8292aa;
  font-size: 11px;
  letter-spacing: 0.15em;
}

.topbar-status,
.toolbar,
.toolbar-actions,
.policy-note,
.zone-control {
  display: flex;
  align-items: center;
}

.topbar-status {
  justify-content: flex-end;
  gap: 9px;
}

.badge,
.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(15, 23, 42, 0.72);
  white-space: nowrap;
}

.badge-demo {
  border-color: rgba(250, 204, 21, 0.28);
  color: #fde68a;
  background: rgba(113, 63, 18, 0.28);
}

.badge-live {
  border-color: rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
  background: rgba(6, 78, 59, 0.28);
}

.connection-pill {
  gap: 7px;
}

.connection-pill.is-online {
  border-color: rgba(52, 211, 153, 0.34);
  color: #a7f3d0;
}

.connection-pill.is-degraded {
  border-color: rgba(250, 204, 21, 0.34);
  color: #fde68a;
}

.connection-pill.is-offline {
  border-color: rgba(251, 113, 133, 0.38);
  color: #fecdd3;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 10px currentColor;
}

.is-online .status-dot {
  background: var(--green);
}

.is-degraded .status-dot {
  background: var(--yellow);
}

.is-offline .status-dot {
  background: var(--red);
}

.is-loading .status-dot {
  animation: blink 1.2s infinite;
}

.clock {
  min-width: 78px;
  color: #94a3b8;
  font-family: var(--font-display);
  font-size: 12px;
  text-align: right;
}

.toolbar {
  position: relative;
  z-index: 15;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 9px clamp(18px, 2.3vw, 38px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 13, 29, 0.84);
  backdrop-filter: blur(14px);
}

.zone-control {
  gap: 9px;
}

.zone-control label,
.toolbar-actions,
.policy-note {
  color: var(--muted);
  font-size: 12px;
}

select,
input {
  min-height: 40px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  outline: none;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.92);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

select {
  min-width: 154px;
  padding: 0 34px 0 12px;
}

input {
  width: 100%;
  padding: 0 12px;
}

select:focus,
input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

.policy-note {
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(34, 211, 238, 0.14);
  border-radius: 10px;
  background: rgba(8, 145, 178, 0.07);
}

.policy-note strong {
  color: #a5f3fc;
}

.policy-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(8, 145, 178, 0.14);
}

.toolbar-actions {
  justify-content: flex-end;
  gap: 12px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-button {
  padding: 7px 12px;
  border-color: rgba(45, 212, 191, 0.25);
  color: #99f6e4;
  background: rgba(13, 148, 136, 0.1);
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.icon-button.is-spinning span {
  animation: spin 0.75s linear infinite;
}

.primary-button {
  padding: 9px 15px;
  color: #051319;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  box-shadow: 0 10px 22px rgba(13, 148, 136, 0.16);
}

.secondary-button {
  padding: 9px 15px;
  border-color: rgba(96, 165, 250, 0.28);
  color: #bfdbfe;
  background: rgba(30, 64, 175, 0.12);
}

.danger-button {
  padding: 9px 15px;
  border-color: rgba(251, 113, 133, 0.3);
  color: #fecdd3;
  background: rgba(159, 18, 57, 0.18);
}

.text-button {
  min-height: 32px;
  padding: 5px 9px;
  color: #67e8f9;
  background: transparent;
}

.text-button:hover {
  background: rgba(8, 145, 178, 0.1);
}

.app-shell {
  width: min(1880px, 100%);
  min-height: calc(100vh - 188px);
  margin: 0 auto;
  padding: clamp(14px, 1.6vw, 26px) clamp(14px, 2vw, 32px) 26px;
}

.loading-panel,
.error-panel {
  display: grid;
  min-height: 58vh;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.loading-bike {
  font-size: 48px;
  animation: float 1.8s ease-in-out infinite;
}

.error-panel strong {
  color: #fecdd3;
  font-size: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(17, 27, 48, 0.9), rgba(8, 14, 28, 0.94));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.metric-card {
  position: relative;
  min-height: 108px;
  padding: 16px;
  overflow: hidden;
  border-radius: 15px;
}

.metric-card::after {
  position: absolute;
  right: -28px;
  bottom: -50px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--metric-color, var(--cyan));
  content: "";
  opacity: 0.08;
  filter: blur(4px);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #93a4ba;
  font-size: 12px;
}

.metric-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--metric-color, var(--cyan));
  background: color-mix(in srgb, var(--metric-color, var(--cyan)) 12%, transparent);
}

.metric-value {
  margin-top: 7px;
  color: #f8fafc;
  font-family: var(--font-display);
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 700;
}

.metric-note {
  margin-top: 3px;
  color: #718198;
  font-size: 11px;
}

.metric-card.is-alert .metric-value,
.metric-card.is-alert .metric-note {
  color: #fda4af;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(320px, 0.72fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  overflow: hidden;
  border-radius: var(--radius);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

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

.map-panel {
  min-height: 580px;
}

.map-canvas {
  position: relative;
  min-height: 514px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(4, 10, 23, 0.44), rgba(4, 10, 23, 0.68)),
    url("../img/map_base.jpg") center / cover no-repeat,
    #0b1324;
}

.map-canvas::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  content: "";
  mix-blend-mode: screen;
}

.map-overlay {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.geofence-area {
  fill: rgba(45, 212, 191, 0.1);
  stroke: rgba(94, 234, 212, 0.92);
  stroke-width: 0.45;
  stroke-dasharray: 1.4 0.85;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(45, 212, 191, 0.55));
}

.map-label {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  max-width: calc(100% - 28px);
  padding: 8px 11px;
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 10px;
  color: #99f6e4;
  font-size: 11px;
  background: rgba(4, 10, 23, 0.8);
  backdrop-filter: blur(10px);
}

.map-marker {
  position: absolute;
  z-index: 6;
  display: grid;
  padding: 0;
  place-items: center;
  border: 0;
  transform: translate(-50%, -50%);
  background: transparent;
}

.map-marker:hover,
.map-marker:focus-visible {
  z-index: 12;
}

.station-marker {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(103, 232, 249, 0.72);
  border-radius: 15px 15px 15px 4px;
  color: #083344;
  background: linear-gradient(145deg, #67e8f9, #2dd4bf);
  box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.09), 0 8px 22px rgba(0, 0, 0, 0.42);
  transform: translate(-50%, -50%) rotate(-45deg);
}

.station-marker > span:first-child {
  font-size: 21px;
  transform: rotate(45deg);
}

.station-marker.is-offline {
  border-color: #fda4af;
  background: linear-gradient(145deg, #fb7185, #be123c);
}

.marker-label {
  position: absolute;
  top: 49px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: max-content;
  padding: 6px 9px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 10px;
  background: rgba(3, 7, 18, 0.88);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%) rotate(45deg);
  pointer-events: none;
}

.marker-count {
  color: #67e8f9;
  font-family: var(--font-display);
}

.bike-marker {
  width: 26px;
  height: 26px;
  border: 2px solid #d1fae5;
  border-radius: 50%;
  color: #052e2b;
  font-size: 13px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12), 0 6px 14px rgba(0, 0, 0, 0.4);
}

.bike-marker.state-in_use {
  border-color: #cffafe;
  background: var(--cyan);
  animation: bike-pulse 2s infinite;
}

.bike-marker.state-maintenance {
  border-color: #fef3c7;
  background: var(--yellow);
}

.bike-marker.is-offline,
.bike-marker.is-unbound {
  border-color: #cbd5e1;
  background: #64748b;
}

.bike-marker.is-outside {
  border-color: #ffe4e6;
  background: var(--red);
  animation: danger-pulse 1.2s infinite;
}

.bike-tag {
  position: absolute;
  top: 29px;
  left: 50%;
  display: none;
  min-width: max-content;
  padding: 4px 7px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 9px;
  background: rgba(3, 7, 18, 0.9);
  transform: translateX(-50%);
}

.bike-marker:hover .bike-tag,
.bike-marker:focus-visible .bike-tag,
.bike-marker.is-outside .bike-tag {
  display: block;
}

.map-legend {
  position: absolute;
  z-index: 8;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 12px;
  max-width: calc(100% - 28px);
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  color: #a8b5c8;
  font-size: 9px;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(9px);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--legend-color);
  box-shadow: 0 0 6px var(--legend-color);
}

.side-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.side-column > .panel {
  flex: 1;
}

.panel-body {
  padding: 15px;
}

.station-stack,
.alert-stack,
.bike-stack,
.zone-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-card,
.alert-card,
.bike-card,
.zone-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.58);
}

.station-card,
.zone-card {
  padding: 13px;
}

.card-row,
.station-head,
.bike-head,
.alert-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.station-name,
.bike-name,
.alert-title {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 700;
}

.station-code,
.bike-code,
.alert-meta {
  margin-top: 3px;
  color: #718198;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  color: #cbd5e1;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip.online,
.status-chip.available,
.status-chip.in_bounds {
  border-color: rgba(52, 211, 153, 0.3);
  color: #a7f3d0;
  background: rgba(6, 78, 59, 0.2);
}

.status-chip.offline,
.status-chip.out_of_bounds,
.status-chip.critical {
  border-color: rgba(251, 113, 133, 0.32);
  color: #fecdd3;
  background: rgba(136, 19, 55, 0.2);
}

.status-chip.in_use {
  border-color: rgba(34, 211, 238, 0.3);
  color: #a5f3fc;
  background: rgba(8, 145, 178, 0.16);
}

.status-chip.maintenance,
.status-chip.warning,
.status-chip.unbound,
.status-chip.degraded {
  border-color: rgba(250, 204, 21, 0.3);
  color: #fde68a;
  background: rgba(113, 63, 18, 0.2);
}

.station-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.mini-count {
  padding: 8px 6px;
  border-radius: 9px;
  color: #8292aa;
  font-size: 9px;
  text-align: center;
  background: rgba(4, 10, 23, 0.5);
}

.mini-count strong {
  display: block;
  margin-bottom: 2px;
  color: #e2e8f0;
  font-family: var(--font-display);
  font-size: 16px;
}

.offline-copy {
  margin-top: 9px;
  color: #fb7185;
  font-size: 10px;
}

.alert-card {
  padding: 12px;
  border-left: 3px solid var(--yellow);
}

.alert-card.critical {
  border-left-color: var(--red);
  background: linear-gradient(100deg, rgba(159, 18, 57, 0.16), rgba(15, 23, 42, 0.58));
}

.alert-card.is-acknowledged {
  opacity: 0.52;
}

.alert-message {
  margin: 8px 0 0;
  color: #9aabc0;
  font-size: 11px;
  line-height: 1.65;
}

.alert-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.empty-state {
  display: grid;
  min-height: 140px;
  padding: 20px;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: #8292aa;
  font-size: 12px;
  text-align: center;
}

.empty-state strong {
  color: #a7f3d0;
  font-size: 14px;
}

.action-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 13px;
  border: 1px solid rgba(45, 212, 191, 0.2);
  border-radius: 13px;
  background: rgba(13, 148, 136, 0.08);
}

.action-banner p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.data-panel {
  margin-top: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 11px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: #718198;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(3, 7, 18, 0.36);
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(8, 145, 178, 0.06);
}

.cell-main {
  color: #e2e8f0;
  font-weight: 700;
}

.cell-sub {
  display: block;
  margin-top: 3px;
  color: #718198;
  font-size: 9px;
}

.mono {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.battery {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.battery-bar {
  width: 42px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.battery-bar span {
  display: block;
  width: var(--battery, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.battery.is-low .battery-bar span {
  background: var(--red);
}

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

.zone-card {
  position: relative;
  overflow: hidden;
}

.zone-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: var(--green);
  content: "";
}

.zone-card.status-degraded::after {
  background: var(--yellow);
}

.zone-card.status-alert::after {
  background: var(--red);
}

.zone-card strong {
  font-size: 14px;
}

.zone-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 11px;
}

.zone-kpis span {
  color: #718198;
  font-size: 8px;
  text-align: center;
}

.zone-kpis b {
  display: block;
  margin-bottom: 2px;
  color: #e2e8f0;
  font-family: var(--font-display);
  font-size: 14px;
}

.toast-region {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 22px;
  display: flex;
  width: min(360px, calc(100vw - 40px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid rgba(45, 212, 191, 0.32);
  border-radius: 12px;
  color: #d5fbf4;
  font-size: 12px;
  background: rgba(6, 34, 40, 0.94);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.24s ease both;
}

.toast.error {
  border-color: rgba(251, 113, 133, 0.38);
  color: #ffe4e6;
  background: rgba(76, 5, 25, 0.94);
}

.modal {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: 18px;
  color: var(--text);
  background: #0b1324;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.68);
}

.modal::backdrop {
  background: rgba(1, 4, 12, 0.78);
  backdrop-filter: blur(5px);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px;
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.65);
}

.modal-body {
  max-height: calc(100vh - 180px);
  padding: 17px;
  overflow-y: auto;
}

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

.form-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  color: #9aabc0;
  font-size: 11px;
}

.form-field small {
  color: #65758b;
  font-size: 9px;
  line-height: 1.5;
}

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

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.48);
}

.detail-item span,
.detail-item strong {
  display: block;
}

.detail-item span {
  margin-bottom: 4px;
  color: #718198;
  font-size: 9px;
}

.detail-item strong {
  overflow-wrap: anywhere;
  color: #e2e8f0;
  font-size: 12px;
}

.policy-box {
  margin-top: 13px;
  padding: 12px;
  border: 1px solid rgba(250, 204, 21, 0.24);
  border-radius: 11px;
  color: #fde68a;
  font-size: 11px;
  line-height: 1.6;
  background: rgba(113, 63, 18, 0.14);
}

.rent-bike-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rent-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #dbeafe;
  text-align: left;
  background: rgba(15, 23, 42, 0.55);
}

.rent-option:hover {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(13, 148, 136, 0.08);
}

body.role-user .admin-only,
body.role-user .guard-only,
body.role-guard .admin-only,
body.role-controlroom .admin-only,
body.role-controlroom .guard-only {
  display: none !important;
}

body.role-user .clock {
  display: none;
}

body.role-controlroom {
  cursor: none;
}

body.role-controlroom .toolbar {
  min-height: 52px;
}

body.role-controlroom .app-shell {
  max-width: none;
  min-height: calc(100vh - 130px);
}

body.role-controlroom #global-footer {
  display: none;
}

@keyframes blink {
  50% {
    opacity: 0.28;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes float {
  50% {
    transform: translateY(-8px);
  }
}

@keyframes bike-pulse {
  50% {
    box-shadow: 0 0 0 9px rgba(34, 211, 238, 0.03), 0 6px 14px rgba(0, 0, 0, 0.4);
  }
}

@keyframes danger-pulse {
  50% {
    box-shadow: 0 0 0 10px rgba(251, 113, 133, 0.05), 0 0 22px rgba(251, 113, 133, 0.75);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-status {
    flex-wrap: wrap;
  }

  .source-badge,
  .clock {
    display: none;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .policy-note {
    order: 3;
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 510px;
  }

  .map-canvas {
    min-height: 445px;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 68px;
    padding: 11px 13px;
  }

  .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand strong {
    max-width: 48vw;
    font-size: 15px;
  }

  .brand small,
  #role-badge {
    display: none;
  }

  .connection-pill {
    padding: 5px 8px;
    font-size: 9px;
  }

  .toolbar {
    gap: 8px;
    padding: 8px 13px;
  }

  .zone-control {
    flex: 1;
  }

  .zone-control label,
  #last-updated {
    display: none;
  }

  .zone-control select {
    width: 100%;
    min-width: 0;
  }

  .toolbar-actions {
    flex: 0 0 auto;
  }

  .policy-note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell {
    padding: 11px 10px 22px;
  }

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

  .metric-card {
    min-height: 94px;
    padding: 12px;
  }

  .metric-card:last-child {
    grid-column: 1 / -1;
  }

  .metric-value {
    font-size: 25px;
  }

  .map-panel {
    min-height: 440px;
  }

  .map-canvas {
    min-height: 374px;
  }

  .panel-header {
    padding: 13px;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .panel-header:has(.panel-actions) {
    flex-wrap: wrap;
  }

  .station-marker {
    width: 39px;
    height: 39px;
  }

  .marker-label {
    top: 43px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bike-marker {
    width: 24px;
    height: 24px;
  }

  .map-legend {
    left: 10px;
    right: 10px;
    bottom: 10px;
    justify-content: flex-start;
  }

  .zone-grid,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-field.full {
    grid-column: auto;
  }

  .action-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .action-banner .primary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
