:root {
  /* Backgrounds — warm dark, not cold black */
  --bg:               #161518;
  --surface:          #1c1b1f;
  --surface-raised:   #222128;
  --surface-active:   #1f1e26;

  /* Edges */
  --edge:             #2c2b32;
  --edge-active:      #3d3b52;
  --edge-subtle:      #242329;

  /* Accent — indigo */
  --accent:           #6674f4;
  --accent-dim:       #3d4a9e;
  --accent-muted:     #2a2d4a;
  --accent-glow:      rgba(102, 116, 244, 0.15);
  --accent-glow-soft: rgba(102, 116, 244, 0.07);

  /* Text */
  --ivory:            #eeeaf4;
  --ivory-dim:        #b8b4c4;
  --muted:            #6e6a7c;
  --muted-soft:       #4a4756;

  /* Semantic */
  --danger:           #e05c5c;

  /* Structure */
  --radius:           20px;
  --seam:             2px;

  /* Additions for Light theme */

  --shell:        #0f0e12;
  --modal-bg:     #1e1d24;
  --tooltip-bg:   #13121a;
  --plunger-1:    #2e2c38;
  --plunger-2:    #1e1d24;
  --plunger-3:    #18171e;
  --heat-0:       #26242e;
  --heat-1:       #2d2d52;
  --heat-2:       #3a3a78;
  --heat-3:       #4f4fa8;


  font-size: 16px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:               #f4f3f6;
  --surface:          #ffffff;
  --surface-raised:   #f7f6fa;
  --surface-active:   #eeecf8;

  --edge:             #e0dde6;
  --edge-active:      #c9c3e0;
  --edge-subtle:      #e8e5ec;

  --accent:           #5561e8;
  --accent-dim:       #b3bbf5;
  --accent-muted:     #e6e8fc;
  --accent-glow:      rgba(85, 97, 232, 0.12);
  --accent-glow-soft: rgba(85, 97, 232, 0.06);

  --ivory:            #201e28;
  --ivory-dim:        #504b5e;
  --muted:            #827d90;
  --muted-soft:       #a8a3b3;

  --danger:           #c9403a;

  --shell:            #e5e2ea;
  --modal-bg:         #ffffff;
  --tooltip-bg:       #ffffff;
  --plunger-1:        #ffffff;
  --plunger-2:        #f2f0f6;
  --plunger-3:        #e8e5ee;
  --heat-0:           #e9e7ee;
  --heat-1:           #c9cdf7;
  --heat-2:           #9aa0ee;
  --heat-3:           #6d76e2;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ivory);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

body {
  overflow: hidden;
  background:
    radial-gradient(
      ellipse 100% 60% at 50% 0%,
      rgba(102, 116, 244, 0.05),
      transparent 65%
    ),
    var(--bg);
}

button,
input {
  font: inherit;
}

/* ====================================================================
   APP SHELL
   ==================================================================== */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--seam);
  padding: var(--seam);
  background: var(--shell);
}

/* ====================================================================
   BRANDING
   ==================================================================== */

.app-title {
  position: fixed;
  top: 20px;
  left: 22px;
  z-index: 30;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

/* ====================================================================
   TOPBAR
   ==================================================================== */

.topbar {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 30;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--edge);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--edge-active);
  background: var(--surface-raised);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.icon-btn:active {
  transform: scale(0.93);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.hidden {
  display: none !important;
}

/* ====================================================================
   PANELS — Two halves of one object
   ==================================================================== */

.panel {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--edge-subtle);
  background: var(--surface);
  color: inherit;

  /* Gentle lift — surfaces feel soft, not recessed */
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);

  transition:
    background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel.active {
  background: var(--surface-active);
  border-color: var(--edge-active);

  box-shadow:
    0 2px 16px rgba(0, 0, 0, 0.4),
    0 1px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(102, 116, 244, 0.08);
}

.panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

/* ====================================================================
   GLOW — Accent warmth on the active face
   ==================================================================== */

.glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(
      ellipse 80% 55% at 50% 105%,
      rgba(102, 116, 244, 0.1),
      transparent 75%
    );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.panel.active .glow {
  opacity: 1;
}

.panel.active.running .glow {
  animation: breathe 5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1;   }
}

@media (prefers-reduced-motion: reduce) {
  .panel.active.running .glow {
    animation: none;
    opacity: 1;
  }
}

/* ====================================================================
   PANEL CONTENT
   ==================================================================== */

.side-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin-bottom: 16px;
  z-index: 2;
  transition: color 0.35s ease;
}

.active .side-label {
  color: var(--accent);
}

/* The hero — the numbers carry everything */
.time-display {
  font-size: clamp(3rem, 15vmin, 7.5rem);
  font-weight: 300;
  line-height: 1;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  z-index: 2;
  color: var(--muted);
  transition:
    color 0.35s ease,
    text-shadow 0.35s ease;
}

.active .time-display {
  color: var(--ivory);
  font-weight: 300;
  text-shadow:
    0 0 60px rgba(102, 116, 244, 0.18),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

.over .time-display,
.over-tag {
  color: var(--danger);
}

.over-tag {
  margin-top: 14px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--danger);
  opacity: 0;
  z-index: 2;
  transition: opacity 0.25s ease;
}

.over .over-tag {
  opacity: 1;
}

.budget-note {
  margin-top: 10px;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  color: var(--muted-soft);
  opacity: 0.9;
  z-index: 2;
  transition: color 0.35s ease;
}

.active .budget-note {
  color: var(--muted);
}

/* ====================================================================
   CENTER ROW
   ==================================================================== */

.center-row {
  position: relative;
  height: 0;
  z-index: 20;
}

.plunger-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

/* ====================================================================
   PLUNGER — Premium modern switch. You want to press this.
   ==================================================================== */

.plunger {
  width: 64px;
  height: 64px;
  border-radius: 50%;

  background:
    radial-gradient(
      circle at 40% 35%,
      var(--plunger-1) 0%,
      var(--plunger-2) 60%,
      var(--plunger-3) 100%
    );

  border: 1px solid var(--edge-active);

  box-shadow:
    0 0 0 4px var(--shell),
    0 4px 16px rgba(0, 0, 0, 0.55),
    0 1px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5);

  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    color 0.2s ease,
    transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.plunger:hover {
  color: var(--accent);
  border-color: var(--accent-dim);

  box-shadow:
    0 0 0 4px #0f0e12,
    0 4px 20px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(102, 116, 244, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5);
}

.plunger:active {
  transform: scale(0.92);
  box-shadow:
    0 0 0 4px #0f0e12,
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 2px 5px rgba(0, 0, 0, 0.7),
    inset 0 -1px 1px rgba(255, 255, 255, 0.04);
}

.plunger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.plunger.is-running {
  color: var(--accent);
  border-color: var(--accent-dim);

  box-shadow:
    0 0 0 4px #0f0e12,
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(102, 116, 244, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5);
}

.plunger svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

/* ====================================================================
   HINT
   ==================================================================== */

.hint {
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted-soft);
  white-space: nowrap;
}

/* ====================================================================
   FOOTER
   ==================================================================== */

.footer-hint {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--muted-soft);
  opacity: 0.45;
  pointer-events: none;
  z-index: 5;
}

/* ====================================================================
   ACCESSIBILITY
   ==================================================================== */

.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;
}

/* ====================================================================
   MODALS — Carried forward. Phase 3.
   ==================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 14, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: auto;
  background: var(--modal-bg);
  border: 1px solid var(--edge);
  border-radius: 20px;
  padding: 24px 22px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.modal.compact {
  max-width: 410px;
}

.modal.dashboard {
  max-width: 840px;
  min-height: min(690px, 90vh);
}

.modal h2 {
  margin: 0 0 18px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.modal h3 {
  margin: 0 0 17px;
  font-size: 1.15rem;
}

.modal h4 {
  margin: 24px 0 12px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.modal-header h2 {
  margin-top: 4px;
}

.eyebrow {
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.close-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.close-btn:hover {
  color: var(--ivory);
}

.btn {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--surface-raised);
  color: var(--ivory);
  font-size: 0.82rem;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.btn.ghost {
  background: none;
  color: var(--muted);
}

.btn.full {
  width: 100%;
  margin-top: 20px;
}

.btn.narrow {
  max-width: 200px;
}

.stack-actions {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.summary-actions {
  margin-top: 20px;
}

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

.metric {
  min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.67rem;
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: 0.96rem;
  color: var(--ivory);
  overflow-wrap: anywhere;
}

.efficiency {
  margin-top: 16px;
}

.efficiency span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.efficiency strong {
  display: block;
  margin: 5px 0 10px;
  color: var(--accent);
}

.progress {
  height: 6px;
  background: var(--surface);
  border-radius: 99px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: inherit;
  transition: width 0.4s;
}

.report-tabs {
  display: flex;
  gap: 5px;
  padding: 5px;
  margin-bottom: 22px;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 12px;
}

.report-tab {
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  padding: 8px 5px;
  font-size: 0.73rem;
  cursor: pointer;
}

.report-tab.active {
  background: var(--surface-raised);
  color: var(--accent);
}

.report-body {
  animation: fade 0.18s ease;
}

.report-body .metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.bar-chart {
  height: 190px;
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding-top: 8px;
}

.bar-chart.monthly {
  gap: 3px;
  overflow-x: auto;
}

.bar-item {
  flex: 1;
  min-width: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.monthly .bar-item {
  min-width: 12px;
}

.bar-track {
  height: 150px;
  width: 100%;
  display: flex;
  align-items: end;
  background: rgba(102, 116, 244, 0.05);
  border-radius: 5px 5px 2px 2px;
  overflow: hidden;
}

.bar-track i {
  width: 100%;
  min-height: 2px;
  background: linear-gradient(var(--accent), var(--accent-dim));
  border-radius: 4px 4px 0 0;
}

.bar-item small {
  color: var(--muted);
  font-size: 0.61rem;
}

.monthly .bar-item small {
  font-size: 0.5rem;
}

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 5px;
  overflow-x: auto;
  padding: 8px 4px 45px;
}

.heat {
  position: relative;
  display: block;
  border-radius: 3px;
  outline: none;
}

.heat span {
  display: none;
  position: absolute;
  z-index: 3;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  padding: 9px;
  background: var(--tooltip-bg);
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--muted);
  font: 11px/1.5 sans-serif;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
}

.heat span b {
  display: block;
  color: var(--ivory);
}

.heat:hover span,
.heat:focus span {
  display: block;
}

.level-0 { background: var(--level-0); }
.level-1 { background: var(--level-1); }
.level-2 { background: var(--level-2); }
.level-3 { background: var(--level-3); }
.level-4 { background: var(--accent); }

.legend {
  display: flex;
  justify-content: end;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.62rem;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.trend-card {
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 0 12px 12px;
  margin-bottom: 12px;
}

.trend-card h4 {
  margin-top: 14px;
}

.trend-card .metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-top: 1px solid var(--edge);
  border-radius: 0;
  padding: 10px 0;
  background: none;
}

.trend-card .metric span {
  margin: 0;
}

.trend-card .metric strong {
  font-size: 0.82rem;
}

.insights {
  margin: 0;
  padding-left: 20px;
  color: var(--ivory);
  line-height: 1.7;
  font-size: 0.85rem;
}

.insights li::marker {
  color: var(--accent);
}

.field-group {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--edge);
}

.group-label {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.name-input,
.hms-row input,
.inline-field input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 9px;
  color: var(--ivory);
  padding: 9px;
}

.name-input {
  margin-bottom: 9px;
}

.hms-row {
  display: flex;
  gap: 8px;
}

.hms-row label {
  flex: 1;
  color: var(--muted);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.hms-row input {
  display: block;
  margin-top: 4px;
  text-align: center;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 11px 0;
  color: var(--ivory);
  font-size: 0.84rem;
}

.toggle-row small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}

.toggle-row input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.inline-field input {
  width: 55px;
  text-align: center;
}

.btn-ghost {
  width: 100%;
  background: none;
  border: 1px solid var(--edge);
  color: var(--muted);
  border-radius: 9px;
  padding: 8px;
  font-size: 0.73rem;
  cursor: pointer;
}

.status-note {
  font-size: 0.67rem;
  color: var(--muted);
  margin: 6px 0 12px;
}

.idle-permission {
  margin-top: 12px;
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ====================================================================
   ANIMATIONS
   ==================================================================== */

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

/* ====================================================================
   RESPONSIVE
   ==================================================================== */

@media (max-width: 650px) {
  .app-title {
    top: 14px;
    left: 14px;
    font-size: 0.58rem;
  }

  .topbar {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn svg {
    width: 15px;
    height: 15px;
  }

  .side-label {
    margin-bottom: 12px;
  }

  .plunger {
    width: 58px;
    height: 58px;
  }

  .plunger svg {
    width: 20px;
    height: 20px;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .modal {
    padding: 20px 15px 16px;
    border-radius: 16px;
  }

  .modal.dashboard {
    min-height: 92vh;
  }

  .report-body .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-tabs {
    overflow-x: auto;
  }

  .report-tab {
    min-width: 60px;
  }

  .bar-chart {
    gap: 4px;
  }

  .footer-hint {
    display: none;
  }

  .heatmap {
    grid-template-rows: repeat(7, 13px);
    grid-auto-columns: 13px;
    gap: 4px;
  }
}

@media (max-height: 570px) and (orientation: landscape) {
  .app {
    flex-direction: row;
  }

  .center-row {
    width: 0;
    height: auto;
  }

  .time-display {
    font-size: clamp(2rem, 12vmin, 5rem);
  }
}