:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #637083;
  --line: #dfe4ea;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --danger-bg: #fee4e2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.primary-action,
.secondary-action {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button:disabled {
  background: #c8ced6;
  color: #667085;
  cursor: not-allowed;
}

button:hover,
.primary-action:hover,
.secondary-action:hover {
  background: var(--accent-dark);
}

button:disabled:hover {
  background: #c8ced6;
}

.secondary-action {
  background: #243447;
}

.danger {
  background: var(--danger);
}

.danger-zone {
  border-color: #fecdca;
}

.danger-zone form {
  margin-top: 18px;
}

.link-button {
  background: transparent;
  color: var(--ink);
  min-height: auto;
  padding: 0;
}

.link-button:hover {
  background: transparent;
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.nav a {
  text-decoration: none;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 32px 24px 56px;
}

.impersonation {
  align-items: center;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 10px 16px;
}

.impersonation button {
  min-height: 32px;
}

.flash {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 7px;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.flash-error {
  background: var(--danger-bg);
  border-color: #fecdca;
}

.login-panel {
  align-items: center;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 62vh;
}

.login-panel h1,
.page-header h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.page-header {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.toolbar-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 20px;
}

.narrow {
  max-width: 680px;
}

.inline-form {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
}

.stack-form {
  display: grid;
  gap: 16px;
}

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

label span {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}

input,
textarea,
select {
  border: 1px solid #cfd6df;
  border-radius: 7px;
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  min-height: 110px;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.checkbox-row input,
input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

.list {
  display: grid;
  gap: 12px;
}

.form-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px;
  text-decoration: none;
}

.form-row h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.form-row p {
  color: var(--muted);
  margin: 0;
}

.row-meta {
  align-items: end;
  color: var(--muted);
  display: grid;
  gap: 6px;
  justify-items: end;
}

.row-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.status-on,
.status-off {
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
  padding: 3px 9px;
}

.status-on {
  background: #d1fadf;
  color: #05603a;
}

.status-off {
  background: #f2f4f7;
  color: #475467;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 22px;
  margin-bottom: 20px;
}

.tabs a {
  color: var(--muted);
  padding: 0 0 12px;
  text-decoration: none;
}

.tabs .active {
  border-bottom: 3px solid var(--accent);
  color: var(--ink);
  font-weight: 800;
}

.section-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 1.05rem;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 900px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
}

pre {
  background: #101828;
  border-radius: 8px;
  color: #f9fafb;
  overflow-x: auto;
  padding: 18px;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .92rem;
}

.empty-state,
.setup-warning {
  background: #fff;
  border: 1px dashed #b7c0cc;
  border-radius: 8px;
  color: var(--muted);
  padding: 22px;
}

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

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-card .metric-small {
  font-size: 1.1rem;
  line-height: 1.25;
}

.metric-card p {
  color: var(--muted);
  margin: 0;
}

.meter {
  background: #eef2f6;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.meter span {
  background: var(--accent);
  display: block;
  height: 100%;
}

.activity-chart {
  align-items: end;
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(30, minmax(18px, 1fr));
  min-height: 180px;
  overflow-x: auto;
  padding-top: 16px;
}

.activity-day {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-rows: 120px auto auto;
  justify-items: center;
  min-width: 18px;
}

.activity-bar {
  align-self: end;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  display: block;
  min-height: 2px;
  width: 100%;
}

.activity-count,
.activity-label {
  color: var(--muted);
  font-size: .72rem;
}

@media (max-width: 760px) {
  .topbar,
  .page-header,
  .form-row,
  .login-panel {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 14px;
    padding: 16px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .metric-grid.compact {
    grid-template-columns: 1fr;
  }

  .row-meta {
    align-items: start;
    justify-items: start;
  }
}
