:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --ink: #080808;
  --muted: #6c6c6c;
  --soft: #3d3d3d;
  --line: rgba(8, 8, 8, .10);
  --panel: rgba(255, 255, 255, .78);
  --panel-solid: #ffffff;
  --black: #080808;
  --white: #ffffff;
  --danger: #d83a3a;
  --shadow: 0 24px 80px rgba(10, 10, 10, .10);
  --blur: blur(22px);
}

* {
  box-sizing: border-box;
}

[v-cloak] {
  display: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(0, 0, 0, .09), transparent 24%),
    radial-gradient(circle at 90% 8%, rgba(0, 0, 0, .06), transparent 20%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, .035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .5), transparent 75%);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--black);
  border-radius: 999px;
  background: var(--black);
  color: var(--white);
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

button:hover {
  transform: translateY(-1px);
  background: #2a2a2a;
}

button:disabled {
  cursor: wait;
  opacity: .55;
  transform: none;
}

button.ghost {
  background: rgba(255, 255, 255, .68);
  color: var(--ink);
  border-color: var(--line);
}

button.ghost:hover {
  background: #fff;
}

button.danger-button {
  background: #fff1f1;
  border-color: rgba(216, 58, 58, .38);
  color: #a82121;
}

button.danger-button:hover {
  background: #ffe1e1;
}

button.danger-button:disabled {
  background: #f4eeee;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.brand {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--black);
  box-shadow: 0 0 0 6px rgba(0, 0, 0, .08);
}

.login-panel,
.metrics article,
.panel,
.toolbar,
.modal-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 34px;
  border-radius: 26px;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 34px;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .82);
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(0, 0, 0, .46);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .07);
}

.error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.dashboard {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 28px;
}

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

.topbar h1 {
  font-size: 42px;
  line-height: 1;
}

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

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

.metrics article {
  min-width: 0;
  padding: 18px;
  border-radius: 24px;
}

.metrics span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metrics strong {
  display: block;
  overflow: hidden;
  font-size: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 150px;
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: 24px;
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border-radius: 26px;
}

.map-panel {
  grid-column: span 7;
}

.main-grid > .panel:not(.map-panel):not(.sleep-panel):not(.chart-panel):not(.table-panel) {
  grid-column: span 5;
}

.sleep-panel {
  grid-column: 1 / -1;
}

.chart-panel,
.table-panel {
  grid-column: 1 / -1;
}

.panel-head {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 18px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.map {
  position: relative;
  width: 100%;
  height: 440px;
  overflow: hidden;
  background: #f0f0ec;
}

.leaflet-map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #f0f0ec;
  font: inherit;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.map-warning {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 500;
  padding: 10px 12px;
  border: 1px solid rgba(216, 58, 58, .20);
  border-radius: 14px;
  background: rgba(255, 241, 241, .86);
  color: #8f1f1f;
  font-size: 13px;
  font-weight: 750;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.map-info {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.map-info span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.map-info strong {
  color: var(--ink);
  font-size: 13px;
}

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

.signal-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .74);
}

.signal-card span,
.signal-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.signal-card strong {
  display: block;
  margin: 8px 0;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.metric-chart {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .80);
}

.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.chart-title strong {
  font-size: 18px;
}

.chart-canvas {
  height: 180px;
  min-height: 180px;
}

.chart-canvas-large {
  height: 280px;
  min-height: 280px;
}

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

.volume-chart {
  padding: 14px;
}

.sleep-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.sleep-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sleep-total span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.sleep-total strong {
  font-size: 28px;
}

.sleep-bar {
  height: 18px;
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, .06);
}

.sleep-bar span {
  min-width: 10px;
}

.sleep-light,
.sleep-grid .sleep-light {
  background: #74b9ff;
}

.sleep-deep,
.sleep-grid .sleep-deep {
  background: #2d3436;
}

.sleep-rem,
.sleep-grid .sleep-rem {
  background: #a29bfe;
}

.sleep-other,
.sleep-grid .sleep-other {
  background: #dfe6e9;
}

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

.sleep-grid article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .74);
}

.sleep-grid i {
  width: 18px;
  height: 6px;
  border-radius: 999px;
}

.sleep-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sleep-grid strong {
  font-size: 18px;
}

.event-list {
  max-height: 560px;
  overflow: auto;
}

.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.event-row strong {
  display: block;
  margin: 8px 0 4px;
}

.event-row p {
  color: var(--soft);
  word-break: break-word;
}

.event-row time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: right;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, .06);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, .44);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-panel {
  width: min(470px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border-radius: 26px;
}

.modal-panel h2 {
  font-size: 24px;
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.5;
}

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

@media (max-width: 1020px) {
  .metrics,
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .map-panel,
  .main-grid > .panel:not(.map-panel):not(.sleep-panel):not(.chart-panel):not(.table-panel),
  .sleep-panel,
  .chart-panel,
  .table-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .dashboard {
    padding: 16px;
  }

  .brand {
    left: 20px;
  }

  .login-panel {
    padding: 26px;
  }

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

  .topbar h1 {
    font-size: 34px;
  }

  .actions,
  .metrics,
  .toolbar,
  .chart-grid,
  .signal-list,
  .sleep-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
  }

  .metrics strong {
    font-size: 20px;
    white-space: normal;
  }

  .map {
    height: 340px;
  }

  .map-info {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  .event-row time {
    text-align: left;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
