/* Air Quality Observatory: what every page shares. Colours and sizes are the variables
   in :root; each page adds its own file (map.css, data-manager.css, about.css, survey.css). */
:root {
  --navy: #173049;
  --navy-2: #1e3c58;
  --navy-text: #c9d6e2;
  --teal: #178a94;
  --teal-strong: #0f727b;
  --teal-soft: #dff1f2;
  --violet: #8a6be3;
  --violet-soft: #b9a6f0;
  --green: #2c9a56;
  --amber: #c98a12;
  --red: #c2413a;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --line: #e1e8ee;
  --line-strong: #cbd5de;
  --ink: #132a3e;
  --ink-2: #3d5163;
  --muted: #6a7b8a;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(19, 42, 62, .06);
  --font: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--teal-strong); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell */
.shell { --side-w: 236px; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh;
         background: linear-gradient(90deg, var(--navy) var(--side-w), var(--bg) var(--side-w)); transition: grid-template-columns .2s ease; }

/* Collapsed sidebar: a narrow strip of icons. The link text is hidden by setting its size
   to nothing (the icons have their own size), so the links themselves are unchanged. */
.nav-collapsed .shell { --side-w: 68px; }
.nav-collapsed .brand { display: none; }
.nav-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
.nav-collapsed .nav a, .nav-collapsed .nav-action { font-size: 0; gap: 0; justify-content: center; padding: 13px 0; }
.nav-toggle svg { transform: rotate(180deg); transition: transform .2s; }
.nav-collapsed .nav-toggle svg { transform: none; }
.nav-toggle { margin-top: 4px; }
.shell-login { grid-template-columns: 1fr; background: radial-gradient(circle at top right, var(--teal-soft), var(--bg) 42%); }
.sidebar { background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 20px 10px 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: block; padding: 0 2px 30px; text-decoration: none; color: #fff; }
.brand-logo { display: block; width: 100%; max-width: 212px; height: auto; border-radius: 3px; }
.badge-demo { display: inline-block; margin-top: 8px; background: #2c5575; color: #e3eef6; font-size: 12px; padding: 1px 9px; border-radius: 5px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { white-space: nowrap; display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-radius: 8px; color: var(--navy-text); text-decoration: none; font-size: 16px; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--teal); color: #fff; font-weight: 600; }
.nav svg { width: 22px; height: 22px; flex: none; }
.nav-bottom { margin-top: auto; }
.nav-action { width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 16px; border: 0; border-radius: 8px; color: var(--navy-text); background: transparent; font: inherit; font-size: 16px; cursor: pointer; }
.nav-action:hover { background: var(--navy-2); color: #fff; }
.nav-action svg { width: 22px; height: 22px; }

.main { padding: 22px 28px 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 36px; line-height: 1.05; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 16px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); padding: 10px 20px; font-size: 16px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--teal); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--teal); color: #fff; border-color: var(--teal); font-weight: 600; }
.btn-primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); }
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-quiet { background: #eef3f6; }
.btn-danger { color: var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; color: var(--ink-2); }
.input, .select { height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 0 12px; min-width: 0; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23132a3e' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-2); pointer-events: none; }
.input-icon .input { padding-left: 40px; width: 100%; }


.switch { position: relative; width: 52px; height: 30px; border-radius: 15px; border: 0; background: #c3ced7; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* ---------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h2, .card h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.card h2 { font-size: 22px; }
.card h3 { font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }


.stat { padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: start; }
.stat svg { width: 22px; height: 22px; grid-row: span 3; color: var(--ink-2); margin-top: 2px; }
.stat-label { font-size: 14px; color: var(--ink-2); }
.stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; font-weight: 600; }
.stat-sub { font-size: 12.5px; color: var(--muted); }

.status-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--green); margin-right: 8px; vertical-align: -1px; }
.status-dot.warn { background: var(--amber); }
.status-dot.fail { background: var(--red); }
.status-dot.run { background: var(--teal); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status-dot.run { animation: none; } * { transition: none !important; } }

/* ---------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 15.5px; }
table.data th { text-align: left; font-weight: 600; background: #f1f5f8; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { font-variant-numeric: tabular-nums; }
table.sensors .num { text-align: right; }
table.sensors td { white-space: nowrap; }
table.data input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); }
.file-cell { display: flex; align-items: center; gap: 14px; }
.file-cell svg { color: var(--violet); width: 26px; height: 26px; flex: none; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--ink); display: inline-grid; }
.icon-btn:hover { background: #eef2f5; }
.icon-btn svg { width: 22px; height: 22px; }

.pager { display: flex; gap: 8px; align-items: center; }
.pager button { min-width: 36px; height: 36px; border: 1px solid var(--line-strong); background: #fff; border-radius: 6px; cursor: pointer; padding: 0 12px; }
.pager button[aria-current="page"] { background: var(--teal); color: #fff; border-color: var(--teal); font-weight: 600; }
.pager button[disabled] { color: #a9b5bf; cursor: default; }

/* ---------- charts */
.chart-card { padding: 14px 18px 12px; display: flex; flex-direction: column; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.legend { display: flex; gap: 18px; font-size: 14px; color: var(--ink-2); align-items: center; }
.legend i { display: inline-block; margin-right: 7px; vertical-align: middle; }
.legend .line { width: 18px; height: 3px; background: var(--teal); border-radius: 2px; }
.legend .band { width: 22px; height: 14px; background: rgba(23, 138, 148, .2); border-radius: 3px; }
.legend .median { width: 20px; border-top: 2px dashed var(--violet); }
.chart-box { position: relative; min-height: 0; flex: 1; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; }

/* dual range slider */
.range { position: relative; height: 34px; }
.range .track { position: absolute; left: 0; right: 0; top: 50%; height: 5px; margin-top: -2.5px; border-radius: 3px; background: #d7e0e6; }
.range .fill { position: absolute; top: 50%; height: 5px; margin-top: -2.5px; background: var(--teal); border-radius: 3px; }
.range input[type="range"] { position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none; appearance: none; -webkit-appearance: none; height: 34px; }
.range input[type="range"]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--teal); border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--teal); cursor: grab; }
.range input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--teal); border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--teal); cursor: grab; }
.range input[type="range"]::-moz-range-track { background: none; }
.range input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(23,138,148,.35); }

.play { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.play svg { width: 18px; height: 18px; }

/* ---------- toast & notices */
.messages { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--teal-soft); }
.messages li.error { background: #fbe4e2; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 2000; white-space: pre-line; }


/* ---------- tags and sign-in */
.pill { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12.5px; background: #eef2f5; color: var(--ink-2); }
.pill.warn { background: #fdf0d5; color: #7a5200; }
.login-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 0; font-size: 34px; }
.login-card form { display: grid; gap: 16px; margin-top: 20px; }
.login-error { padding: 10px 12px; border-radius: 7px; color: #84261f; background: #fbe4e2; }

/* Buttons at their largest, and any button that cannot be pressed yet. */
.btn-lg { height: 52px; padding: 0 30px; font-size: 17px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- responsive */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; width: 100%; min-width: 0; height: auto; padding: 12px; }
  .brand { padding-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { padding: 9px 12px; font-size: 14px; white-space: nowrap; }
  .nav-bottom { margin-top: 0; }
  /* On a phone the menu is a row across the top: there is nothing to collapse. */
  .nav-toggle { display: none; }
  .nav-collapsed .brand { display: block; }
  .nav-collapsed .nav a, .nav-collapsed .nav-action { font-size: 14px; gap: 14px; padding: 9px 12px; }
  .main { padding: 16px; }
  .page-head { flex-direction: column; }
  .page-head h1 { font-size: 28px; }
}
