/* ========================================
   Date Navigation
   ======================================== */

.date-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.date-nav__center {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.date-nav__today {
  font-size: var(--text-caption) !important;
  min-height: auto !important;
  padding: var(--space-2xs) var(--space-sm) !important;
}

/* Day type bar */
.daytype-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.daytype-chip {
  padding: 4px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  font-size: var(--text-caption);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.daytype-chip:hover {
  border-color: var(--color-accent);
}

.daytype-chip--active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  font-weight: var(--weight-medium);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: var(--color-accent);
  color: #0f0f0f;
}

.btn--primary:hover {
  background: var(--color-accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn--danger {
  background: var(--color-danger-dim);
  color: var(--color-danger);
}

.btn--danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn--sm {
  min-height: 36px;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-caption);
}

.btn--icon {
  width: var(--touch-target);
  padding: 0;
}

/* ========================================
   Field Row — Today View
   ======================================== */

.field-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  min-height: var(--touch-target);
  transition: background var(--duration-fast) var(--ease-out);
}

@media (min-width: 768px) {
  .field-row {
    padding: var(--space-md) var(--space-lg);
    gap: var(--space-md);
  }

  .field-label {
    font-size: var(--text-body);
  }
}

.field-row:active {
  background: var(--color-surface-2);
}

.field-icon {
  font-size: var(--text-subheading);
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.field-label {
  font-size: var(--text-body-sm);
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-input-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.field-notes-wrap {
  width: 100%;
  margin-top: var(--space-xs);
}

.input-field--notes {
  font-size: var(--text-caption);
  padding: var(--space-xs) var(--space-sm);
  width: 100%;
}

/* ========================================
   Checkbox Toggle
   ======================================== */

/* Legacy checkbox-toggle (kept for history view) */
.checkbox-toggle {
  position: relative;
  width: var(--touch-target);
  height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.checkbox-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.checkbox-toggle__box {
  width: 26px;
  height: 26px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  background: transparent;
}

.checkbox-toggle input:checked + .checkbox-toggle__box {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.checkbox-toggle__check {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0);
  transition: all var(--duration-normal) var(--ease-out);
}

.checkbox-toggle input:checked + .checkbox-toggle__box .checkbox-toggle__check {
  opacity: 1;
  transform: scale(1);
}

/* Three-state toggle: unanswered → yes → no */
.tristate-toggle {
  width: var(--touch-target);
  height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.tristate-toggle__box {
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  background: transparent;
  position: relative;
}

.tristate-toggle__icon {
  width: 14px;
  height: 14px;
  position: absolute;
  opacity: 0;
  transform: scale(0);
  transition: all var(--duration-normal) var(--ease-out);
}

/* Unanswered: grey border, dash */
.tristate-toggle[data-state="unanswered"] .tristate-toggle__box {
  border-color: var(--color-border);
  background: transparent;
}
.tristate-toggle[data-state="unanswered"] .tristate-toggle__icon--unanswered {
  opacity: 0.3;
  transform: scale(1);
  color: var(--color-text-muted);
}

/* Yes: green bg, check */
.tristate-toggle[data-state="yes"] .tristate-toggle__box {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.tristate-toggle[data-state="yes"] .tristate-toggle__icon--yes {
  opacity: 1;
  transform: scale(1);
  color: #fff;
}

/* No: red border, X */
.tristate-toggle[data-state="no"] .tristate-toggle__box {
  border-color: var(--color-danger, #ef5350);
  background: var(--color-danger, #ef5350);
}
.tristate-toggle[data-state="no"] .tristate-toggle__icon--no {
  opacity: 1;
  transform: scale(1);
  color: #fff;
}

/* ========================================
   Text / Number / Time Inputs
   ======================================== */

.input-field {
  width: 100%;
  max-width: 200px;
  padding: var(--space-sm) var(--space-sm);
  background: var(--color-surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-body-sm);
  min-height: 36px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.input-field:focus {
  border-color: var(--color-accent);
}

.input-field::placeholder {
  color: var(--color-text-muted);
}

.input-field--time {
  max-width: 120px;
  text-align: center;
}

.input-field--number {
  max-width: 100px;
  text-align: center;
}

/* Fix time input color scheme for dark mode */
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* ========================================
   Rating (stars)
   ======================================== */

.rating-input {
  display: flex;
  gap: 2px;
}

.rating-star {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-border);
  padding: 2px;
  line-height: 1;
  transition: color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.rating-star--on {
  color: var(--color-accent);
}

.rating-star:hover {
  transform: scale(1.2);
}

/* ========================================
   Slider
   ======================================== */

.slider-input {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  max-width: 200px;
}

.slider-range {
  flex: 1;
  accent-color: var(--color-accent);
  cursor: pointer;
  height: 4px;
}

.slider-value {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  min-width: 28px;
  text-align: center;
  color: var(--color-text);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  width: 100%;
  margin-top: var(--space-xs);
}

/* ========================================
   Duration
   ======================================== */

.duration-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-field--duration {
  width: 50px;
  max-width: 50px;
  text-align: center;
  padding: var(--space-xs) var(--space-xs);
}

.duration-label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-right: var(--space-xs);
}

/* ========================================
   Multi-select chips
   ======================================== */

.multi-select-input {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.multi-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.multi-chip--on {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f0f0f;
}

/* ========================================
   Counter
   ======================================== */

.counter-input {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.counter-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  line-height: 1;
}

.counter-btn:active {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.counter-display {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  min-width: 40px;
  text-align: center;
}

/* ========================================
   Field unit label
   ======================================== */

.field-unit {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ========================================
   Field group header
   ======================================== */

.field-group-header {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-sm) var(--space-xs);
  margin-top: var(--space-xs);
}

/* ========================================
   Select Field
   ======================================== */

.select-field {
  padding: var(--space-sm) var(--space-md);
  padding-right: var(--space-xl);
  background: var(--color-surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-body-sm);
  min-height: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.select-field:focus {
  border-color: var(--color-accent);
}

/* ========================================
   Streak Badge
   ======================================== */

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-accent-dim);
  color: var(--color-accent);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.interval-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ========================================
   Save Status
   ======================================== */

.save-status {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  transition: opacity var(--duration-normal) var(--ease-out);
}

.save-status--saving {
  color: var(--color-text-muted);
}

.save-status--saved {
  color: var(--color-success);
}

.save-status--error {
  color: var(--color-danger);
}

/* ========================================
   History Day Row
   ======================================== */

/* History view toggle */
.history-view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.history-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.history-view-btn:hover {
  background: var(--color-surface-2);
}

.history-view-btn--active {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

/* History grid (color-coded spreadsheet) */
.hgrid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hgrid {
  border-collapse: collapse;
  font-size: var(--text-caption);
  width: 100%;
  min-width: 600px;
}

.hgrid__th {
  padding: var(--space-2xs) var(--space-xs);
  text-align: center;
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  white-space: nowrap;
  font-size: 0.75rem;
}

.hgrid__th--date {
  text-align: left;
  min-width: 48px;
}

.hgrid__td {
  padding: 3px var(--space-xs);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.7rem;
  white-space: nowrap;
  transition: background var(--duration-fast);
}

.hgrid__td--num {
  text-align: right;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}

.hgrid__td--date {
  text-align: left;
  font-weight: var(--weight-medium);
  min-width: 48px;
  position: sticky;
  left: 0;
  background: var(--color-bg);
  z-index: 1;
}

/* Color-coding custom properties */
:root {
  --hg-yes: #2e7d32;
  --hg-mid: #f9a825;
  --hg-low: #c62828;
  --hg-neutral: #37474f;
}

:root.light {
  --hg-yes: #a5d6a7;
  --hg-mid: #fff176;
  --hg-low: #ef9a9a;
  --hg-neutral: #b0bec5;
}

.history-month-header {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-sm) 0 var(--space-xs);
  margin-top: var(--space-sm);
}

.history-month-header:first-child {
  margin-top: 0;
}

.history-day {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background var(--duration-fast) var(--ease-out);
}

.history-day__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  min-height: var(--touch-target);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.history-day__date {
  font-weight: var(--weight-medium);
  font-size: var(--text-body-sm);
  min-width: 80px;
}

.history-day__dots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  flex: 1;
}

.history-day__fill {
  display: none;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  min-width: 70px;
}

@media (min-width: 768px) {
  .history-day__fill {
    display: flex;
  }
}

.history-day__fill-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--color-accent);
  flex: 1;
  max-width: 40px;
  transition: width var(--duration-fast) var(--ease-out);
}

.history-day__fill-text {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  min-width: 28px;
  text-align: right;
}

.history-day__chevron {
  color: var(--color-text-muted);
  transition: transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.history-day--expanded .history-day__chevron {
  transform: rotate(180deg);
}

.history-day__body {
  display: none;
  padding: 0 var(--space-md) var(--space-md);
}

.history-day--expanded .history-day__body {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* Dot indicators */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot--on {
  background: var(--color-accent);
}

.dot--off {
  background: var(--color-border);
}

.dot--no {
  background: var(--color-danger, #ef5350);
  opacity: 0.5;
}

/* ========================================
   Field Card — Field Manager
   ======================================== */

.field-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  min-height: var(--touch-target);
  transition: all var(--duration-fast) var(--ease-out);
  user-select: none;
}

@media (min-width: 768px) {
  .field-card {
    padding: var(--space-md) var(--space-lg);
  }
}

.field-card.dragging {
  opacity: 0.4;
}

.field-card.drag-over {
  border-top: 2px solid var(--color-accent);
}

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: var(--color-text-muted);
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.field-card__info {
  flex: 1;
  min-width: 0;
}

.field-card__name {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-card__type {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.field-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ========================================
   Toggle Switch
   ======================================== */

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.toggle-switch__track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast) var(--ease-out);
}

.toggle-switch input:checked + .toggle-switch__track {
  background: var(--color-accent);
}

.toggle-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--color-text);
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-out);
}

.toggle-switch input:checked ~ .toggle-switch__thumb {
  transform: translateX(20px);
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  animation: slideUp var(--duration-normal) var(--ease-out);
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    animation: fadeIn var(--duration-normal) var(--ease-out);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal__title {
  font-size: var(--text-subheading);
  font-weight: var(--weight-semibold);
}

.modal__body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.modal__footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
}

/* ========================================
   Form Elements
   ======================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}

.form-input {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-body);
  min-height: var(--touch-target);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.form-input:focus {
  border-color: var(--color-accent);
  outline: none;
}

.form-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-body);
  min-height: var(--touch-target);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--color-accent);
  outline: none;
}

/* ========================================
   Toast
   ======================================== */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-body-sm);
  color: var(--color-text);
  z-index: 300;
  animation: slideUp var(--duration-normal) var(--ease-out);
  box-shadow: var(--shadow-md);
}

/* ========================================
   Auth Screen
   ======================================== */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  padding: var(--space-xl);
  text-align: center;
}

.auth-logo {
  font-family: var(--font-heading);
  font-size: var(--text-h1);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.auth-tagline {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xl);
}

.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-toggle {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
}

.auth-toggle a {
  color: var(--color-accent);
  cursor: pointer;
}

.auth-error {
  font-size: var(--text-body-sm);
  color: var(--color-danger);
  text-align: center;
}

.auth-error--success {
  color: var(--color-success);
}


/* ========================================
   Confirm Dialog
   ======================================== */

.confirm-text {
  font-size: var(--text-body);
  color: var(--color-text);
  line-height: var(--leading-normal);
}

/* ========================================
   Stats Cards
   ======================================== */

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  position: relative;
}

@media (min-width: 640px) {
  .stat-card {
    padding: var(--space-lg);
  }
}

.stat-card--span-2 { grid-column: span 2; }
.stat-card--span-3 { grid-column: span 3; }
.stat-card--span-4 { grid-column: 1 / -1; }

/* On mobile (2 cols), cap span at full width */
@media (max-width: 639px) {
  .stat-card--span-3,
  .stat-card--span-4 {
    grid-column: 1 / -1;
  }
}

.widget-toolbar {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: none;
  gap: 2px;
}

.stats--editing .widget-toolbar {
  display: flex;
}

.btn--xs {
  width: 24px;
  height: 24px;
  min-height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.btn--xs:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* Edit mode */
.stats--editing .stat-card {
  outline: 1px dashed var(--color-border);
  cursor: default !important;
}

/* Drag handle */
.widget-drag-handle {
  cursor: grab;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
}

.widget-drag-handle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.widget-drag-handle:active {
  cursor: grabbing;
}

/* Drag states */
.stat-card--dragging {
  opacity: 0.4;
}

.stat-card--drag-over {
  outline: 2px solid var(--color-accent) !important;
  outline-offset: -2px;
}

/* Interval log table */
.ilog-wrap {
  max-height: 300px;
  overflow-y: auto;
}

.ilog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-caption);
}

.ilog-table thead {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

.ilog-cell {
  padding: var(--space-2xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.ilog-cell--num {
  width: 40px;
  color: var(--color-text-muted);
}

.ilog-cell--days {
  width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ilog-table tfoot .ilog-cell {
  border-bottom: none;
  border-top: 2px solid var(--color-border);
}

/* Bar chart */
.bar-chart {
  display: block;
}

/* Heatmap */
.heatmap {
  display: block;
}

.hm-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
}

.hm-months {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hm-month-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 11px;
}

.hm-month-row__name {
  width: 32px;
  color: var(--color-text-muted);
  text-transform: capitalize;
  flex-shrink: 0;
}

.hm-month-row__bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.hm-month-row__bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.hm-month-row__val {
  width: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.hm-month-row__pct {
  width: 30px;
  text-align: right;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Month table */
.mt-table {
  width: 100%;
  border-collapse: collapse;
}

.mt-row {
  border-bottom: 1px solid var(--color-border);
}

.mt-row:last-child {
  border-bottom: none;
}

.mt-row--avg {
  border-bottom: 2px solid var(--color-border);
}

.mt-row--avg .mt-cell {
  font-weight: var(--weight-semibold);
}

.mt-cell {
  padding: 4px 0;
  font-size: var(--text-body-sm);
  vertical-align: middle;
}

.mt-cell--label {
  width: 100px;
  color: var(--color-text-muted);
}

.mt-row--avg .mt-cell--label {
  color: var(--color-text);
}

.mt-cell--val {
  width: 60px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: var(--space-sm);
}

.mt-cell--bar {
  width: auto;
}

.mt-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--color-accent);
  opacity: 0.5;
  transition: width 0.3s;
}

.mt-bar--above {
  opacity: 0.9;
  background: var(--color-success, var(--color-accent));
}

.btn--xs:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.stat-card__label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.stat-card__value {
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
}

@media (min-width: 640px) {
  .stat-card__value {
    font-size: var(--text-h2);
  }
}

.stat-card__sub {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: var(--space-2xs);
}

/* Detail page (full-screen overlay) */
.detail-page {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 768px) {
  .detail-page {
    left: var(--sidebar-width);
  }
}

.detail-page__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-bg);
}

.detail-page__back {
  flex-shrink: 0;
}

.detail-page__title {
  font-size: var(--text-h3);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.detail-page__sub {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.detail-page__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  max-width: 600px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body);
}

.detail-table th {
  text-align: left;
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg);
}

.detail-table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.detail-table tr:last-child td {
  border-bottom: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Sparkline */
.sparkline {
  display: block;
  margin-top: var(--space-sm);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
  color: var(--color-text-muted);
}

.empty-state__icon {
  font-size: var(--text-h1);
  margin-bottom: var(--space-md);
}

.empty-state__text {
  font-size: var(--text-body-sm);
}

.empty-state__hint {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.empty-state__hint strong {
  color: var(--color-accent);
}

/* ========================================
   Field List (today view container)
   ======================================== */

.field-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

@media (min-width: 768px) {
  .field-list--grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
}

/* ========================================
   Options Chips (for select field editor)
   ======================================== */

.options-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  font-size: var(--text-body-sm);
}

.option-chip__remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-caption);
}

.option-chip__remove:hover {
  background: var(--color-danger-dim);
  color: var(--color-danger);
}

/* Icon picker */
.icon-picker {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
}

.icon-picker__category {
  margin-bottom: var(--space-xs);
}

.icon-picker__category:last-child {
  margin-bottom: 0;
}

.icon-picker__label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xs);
  font-weight: var(--weight-medium);
}

.icon-picker__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.icon-picker__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.icon-picker__btn:hover {
  background: var(--color-surface-2);
}

.icon-picker__btn--active {
  background: var(--color-accent-dim);
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Size picker */
.size-picker {
  display: flex;
  gap: var(--space-xs);
}

.size-picker__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-xs);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.size-picker__btn:hover {
  border-color: var(--color-text-muted);
}

.size-picker__btn--active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

.size-picker__preview {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.5;
}

.size-picker__preview--1 { width: 25%; }
.size-picker__preview--2 { width: 50%; }
.size-picker__preview--3 { width: 75%; }
.size-picker__preview--4 { width: 100%; }

/* Widget modal type picker */
.wm-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.wm-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.wm-type-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
  transform: translateY(-1px);
}

.wm-type-card--active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.wm-type-card__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.wm-type-card--active .wm-type-card__icon {
  color: var(--color-accent);
}

.wm-type-card__icon svg {
  width: 24px;
  height: 24px;
}

.wm-type-card__name {
  font-size: 11px;
  font-weight: var(--weight-medium);
  color: var(--color-text);
  text-align: center;
  line-height: 1.2;
}

/* Widget modal preview */
.wm-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: var(--space-sm) var(--space-md);
  min-height: 60px;
  max-height: 200px;
  overflow: auto;
  transition: border-color 0.2s;
}

.wm-preview:has(.stat-card__value) {
  border-color: var(--color-accent-dim);
}

/* Dashboard tabs */
.dash-tabs {
  display: flex;
  gap: var(--space-2xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dash-tabs:empty {
  display: none;
}

.dash-tab {
  padding: var(--space-xs) var(--space-md);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.dash-tab:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.dash-tab--active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ========================================
   Settings Page
   ======================================== */

.settings-section {
  margin-bottom: var(--space-lg);
}

.settings-section__title {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.settings-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.settings-description {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

/* Settings quick-links (mobile navigation for Felt, Oppsett, Hjelp) */
.settings-links {
  padding: 0;
  overflow: hidden;
}

.settings-link-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  background: none;
  border: none;
  color: var(--color-text);
  font-size: var(--text-body);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.settings-link-item:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.settings-link-item:hover {
  background: var(--color-surface-2);
}

.settings-link-item:active {
  background: var(--color-surface-2);
}

.settings-link-icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.settings-link-label {
  flex: 1;
  text-align: left;
}

.settings-link-chevron {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .settings-links-section {
    display: none;
  }
}

/* Feedback */
.settings-danger-link {
  width: 100%;
  margin-top: var(--space-sm);
  color: var(--color-danger) !important;
  font-size: var(--text-caption);
}

.feedback-textarea {
  width: 100%;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.feedback-status {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.feedback-status--success {
  color: var(--color-success);
}

.feedback-status--error {
  color: var(--color-danger);
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 500px;
  overflow-y: auto;
}

.feedback-item {
  padding: var(--space-sm);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}

.feedback-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2xs);
}

.feedback-item__email {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
}

.feedback-item__date {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.feedback-item__message {
  font-size: var(--text-body-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  padding: var(--space-sm) 0;
  cursor: pointer;
  font-weight: var(--weight-medium);
  font-size: var(--text-body-sm);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-question::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--color-text-muted);
  transition: transform var(--duration-fast);
}

.faq-item[open] .faq-question::after {
  content: '−';
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-answer {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
  padding-bottom: var(--space-sm);
  line-height: var(--leading-relaxed);
}

.faq-answer strong {
  color: var(--color-text);
}

.faq-category {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
}

.faq-category__title {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-xs);
  color: var(--color-accent);
}

/* ========================================
   Admin
   ======================================== */

.admin-tabs {
  display: flex;
  gap: var(--space-2xs);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.admin-tab {
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-text-muted);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.admin-tab:hover {
  color: var(--color-text);
}

.admin-tab--active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

@media (min-width: 640px) {
  .admin-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .admin-stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.admin-stat {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.admin-stat__value {
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
}

.admin-stat__label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: var(--space-2xs);
}

.admin-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 768px) {
  .admin-panels {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-panel {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.admin-panel__title {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}

.admin-table th {
  text-align: left;
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.admin-table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table--full {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-table--full th {
  background: var(--color-surface);
  position: sticky;
  top: 0;
}

.admin-role-select {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 2px var(--space-xs);
  font-size: var(--text-caption);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.settings-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.settings-user__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-subheading);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.settings-user__name {
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
}

.settings-user__email {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
}

/* Color picker */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--swatch-color);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch--active {
  border-color: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--swatch-color);
}

/* View mode picker */
.view-mode-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.view-mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--color-surface-2);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.view-mode-option:hover {
  border-color: var(--color-border);
}

.view-mode-option--active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

.view-mode-option__icon {
  color: var(--color-text-muted);
}

.view-mode-option--active .view-mode-option__icon {
  color: var(--color-accent);
}

.view-mode-option__label {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
}

.view-mode-option__desc {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

/* ========================================
   Spreadsheet / Table View
   ======================================== */

.table-view {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  max-height: calc(100dvh - 140px);
}

.spreadsheet {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: var(--text-caption);
}

/* Header */
.spreadsheet thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.spreadsheet__th {
  background: var(--color-surface);
  padding: var(--space-xs) var(--space-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-align: center;
  border-bottom: 2px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  min-width: 70px;
  vertical-align: bottom;
}

.spreadsheet__th:last-child {
  border-right: none;
}

.spreadsheet__th--date {
  position: sticky;
  left: 0;
  z-index: 11;
  min-width: 100px;
  text-align: left;
}

.spreadsheet__th-icon {
  display: block;
  font-size: var(--text-body-sm);
  line-height: 1;
}

.spreadsheet__th-label {
  display: block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Body rows */
.spreadsheet__row {
  transition: background var(--duration-fast) var(--ease-out);
}

.spreadsheet__row:hover {
  background: var(--color-surface-2);
}

.spreadsheet__row--today {
  background: var(--color-accent-dim);
}

.spreadsheet__row--today:hover {
  background: var(--color-accent-dim);
}

.spreadsheet__td {
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  text-align: center;
  vertical-align: middle;
  height: 36px;
}

.spreadsheet__td:last-child {
  border-right: none;
}

.spreadsheet__td--date {
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 5;
  font-weight: var(--weight-medium);
  text-align: left;
  white-space: nowrap;
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
}

.spreadsheet__row:hover .spreadsheet__td--date {
  background: var(--color-surface-2);
}

.spreadsheet__row--today .spreadsheet__td--date {
  background: var(--color-accent-dim);
  color: var(--color-accent);
  font-weight: var(--weight-semibold);
}

/* Cell inputs */
.table-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.table-input {
  width: 100%;
  max-width: 100px;
  padding: 2px var(--space-xs);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-caption);
  text-align: center;
  height: 28px;
}

.table-input:focus {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
  outline: none;
}

.table-select {
  padding: 2px var(--space-xs);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-caption);
  cursor: pointer;
  height: 28px;
  max-width: 100px;
}

.table-select:focus {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
  outline: none;
}

/* Fix time input in table */
.table-input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  width: 14px;
  height: 14px;
}

/* ========================================
   Distribution Chart
   ======================================== */

.dist-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dist-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.dist-card__icon {
  font-size: var(--text-subheading);
}

.dist-card__title {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  flex: 1;
}

.dist-card__total {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.dist-card__body {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  align-items: flex-start;
}

@media (max-width: 480px) {
  .dist-card__body {
    flex-direction: column;
    align-items: center;
  }
}

.dist-card__chart {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-chart {
  display: block;
}

.dist-card__bars {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.dist-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-body-sm);
}

.dist-row__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dist-row__label {
  min-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
  font-size: var(--text-caption);
}

.dist-row__bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 40px;
}

.dist-row__bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transition: width var(--duration-normal) var(--ease-out);
}

.dist-row__count {
  min-width: 24px;
  text-align: right;
  font-weight: var(--weight-semibold);
  font-size: var(--text-caption);
}

.dist-row__pct {
  min-width: 44px;
  text-align: right;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
}

/* ========================================
   Goal Components
   ======================================== */

.field-goal-hint {
  display: block;
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
  margin-top: 1px;
}

.goal-reached-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2xs) var(--space-sm);
  background: rgba(76, 175, 80, 0.15);
  color: var(--color-success);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
}


.goal-ring-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-sm) 0;
}

.goal-ring {
  flex-shrink: 0;
}

.goal-ring-info {
  display: flex;
  flex-direction: column;
}

.goal-details {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.goal-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.goal-detail__label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.goal-detail__value {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
}

/* ========================================
   Flow Mode — Card Walkthrough
   ======================================== */

.flow-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-md);
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.flow-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  animation: slideUp var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.flow-progress {
  width: 100%;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.flow-progress__bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease-out);
}

.flow-progress__text {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.flow-card__icon {
  font-size: 3rem;
  line-height: 1;
}

.flow-card__name {
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
}

.flow-card__goal {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.flow-card__input {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: var(--space-sm) 0;
}

.flow-card__actions {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  justify-content: space-between;
  margin-top: var(--space-sm);
}

.flow-card__actions .flow-next {
  flex: 1;
}

/* Flow toggle (yes/no) */
.flow-toggle {
  width: 120px;
  height: 56px;
  border-radius: var(--radius-md);
  font-size: var(--text-subheading);
  font-weight: var(--weight-semibold);
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.flow-toggle--on {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f0f0f;
}

.flow-toggle--no {
  background: var(--color-danger, #ef5350);
  border-color: var(--color-danger, #ef5350);
  color: #fff;
}

/* Flow start button */
.btn--flow-start {
  width: 100%;
}

@media (min-width: 768px) {
  .btn--flow-start {
    width: auto;
    min-width: 200px;
  }
}

/* Flow text/number input */
.flow-input {
  width: 100%;
  max-width: 240px;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-subheading);
  text-align: center;
  min-height: 56px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.flow-input:focus {
  border-color: var(--color-accent);
  outline: none;
}

.flow-input::placeholder {
  color: var(--color-text-muted);
}

/* Fix time input in flow */
.flow-input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Flow chips (for select) */
.flow-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  width: 100%;
}

.flow-chip {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font-size: var(--text-body-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  min-height: 40px;
}

.flow-chip:hover {
  border-color: var(--color-text-muted);
}

.flow-chip--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f0f0f;
  font-weight: var(--weight-medium);
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


/* ========================================
   Onboarding
   ======================================== */

.onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  padding: var(--space-md);
}

.onboarding__card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.onboarding__card--wide {
  max-width: 640px;
  text-align: left;
}

.onboarding__icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.onboarding__title {
  font-size: var(--text-h2);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-sm);
}

.onboarding__text {
  color: var(--color-text-muted);
  font-size: var(--text-body);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.onboarding__features {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  text-align: left;
}

.onboarding__feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.onboarding__feature-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.onboarding__feature strong {
  display: block;
  font-weight: var(--weight-semibold);
  margin-bottom: 2px;
}

.onboarding__feature span {
  color: var(--color-text-muted);
  font-size: var(--text-body-sm);
}

.onboarding__btn {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-body);
}

/* Field picker */
.onboarding__categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  max-height: 50dvh;
  overflow-y: auto;
  padding-right: var(--space-xs);
}

.onboarding__category-title {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.onboarding__fields {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.onboarding__field {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.onboarding__field:hover {
  background: var(--color-surface);
}

.onboarding__field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
}

.onboarding__field-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.onboarding__field-name {
  flex: 1;
  font-weight: var(--weight-medium);
}

.onboarding__field-type {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.onboarding__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.onboarding__count {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
}

/* Done tips */
.onboarding__tips {
  text-align: left;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: var(--text-body-sm);
}

.onboarding__tips ul {
  margin: var(--space-xs) 0 0 var(--space-md);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  color: var(--color-text-muted);
}

.onboarding__tips li strong {
  color: var(--color-text);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Tasks — periodic chores
   ======================================== */

.task-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--color-border);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.task-card--overdue {
  border-left-color: var(--color-danger, #ef5350);
}

.task-card--due {
  border-left-color: var(--color-accent);
}

.task-card--ok {
  border-left-color: var(--color-success, #4caf50);
}

.task-card__main {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.task-card__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.task-card__info {
  flex: 1;
  min-width: 0;
}

.task-card__name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  margin-bottom: 2px;
}

.task-card__meta {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.task-card__bar {
  height: 3px;
  background: var(--color-surface-2);
  border-radius: 2px;
  margin-top: var(--space-xs);
  overflow: hidden;
}

.task-card__bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--duration-normal) var(--ease-out);
}

.task-card__bar-fill--ok {
  background: var(--color-success, #4caf50);
}

.task-card__bar-fill--due {
  background: var(--color-accent);
}

.task-card__bar-fill--overdue {
  background: var(--color-danger, #ef5350);
}

.task-card__status {
  flex-shrink: 0;
}

.task-badge {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.task-badge--overdue {
  background: var(--color-danger, #ef5350);
  color: #fff;
}

.task-badge--due {
  background: var(--color-accent);
  color: #0f0f0f;
}

.task-badge--ok {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.task-card__actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.task-history {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.task-history__title {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.task-history__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-history__item {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  padding: 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.task-history__remove {
  opacity: 0.3;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.task-history__item:hover .task-history__remove {
  opacity: 1;
}

.task-history__more {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
}

/* Task compliance summary */
.task-summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.task-summary__ring {
  flex-shrink: 0;
}

.task-summary__pct {
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
}

.task-summary__label {
  font-size: var(--text-body-sm);
  color: var(--color-text-muted);
}

.task-summary__detail {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

/* Task group header */
.task-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-xs);
  margin-top: var(--space-md);
}

.task-group-header:first-child {
  margin-top: 0;
}

.task-group-header__title {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.task-group-header__count {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

/* Task row (overview page) */
.task-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  position: relative;
}

.task-row:hover {
  background: var(--color-surface-2);
}

.task-row__check {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  color: var(--color-text-muted);
}

.task-row__check:hover {
  border-color: var(--color-accent);
}

.task-row__check--done {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #0f0f0f;
}

.task-row__info {
  flex: 1;
  min-width: 0;
}

.task-row__top {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: 2px;
}

.task-row__icon {
  font-size: 16px;
  flex-shrink: 0;
}

.task-row__name {
  font-weight: var(--weight-medium);
  font-size: var(--text-body-sm);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-row__badge {
  flex-shrink: 0;
}

.task-row__bottom {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.task-row__bar {
  height: 3px;
  background: var(--color-surface-2);
  border-radius: 2px;
  flex: 1;
  max-width: 80px;
  overflow: hidden;
}

.task-row__meta {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.task-row__more {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

/* Task context menu */
.task-menu {
  position: absolute;
  right: var(--space-md);
  top: 100%;
  z-index: 10;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.15));
  padding: var(--space-xs);
  min-width: 180px;
}

.task-menu__item {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  color: var(--color-text);
  font-size: var(--text-body-sm);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.task-menu__item:hover {
  background: var(--color-surface-2);
}

/* Task statistics */
.task-stats-section {
  margin-bottom: var(--space-lg);
}

.task-stats-title {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-sm);
}

.task-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}

.task-stats-table th {
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.task-stats-table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.task-stats-table tr:last-child td {
  border-bottom: none;
}
