:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --ink: #1c2833;
  --muted: #5c7183;
  --primary: #0947c0;
  --primary-soft: #ddf1fa;
  --ok: #006f3c;
  --bad: #bf212f;
  --border: #d9e3eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Consolas", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #e5f3ff 0%, #eef3f8 45%, #f8fbfd 100%);
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(6, 27, 44, 0.08);
}

.topbar {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: linear-gradient(130deg, #ffffff, #edf6fc);
}

.title-group h1 {
  margin: 0;
  font-size: 1.22rem;
}

.title-group p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.mode-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f2f7fb;
  color: var(--ink);
  padding: 6px 11px;
  cursor: pointer;
  font-weight: 600;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
}

.mode-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#baseDate {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(20%, 25%) 1fr;
  gap: 12px;
  min-height: 0;
}

.sidebar {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.primary-btn {
  width: 100%;
  font-size:medium;
  border: none;
  border-radius: 10px;
  background: #0947c0;
  color: #fff;
  padding: 11px;
  cursor: pointer;
  font-weight: 700;
}

.status {
  min-height: 20px;
  font-size: 0.85rem;
  color: var(--primary);
  margin-top: 5px;
}

.metric {
  font-size: 1.45rem;
  font-weight: 700;
}

.metric.ok {
  color: var(--ok);
}

.metric.bad {
  color: var(--bad);
}

.subtext {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.history-head h2 {
  margin: 0;
  font-size: 1rem;
}

.delete-cell {
    align-content:  right;
    align-items: right;
}

.history-top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

#entries {
  width: 74px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 7px;
}

.danger-btn {
  border: none;
  border-radius: 8px;
  background: var(--bad);
  color: #fff;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.77rem;
  font-weight: 700;
}

.table-wrap {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: calc(100vh - 290px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 300px;
}

th,
td {
  padding: 4px 3px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f6fbff;
  text-align: left;
  font-size: 0.72rem;
  color: var(--muted);
}

.speed-ok {
  color: var(--ok);
  font-weight: 700;
}

.speed-bad {
  color: var(--bad);
  font-weight: 700;
}

.content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.content-head h2 {
  margin: 0;
}

.content-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff, #f7fbfe);
}

#speedChart {
  width: 100% !important;
  height: min(54vh, 500px) !important;
}

.legend {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  background: #fcfeff;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-dot {
  width: 20px;
  height: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 32, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  margin: 0;
}

.close-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

.modal-form {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.modal-form label {
  font-size: 0.83rem;
  color: var(--muted);
}

.modal-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

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

.quick-actions{
    justify-items: center;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: 300px;
  }

  #speedChart {
    height: 360px !important;
  }
}
