:root {
  --page: #f4f3ef;
  --surface: #ffffff;
  --surface-soft: #f8f7f4;
  --ink: #18191d;
  --ink-soft: #666872;
  --ink-faint: #92949d;
  --line: #e5e3dd;
  --line-strong: #d6d3cc;
  --purple: #6257e5;
  --purple-soft: #eeecff;
  --green: #17a37a;
  --green-soft: #e6f5ef;
  --amber: #b87919;
  --red: #c84f5d;
  --manual: #c7c9d1;
  --manual-soft: #e9eaee;
  --shadow: 0 1px 2px rgba(20, 20, 24, 0.04), 0 12px 30px rgba(20, 20, 24, 0.035);
  --radius: 20px;
  --focus: 0 0 0 3px rgba(98, 87, 229, 0.24);
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); }

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-160%);
  transition: transform 180ms ease-out;
}

.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 40px;
  border-bottom: 1px solid rgba(214, 211, 204, 0.75);
}

.topbar form { justify-self: end; }

.brand, .login-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
}

.brand-mark span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 6px -6px 0 -2px var(--green);
}

.live-list { display: flex; gap: 8px; justify-content: center; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.live-pill[data-state="active"] .live-dot { background: var(--green); }
.live-pill[data-state="idle"] .live-dot,
.live-pill[data-state="passive"] .live-dot { background: var(--amber); }
.live-pill[data-state="paused"] .live-dot { background: var(--red); }

.quiet-button {
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  transition: color 180ms ease-out, background 180ms ease-out;
}

.quiet-button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.65); }

.page-shell {
  width: min(1320px, calc(100% - 64px));
  margin: 0 auto;
  padding: 54px 0 32px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.eyebrow, .card-label {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-family: "Segoe UI Variable Display", Inter, sans-serif;
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.date-range { margin: 10px 0 0; color: var(--ink-soft); font-size: 15px; }

.toolbar { display: flex; align-items: center; gap: 10px; }

.select-wrap select, .week-nav, .view-switch {
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.view-switch { display: flex; align-items: center; overflow: hidden; }

.view-button {
  height: 42px;
  padding: 0 15px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
  transition: background 180ms ease-out, color 180ms ease-out;
}

.view-button + .view-button { border-left: 1px solid var(--line); }
.view-button:hover { background: var(--surface); color: var(--ink); }
.view-button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.view-button[aria-pressed="true"]:hover { background: #2a2b31; }

.select-wrap select {
  min-width: 164px;
  padding: 0 34px 0 13px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.week-nav { display: flex; align-items: center; overflow: hidden; }

.icon-button, .week-button {
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  transition: background 180ms ease-out;
}

.icon-button { width: 42px; display: grid; place-items: center; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.week-button { padding: 0 12px; font-size: 13px; font-weight: 650; border-inline: 1px solid var(--line); }
.icon-button:hover, .week-button:hover { background: var(--surface); }
.icon-button:disabled { cursor: not-allowed; opacity: 0.35; }

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #edcbd0;
  border-radius: 14px;
  background: #fff3f4;
  color: #8f3240;
}

.error-banner[hidden] { display: none; }
.error-banner button { border: 0; background: transparent; color: inherit; font-weight: 700; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.card {
  min-width: 0;
  border: 1px solid rgba(214, 211, 204, 0.82);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.summary-card {
  grid-column: span 4;
  min-height: 276px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.summary-card .card-label { color: #a7a8b0; }

.summary-time {
  margin: 20px 0 0;
  font-family: "Segoe UI Variable Display", Inter, sans-serif;
  font-size: clamp(56px, 6vw, 84px);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.075em;
  font-variant-numeric: tabular-nums;
}

.summary-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.comparison { max-width: 150px; margin: 0; color: #b8bac2; font-size: 13px; }
.comparison.positive { color: #6fe0ba; }
.comparison.negative { color: #ff9aa5; }
.summary-metrics { display: grid; gap: 5px; text-align: right; color: #9fa1aa; font-size: 12px; }
.summary-metrics strong { color: #fff; font-variant-numeric: tabular-nums; }
.summary-metrics .manual-extra { color: #85878f; }
.summary-metrics .manual-extra strong { color: var(--manual); }
.summary-metrics .manual-extra[hidden] { display: none; }

.week-card { grid-column: span 8; min-height: 276px; padding: 24px 26px 20px; }
.people-card { grid-column: span 4; padding: 24px 26px; }
.apps-card { grid-column: span 4; padding: 24px 26px; }
.activity-card { grid-column: span 8; padding: 24px 26px; }
.manual-card { grid-column: span 4; padding: 24px 26px; }

.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-heading h2 { margin: 0; font-size: 18px; line-height: 1.3; letter-spacing: -0.025em; }

.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 12px; }
.legend-swatch { width: 8px; height: 8px; border-radius: 3px; }
.legend-swatch-manual { background: var(--manual); }

.chart-wrap { height: 180px; display: grid; grid-template-columns: 42px 1fr; gap: 8px; margin-top: 14px; }
.axis-labels { display: flex; flex-direction: column; justify-content: space-between; padding: 4px 0 24px; color: var(--ink-faint); font-size: 10px; }
.week-chart {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(24px, 1fr));
  gap: clamp(7px, 1.7vw, 24px);
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px));
  border-bottom: 1px solid var(--line);
}

.day-column { min-width: 0; height: 100%; display: grid; grid-template-rows: 1fr 22px; gap: 4px; }
.day-bars { min-height: 0; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.day-bar {
  width: min(22px, 40%);
  min-height: 2px;
  border-radius: 6px 6px 2px 2px;
  transform-origin: bottom;
  animation: rise 280ms ease-out both;
}
.day-label { color: var(--ink-soft); font-size: 11px; text-align: center; }

.day-bar-stack {
  width: min(22px, 40%);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transform-origin: bottom;
  animation: rise 280ms ease-out both;
}
.day-bar-stack .day-bar { width: 100%; animation: none; border-radius: 2px; }
.day-bar-stack .day-bar:first-child { border-radius: 6px 6px 2px 2px; }
.day-bar-manual { background: var(--manual); }

.week-chart.hours { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: clamp(2px, 0.6vw, 8px); }
.week-chart.hours .day-bars { gap: 2px; }
.week-chart.hours .day-bar { width: min(12px, 78%); border-radius: 3px 3px 1px 1px; }
.week-chart.hours .day-label { font-size: 10px; }

@keyframes rise { from { transform: scaleY(0.08); opacity: 0.4; } to { transform: scaleY(1); opacity: 1; } }

.people-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.person-tile { min-width: 0; padding: 17px; border-radius: 14px; background: var(--surface-soft); }
.person-head { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.person-dot { width: 8px; height: 8px; border-radius: 50%; }
.person-time { margin: 18px 0 2px; font-size: clamp(26px, 3vw, 36px); font-weight: 650; line-height: 1; letter-spacing: -0.055em; font-variant-numeric: tabular-nums; }
.person-sub { margin: 7px 0 0; color: var(--ink-faint); font-size: 11px; }

.app-list, .activity-list { margin-top: 18px; }
.app-row { padding: 12px 0; border-top: 1px solid var(--line); }
.app-row:first-child { padding-top: 4px; border-top: 0; }
.app-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 14px; }
.app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; }
.app-time { color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.app-meta { display: flex; align-items: center; gap: 9px; margin-top: 8px; }
.app-track { flex: 1; height: 5px; overflow: hidden; border-radius: 999px; background: var(--line); }
.app-fill { height: 100%; border-radius: inherit; background: var(--purple); }
.app-intensity { min-width: 64px; color: var(--ink-faint); font-size: 10px; text-align: right; }

.privacy-note { color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.activity-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.activity-item:first-child { padding-top: 4px; border-top: 0; }
.activity-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 620; }
.activity-meta { margin-top: 2px; color: var(--ink-faint); font-size: 11px; }
.activity-time { align-self: center; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.manual-list { margin-top: 18px; }
.manual-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.manual-item:first-child { padding-top: 4px; border-top: 0; }
.manual-output { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; }
.manual-output.no-text { color: var(--ink-soft); font-style: italic; font-weight: 500; }
.manual-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--ink-faint); font-size: 11px; }
.manual-side { display: flex; align-items: center; gap: 8px; align-self: center; }
.manual-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--manual-soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.manual-delete {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  transition: background 180ms ease-out, color 180ms ease-out;
}
.manual-delete:hover { background: #f6e3e6; color: var(--red); }

.empty-state { margin: 20px 0 0; padding: 24px 18px; border-radius: 14px; background: var(--surface-soft); color: var(--ink-soft); font-size: 13px; text-align: center; }

.page-footer { display: flex; justify-content: space-between; gap: 24px; margin-top: 24px; color: var(--ink-faint); font-size: 11px; }
.page-footer p { margin: 0; }

.login-page { display: grid; place-items: center; padding: 32px 20px; }
.login-shell { width: min(100%, 450px); }
.login-brand { margin-bottom: 24px; }
.login-card { padding: 36px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255, 255, 255, 0.88); box-shadow: var(--shadow); }
.login-card h1 { max-width: 340px; margin: 0; font-size: clamp(34px, 8vw, 48px); line-height: 1.02; letter-spacing: -0.055em; }
.login-copy { margin: 18px 0 28px; color: var(--ink-soft); }
.login-form { display: grid; gap: 9px; }
.login-form label { color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.login-form input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; color: var(--ink); }
.primary-button { min-height: 48px; margin-top: 8px; border: 0; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; transition: background 180ms ease-out, transform 180ms ease-out; }
.primary-button:hover { background: #2a2b31; }
.primary-button:active { transform: translateY(1px); }
.form-error { margin: 0; color: var(--red); font-size: 13px; }
.login-footnote { margin: 18px 0 0; color: var(--ink-faint); font-size: 12px; text-align: center; }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: 1fr auto; padding-inline: 24px; }
  .live-list { order: 3; grid-column: 1 / -1; padding-bottom: 12px; }
  .page-shell { width: min(100% - 40px, 900px); padding-top: 42px; }
  .summary-card, .week-card { grid-column: span 12; }
  .people-card, .apps-card { grid-column: span 6; }
  .activity-card, .manual-card { grid-column: span 12; }
}

@media (max-width: 700px) {
  .topbar { min-height: 62px; padding-inline: 16px; gap: 12px; }
  .quiet-button { min-height: 44px; }
  .live-list { justify-content: flex-start; overflow-x: auto; }
  .page-shell { width: calc(100% - 24px); padding-top: 32px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 22px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .select-wrap select { width: 100%; height: 48px; }
  .week-nav { height: 48px; justify-content: space-between; }
  .icon-button, .week-button { height: 46px; }
  .view-switch { height: 48px; }
  .view-button { flex: 1; height: 46px; }
  .dashboard-grid { gap: 12px; }
  .summary-card, .week-card, .people-card, .apps-card, .activity-card, .manual-card { grid-column: span 12; }
  .summary-card { min-height: 250px; padding: 24px; }
  .summary-footer { align-items: flex-start; flex-direction: column; }
  .summary-metrics { text-align: left; }
  .week-card, .people-card, .apps-card, .activity-card, .manual-card { padding: 21px 18px; }
  .chart-wrap { grid-template-columns: 34px 1fr; }
  .week-chart { gap: 5px; }
  .day-bar, .day-bar-stack { width: min(16px, 45%); }
  .week-chart.hours { gap: 2px; }
  .week-chart.hours .day-bar { width: min(9px, 85%); }
  .week-chart.hours .day-label { font-size: 9px; }
  .page-footer { flex-direction: column; gap: 7px; }
  .login-card { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
