:root {
  color-scheme: light;
  --bg: #d9ebff;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #c8d5e6;
  --green: #1f8a5b;
  --red: #c43d35;
  --blue: #2f6fbb;
  --amber: #b9770e;
  --shadow: 0 14px 30px rgba(24, 58, 102, 0.16), 0 2px 8px rgba(24, 58, 102, 0.08);
  --shadow-soft: 0 8px 20px rgba(24, 58, 102, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #cce4ff 0%, var(--bg) 42%, #eef6ff 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(142, 169, 205, 0.55);
  box-shadow: 0 4px 16px rgba(24, 58, 102, 0.08);
  backdrop-filter: blur(10px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 750;
}

h2 {
  font-size: 16px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
  margin: 0;
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(196, 61, 53, 0.45);
  border-radius: 8px;
  background: #fff0ef;
  color: var(--red);
  font-weight: 700;
}

.actions,
.summary-grid,
.section-head,
.facts {
  display: flex;
  align-items: center;
}

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

button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(151, 170, 196, 0.75);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(24, 58, 102, 0.08);
}

button:hover {
  border-color: #9aa4b2;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 650;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.summary-grid {
  align-items: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.status-panel.ok {
  border-color: rgba(31, 138, 91, 0.35);
}

.status-panel.over {
  border-color: rgba(196, 61, 53, 0.5);
}

.panel-label,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.metric-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}

.metric {
  font-size: 44px;
  line-height: 1;
  font-weight: 800;
}

.metric.compact {
  font-size: 34px;
}

.metric-unit {
  color: var(--muted);
  font-weight: 650;
}

.limit-callout {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
}

.remaining-callout {
  margin-top: 4px;
  color: var(--green);
  font-size: 18px;
  font-weight: 800;
}

.status-panel.over .remaining-callout {
  color: var(--red);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  margin: 18px 0 8px;
  border-radius: 999px;
  background: #e8edf3;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 160ms ease, background-color 160ms ease;
}

.facts {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.warning {
  color: var(--amber);
}

.control-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.control-button[aria-pressed="true"] {
  border-color: rgba(47, 111, 187, 0.55);
  background: #edf5ff;
  color: #194f8d;
}

.control-button.danger[aria-pressed="true"] {
  border-color: rgba(196, 61, 53, 0.6);
  background: #fff0ef;
  color: var(--red);
}

.time-adjuster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 750;
}

.time-adjuster span {
  min-width: 72px;
  text-align: center;
}

.charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.section-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.bar-chart {
  display: grid;
  align-items: end;
  gap: 8px;
  min-height: 210px;
  padding-top: 10px;
}

.hourly {
  grid-template-columns: repeat(24, minmax(12px, 1fr));
}

.weekly {
  grid-template-columns: repeat(7, minmax(48px, 1fr));
}

.bar-item {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  height: 210px;
}

.bar-fill-wrap {
  display: flex;
  align-items: end;
  min-height: 0;
  border-radius: 6px;
  background: #eef2f6;
}

.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 6px;
  background: var(--blue);
}

.bar-fill.over {
  background: var(--red);
}

.bar-fill.ok {
  background: var(--green);
}

.bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.events-panel {
  margin-top: 16px;
}

.events {
  display: grid;
  gap: 8px;
}

.practice-activity {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 650;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.event {
  display: grid;
  grid-template-columns: 170px 80px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.admin-dialog {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.admin-dialog::backdrop {
  background: rgba(23, 32, 42, 0.35);
}

.admin-dialog form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 500;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.event:first-child {
  border-top: 0;
}

@media (max-width: 820px) {
  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .time-adjuster {
    justify-content: space-between;
  }

  .hourly {
    grid-template-columns: repeat(12, minmax(16px, 1fr));
  }

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

  .bar-item {
    height: 180px;
  }

  .event {
    grid-template-columns: 1fr;
    gap: 3px;
  }

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