html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: auto;
}

/* Shared Simbad dashboard styles */
* { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 1rem 1.25rem 2rem;
  background: #f4f6f8;
  color: #1e293b;
  overflow-x: auto;
  min-width: 0;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  flex: 1;
}

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: #e8ecf0;
  border-radius: 12px;
  text-decoration: none;
}

.back img {
  height: 26px;
  width: auto;
  object-fit: contain;
  display: block;
}

.panel {
  background: #fff;
  border: 1px solid #d8dee6;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  margin-bottom: 1rem;
}

.panel:last-child {
  margin-bottom: 0;
}

/* Touch-friendly buttons (min 48px tap target) */
.btn,
button.btn,
.nav a,
.toolbar a.btn {
  text-decoration: none;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.btn:hover,
button.btn:hover,
.nav a:hover,
.toolbar a.btn:hover {
  background: #eef2f7;
}

.btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: #eef2f7;
}

.btn-icon img {
  width: 28px;
  height: 28px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.toolbar .spacer {
  flex: 1;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e8ecf0;
}

/* Dashboard gauges — two per row on phones */
.gauge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.gauge-card {
  background: #f8fafc;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 0.35rem 0.5rem 0.35rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  min-width: 0;
  overflow: visible;
}

.gauge-card-title {
  margin: 0 0 0.15rem;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gauge-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07);
  transform: translateY(-1px);
}

.gauge {
  width: 100%;
  min-width: 0;
  aspect-ratio: 2 / 1;
  max-height: 7rem;
  overflow: hidden;
}

.gauge-card[hidden] {
  display: none;
}

.gauge svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (min-width: 640px) {
  .gauge-grid {
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem;
  }

  .gauge-card {
    padding: 0.35rem 0.5rem 0.5rem;
  }

  .gauge-card-title {
    font-size: 0.9375rem;
  }

  .gauge {
    max-height: 8.5rem;
  }
}

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border: 1px solid #e2e8f0;
  padding: 0.65rem 0.85rem;
  text-align: left;
}

.data-table th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  font-size: 0.9rem;
}

.data-table tr:nth-child(even) td {
  background: #f8fafc;
}

.data-table td {
  font-size: 0.95rem;
}

/* Control toggles */
.control-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid #e8ecf0;
  min-height: 64px;
}

.control-item:last-child {
  border-bottom: none;
}

.control-label {
  font-size: 1.1rem;
  font-weight: 500;
  color: #334155;
}

.onoffswitch {
  position: relative;
  width: 110px;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

.onoffswitch-checkbox {
  display: none;
}

.onoffswitch-label {
  display: block;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #cbd5e1;
  border-radius: 24px;
}

.onoffswitch-inner {
  display: block;
  width: 200%;
  margin-left: -100%;
  transition: margin 0.3s ease-in 0s;
}

.onoffswitch-inner:before,
.onoffswitch-inner:after {
  display: block;
  float: left;
  width: 50%;
  height: 44px;
  padding: 0;
  line-height: 44px;
  font-size: 0.95rem;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 600;
  box-sizing: border-box;
}

.onoffswitch-inner:before {
  content: "ON";
  padding-left: 14px;
  background-color: #2563eb;
}

.onoffswitch-inner:after {
  content: "OFF";
  padding-right: 14px;
  background-color: #e2e8f0;
  color: #64748b;
  text-align: right;
}

.onoffswitch-switch {
  display: block;
  width: 36px;
  height: 36px;
  margin: 4px;
  background: #fff;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 62px;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  transition: all 0.3s ease-in 0s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
  margin-left: 0;
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
  right: 0;
}

/* Map — full viewport height on all screen sizes */
body.map-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

body.map-page header {
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.map-page .page {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: none;
  min-height: 0;
}

.map-toolbar {
  flex-shrink: 0;
}

.map-toolbar .daytext {
  font-size: 1.1rem;
  font-weight: 600;
  color: #334155;
  padding: 0 0.25rem;
}

.map-toolbar .daydist {
  font-size: 0.95rem;
  color: #64748b;
  width: 100%;
  margin-top: 0.25rem;
}

.map-panel {
  padding: 0;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: calc(100vh - 12rem);
  min-height: calc(100dvh - 12rem);
  display: flex;
  flex-direction: column;
}

#map-canvas {
  flex: 1;
  width: 100%;
  min-height: 300px;
}

#legend {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d8dee6;
  border-radius: 8px;
  padding: 4px;
  font-size: 0.8rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

#legend div {
  padding: 4px 8px;
  color: #fff;
  font-size: 0.85rem;
}

.toolbar .hint {
  margin-left: auto;
  font-size: 0.8rem;
  color: #64748b;
}

@media (max-width: 600px) {
  body {
    padding: 0.5rem;
  }

  .panel {
    padding: 0.75rem;
  }

  header h1 {
    font-size: 1.25rem;
  }

  .btn,
  .nav a {
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
  }

  .nav a {
    min-width: 100%;
  }

  .toolbar {
    justify-content: center;
  }

  .toolbar .hint {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }
}

/* Charts */
#chart-wrap,
#statchart-wrap {
  width: 100%;
  min-height: 320px;
}

#statchart-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.status {
  color: #64748b;
  font-size: 0.9rem;
  padding: 2rem 0;
  text-align: center;
}
