/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Steel blue (main) + soft coral (done / progress) on cool grays */
  --color-primary: #4A6A8F;
  --color-primary-hover: #3F5B7C;
  --color-primary-light: #ECF1F6;
  --color-primary-text: #3F5B7C;
  --color-partial: #F3D6CA;
  --color-bg: #F9FAFB;
  --color-surface: #FFFFFF;
  --color-border: #E5E7EB;
  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-success: #D58B70;
  --color-success-hover: #C27760;
  --color-danger: #EF4444;
  --color-danger-hover: #DC2626;
  --color-warning: #F59E0B;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 200px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --color-bg: #0F172A;
  --color-surface: #1E293B;
  --color-border: #334155;
  --color-text: #F1F5F9;
  --color-text-secondary: #94A3B8;
  --color-primary: #6688AE;
  --color-primary-hover: #57799F;
  --color-primary-light: #2A3B52;
  --color-primary-text: #C2D3E6;
  --color-success: #E09A80;
  --color-success-hover: #CC8870;
  --color-partial: #4D3128;
}

/* No accidental zooming: allow scrolling only (no pinch or double-tap zoom) */
html {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* === Header === */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + env(safe-area-inset-top));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) calc(24px + env(safe-area-inset-right)) 0 calc(24px + env(safe-area-inset-left));
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

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

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-text);
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  background: var(--color-primary-light);
}

/* === Layout === */
.layout {
  min-height: 100vh;
  padding-top: calc(var(--header-height) + env(safe-area-inset-top));
  padding-left: var(--sidebar-width);
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  top: calc(var(--header-height) + env(safe-area-inset-top));
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.2s, border-color 0.2s;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s;
  width: 100%;
  text-align: left;
}

@media (hover: hover) {
  .nav-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-text);
  }
}

.nav-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

/* === Main Content === */
.main {
  padding: 32px;
  max-width: 800px;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* === Common Elements === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header .section-title {
  margin-bottom: 0;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.section-subtitle {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, background 0.2s;
  width: 100%;
}

/* iPhones zoom in when you tap a text box with small text; 16px avoids that */
@media (pointer: coarse) {
  input, select, textarea, .input {
    font-size: 16px;
  }
}

.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 106, 143, 0.2);
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
  margin-top: 12px;
}

.btn {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

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

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

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

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

.btn-cancel {
  background: none;
  color: var(--color-text-secondary);
}

.btn-cancel:hover {
  color: var(--color-text);
}

.btn-danger {
  color: var(--color-danger);
  border-color: transparent;
  background: none;
  padding: 4px 8px;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.hidden {
  display: none !important;
}

/* === Timer === */
.timer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

.timer-display {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin-bottom: 24px;
  color: var(--color-text);
  line-height: 1;
}

.timer-display.running {
  color: var(--color-primary);
}

.timer-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  margin: 0 auto 24px;
}

.project-select {
  cursor: pointer;
}

.project-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.project-btn {
  padding: 6px 16px;
  border: 2px solid;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  font-family: var(--font);
}

.project-btn:hover {
  opacity: 0.85;
}

.project-btn:active {
  transform: scale(0.95);
}

.project-btn.active {
  color: #fff;
}

.btn-start {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  letter-spacing: 1px;
  text-transform: uppercase;
}

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

.btn-stop {
  background: var(--color-danger);
  color: #fff;
  border: none;
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  letter-spacing: 1px;
  text-transform: uppercase;
}

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

/* Tags */
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--color-surface);
  transition: border-color 0.15s;
}

.tag-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 106, 143, 0.2);
}

.tag-input {
  border: none;
  padding: 2px 0;
  flex: 1;
  min-width: 100px;
  box-shadow: none !important;
}

.tag-input:focus {
  box-shadow: none !important;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
}

.tag-pill button {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}

.tag-pill button:hover {
  opacity: 1;
}

/* Today section */
.today-section {
  margin-top: 32px;
}

.today-total {
  margin-top: 12px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text-secondary);
  text-align: right;
}

/* === Entry List === */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-group-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-top: 20px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.2s;
}

.entry-row:hover {
  border-color: var(--color-primary);
}

.entry-color {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}

.entry-time {
  font-size: 13px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  min-width: 100px;
}

.entry-project {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.entry-desc {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-duration {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.entry-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.entry-row:hover .entry-actions {
  opacity: 1;
}

.entry-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s;
}

.entry-action-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.entry-action-btn.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
}

.entry-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.entry-tag {
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  padding: 1px 6px;
  border-radius: 99px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
}

/* === Filters (History) === */
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.filters > * {
  min-width: 0;
}

/* iPhone date boxes otherwise keep a fixed width and spill over their neighbours */
input[type="date"].input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  min-height: 38px;
  line-height: 1.3;
}

input[type="date"].input::-webkit-date-and-time-value {
  text-align: left;
}

/* === Reports === */
.report-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.report-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3px;
}

.report-view-toggle .btn-sm {
  border: none;
  background: none;
  border-radius: 6px;
}

.report-view-toggle .btn-sm.active {
  background: var(--color-primary);
  color: #fff;
}

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

.report-period {
  font-size: 14px;
  font-weight: 600;
  min-width: 180px;
  text-align: center;
}

.report-total {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 32px;
}

.report-section {
  margin-bottom: 32px;
}

/* Bar chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  font-size: 13px;
  font-weight: 500;
  min-width: 120px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 28px;
  background: var(--color-bg);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}

.bar-fill {
  height: 100%;
  transition: width 0.4s ease;
  min-width: 2px;
}

.bar-fill:first-child {
  border-radius: 6px 0 0 6px;
}

.bar-fill:last-child {
  border-radius: 0 6px 6px 0;
}

.bar-fill:only-child {
  border-radius: 6px;
}

.bar-value {
  font-size: 13px;
  font-weight: 600;
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}

/* === Projects === */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}

.project-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.project-row:hover {
  border-color: var(--color-primary);
}

.project-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.project-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.project-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.color-input {
  width: 60px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 440px;
  max-height: calc(100% - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}


/* === Notes (patient note tally) === */
.notes-daynav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.notes-date-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.notes-date {
  font-weight: 700;
  font-size: 16px;
}

.notes-today-link {
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: 13px;
  cursor: pointer;
  padding: 2px;
}

.notes-total-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

[data-theme="dark"] .notes-total-banner,
[data-theme="dark"] .notes-cell {
  color: var(--color-primary-text);
}

.notes-total-banner span:last-child {
  font-size: 20px;
}

.notes-prod-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.notes-prod-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-success);
}

.notes-prod-unit {
  font-size: 15px;
  font-weight: 600;
}

.notes-prod-detail {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 2px 0 10px;
}

.notes-prod-project {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.notes-prod-project .input {
  flex: 1;
  padding: 6px 10px;
}

.notes-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.notes-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.notes-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.notes-grid th:first-child,
.notes-grid td:first-child {
  width: 40%;
}

.notes-grid th {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 4px;
}

.notes-grid td {
  padding: 5px 4px;
  text-align: center;
  font-size: 15px;
}

.notes-grid td:first-child {
  text-align: left;
}

.notes-cell {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: transform 0.08s;
}

.notes-cell:active {
  transform: scale(0.94);
}

.notes-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: 8px;
}

.notes-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 15px;
}

.notes-row + .notes-row {
  border-top: 1px solid var(--color-border);
}

.notes-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notes-step {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
}

.notes-step-add {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.notes-count {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
}

.notes-undo {
  display: block;
  margin: 0 auto 20px;
}

.notes-undo:disabled {
  opacity: 0.4;
  cursor: default;
}

.notes-totals .report-controls {
  margin: 14px 0 12px;
}

.notes-totals-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  min-height: 24px;
  -webkit-tap-highlight-color: transparent;
}

.notes-totals-summary::-webkit-details-marker {
  display: none;
}

.notes-totals-chevron {
  flex-shrink: 0;
  color: var(--color-text-secondary);
  transition: transform 0.2s;
}

.notes-totals[open] .notes-totals-chevron {
  transform: rotate(180deg);
}

.notes-avg {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: -6px 0 12px;
  text-align: right;
}

.notes-totals .section-subtitle {
  margin-top: 12px;
}

.notes-total-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 7px 0;
  font-size: 14px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: none;
  color: var(--color-text);
  font-family: inherit;
  text-align: left;
}

.notes-total-row span:last-child {
  font-weight: 700;
}

.notes-day-link {
  cursor: pointer;
}


/* === Habits === */
.habits-summary {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.habit-empty {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  font-size: 14px;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 12px;
}

.habit-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  margin-bottom: 10px;
}

.habit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.habit-name-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
}

.habit-name {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.habit-sub {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.habit-edit {
  color: var(--color-primary);
}

.habit-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Minimal tick: pale when not done, green when done (44px tap area) */
.habit-check {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  padding: 0;
  color: var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, transform 0.08s;
}

.habit-check.on {
  color: var(--color-success);
}

.habit-check:active {
  transform: scale(0.92);
}

.habit-strip {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.habit-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: none;
  padding: 2px 0;
  cursor: pointer;
  font-family: inherit;
}

.habit-bar {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--color-border);
}

.habit-day.done .habit-bar {
  background: var(--color-success);
}

.habit-day.partial .habit-bar {
  background: var(--color-partial);
}

[data-theme="dark"] .habit-day.partial .habit-bar {
  background: var(--color-partial);
}

.habit-letter {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.habit-day.selected .habit-letter {
  color: var(--color-primary);
  font-weight: 700;
}

.habits-mode-toggle {
  margin-bottom: 12px;
}

.habits-mode-toggle .btn-sm {
  flex: 1;
}

/* Month grid (bullet-journal habit tracker): names fixed on the left, day squares slide sideways */
.hm-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 10px;
}

.hm-habit + .hm-habit {
  margin-top: 14px;
}

.hm-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.hm-name-text {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hm-goal,
.hm-total {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
}

.hm-total {
  flex-shrink: 0;
}

.hm-month {
  margin-top: 10px;
}

.hm-grid {
  display: grid;
  gap: 3px;
}

.habit-name .hm-goal {
  font-size: 13px;
}

/* The day the tick / +/- buttons apply to */
.hm-cell.selected {
  outline: 2px solid var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
  position: relative;
  z-index: 1;
}

.hm-grid + .hm-grid {
  margin-top: 3px;
}

.hm-cell {
  border: none;
  border-radius: 4px;
  padding: 0;
  aspect-ratio: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
  background: var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hm-cell.done {
  background: var(--color-success);
  color: #fff;
}

.hm-cell.partial {
  background: var(--color-partial);
}

[data-theme="dark"] .hm-cell.partial {
  background: var(--color-partial);
}

.hm-cell.today {
  outline: 2px solid var(--color-primary);
  outline-offset: 0;
}

.hm-cell.future {
  opacity: 0.35;
  cursor: default;
}

.habit-add {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: none;
  color: var(--color-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 12px;
}

.habit-form .label {
  margin-top: 10px;
}

.habit-error {
  font-size: 13px;
  color: var(--color-danger);
  margin-top: 4px;
}

.habit-count-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.habit-form-actions {
  align-items: center;
}

.habit-form-spacer {
  flex: 1;
}

.btn-danger-text {
  background: none;
  border-color: transparent;
  color: var(--color-danger);
  padding-left: 0;
}


/* === Header menu button + side menu === */
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-btn {
  color: var(--color-text);
}

.side-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
}

.side-menu {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(280px, 80vw);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: 310;
  padding: calc(20px + env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 0.22s ease, visibility 0s linear 0.22s;
}

.side-menu.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.22s ease;
}

.side-menu-title {
  font-size: 18px;
  font-weight: 700;
  padding: 0 12px 12px;
}

.side-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: var(--radius);
  padding: 13px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.side-menu-item:active {
  background: var(--color-primary-light);
}

@media (hover: hover) {
  .side-menu-item:hover {
    background: var(--color-primary-light);
  }
}

.side-menu-secondary {
  margin-top: 8px;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
  padding-top: 16px;
  color: var(--color-text-secondary);
}


/* === History: week/month summary + one 24-hour bar per day === */
.hist-period {
  margin-bottom: 12px;
}

.hist-period .btn {
  flex: 1;
}

.hist-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.hist-tile {
  background: var(--color-primary-light);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  min-width: 0;
}

.hist-tile span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-text);
}

.hist-tile b {
  display: block;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hist-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.hist-stack {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 8px;
}

.hist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
}

.hist-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hist-legend b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hist-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hist-none {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-align: center;
  padding: 4px 0;
}

.hist-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.hist-filters > * {
  min-width: 0;
}

.hist-days {
  padding-top: 4px;
  padding-bottom: 4px;
}

/* Day row: name and total on top, 24-hour bar underneath */
.hday {
  border-bottom: 1px solid var(--color-border);
}

.hday:last-child {
  border-bottom: none;
}

.hday-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label total" "bar bar";
  gap: 5px 10px;
  align-items: baseline;
  width: 100%;
  padding: 10px 0;
  border: none;
  background: none;
  font-family: inherit;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hday-row:disabled {
  cursor: default;
  color: inherit;
}

.hday-future .hday-row {
  opacity: 0.45;
}

.hday-label {
  grid-area: label;
  font-size: 14px;
}

.hday-label b {
  font-weight: 600;
}

.hday-row[aria-expanded="true"] .hday-label b {
  color: var(--color-primary);
}

.hday-bar {
  grid-area: bar;
  position: relative;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent calc(25% - 0.5px), var(--color-surface) calc(25% - 0.5px), var(--color-surface) calc(25% + 0.5px), transparent calc(25% + 0.5px),
      transparent calc(50% - 0.5px), var(--color-surface) calc(50% - 0.5px), var(--color-surface) calc(50% + 0.5px), transparent calc(50% + 0.5px),
      transparent calc(75% - 0.5px), var(--color-surface) calc(75% - 0.5px), var(--color-surface) calc(75% + 0.5px), transparent calc(75% + 0.5px)),
    var(--color-border);
}

.hday-block {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 2px;
  border-radius: 2px;
}

.hday-total {
  grid-area: total;
  font-size: 13px;
  color: var(--color-text-secondary);
  text-align: right;
  white-space: nowrap;
}

/* 0 6 12 18 24 under the first day's bar */
.hday-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-secondary);
  margin: -6px 0 6px;
}

.hday-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 10px;
}

/* === Responsive === */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .header {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }

  /* 16px stops iPhone from zooming in when a text box is tapped */
  .input,
  select,
  textarea {
    font-size: 16px;
  }

  body {
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(60px + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--color-border);
    flex-direction: row;
    justify-content: space-evenly; /* same space between tabs and at both ends */
    gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
  }

  /* Each tab is as wide as its label (or icon) plus 6px each side, so the highlight
     always covers the whole word (e.g. "Anthropometrics"). The bar's 6px side padding
     matches, so every word has the same space on both sides, edges included. */
  .nav-btn {
    flex: 0 0 auto;
    width: auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
    transition: none;
  }

  .nav-btn.active {
    font-weight: 500;
  }

  .nav-icon,
  .nav-icon svg {
    width: 22px;
    height: 22px;
  }

  .nav-label {
    white-space: nowrap;
  }

  /* Small phones: tighter tabs so all five still fit */
  @media (max-width: 359px) {
    .sidebar {
      padding-left: 3px;
      padding-right: 3px;
    }

    .nav-btn {
      padding: 4px 3px;
      font-size: 10px;
    }
  }

  .main {
    padding: 20px 16px;
  }

  .timer-display {
    font-size: 42px;
  }

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

  .report-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .report-nav {
    justify-content: center;
  }

  .bar-label {
    min-width: 80px;
    font-size: 12px;
  }

  .entry-time {
    min-width: auto;
  }

  .entry-desc {
    display: none;
  }

  .entry-actions {
    opacity: 1;
  }

  /* Tags go on their own line under the entry so the
     edit/delete icons are never pushed off the screen */
  .entry-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .entry-project {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .entry-tags {
    order: 10;
    flex-basis: 100%;
    padding-left: 16px;
  }
}

/* === Weight change calculator === */
.wc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  max-width: 480px;
  margin: 0 auto;
}

.wc-card-next {
  margin-top: 16px;
}

.wc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.wc-head .section-title {
  margin: 0;
}

.wc-fields,
.wc-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wc-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.wc-field {
  position: relative;
  margin-bottom: 14px;
}

.wc-input {
  font-size: 22px;
  font-weight: 600;
  padding: 10px 40px 10px 12px;
  font-variant-numeric: tabular-nums;
}

.wc-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  font-size: 15px;
  pointer-events: none;
}

.wc-tile {
  background: var(--color-primary-light);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  min-width: 0;
}

.wc-tile-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wc-tile-value {
  font-size: clamp(16px, 7vw, 26px);
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wc-tile-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.wc-divider {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 8px;
}

.wc-or {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin: -4px 0 8px;
}

.wc-summary:empty {
  display: none;
}

.wc-summary {
  margin-top: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.wc-clear {
  margin-top: 14px;
  width: 100%;
}

/* === Tube feeding calculator === */
#view-tubefeed {
  max-width: 760px;
}

.tf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.tf-head .section-title {
  margin: 0;
}

.tf-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 14px;
}

.tf-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.tf-hint,
.tf-empty {
  color: var(--color-text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

.tf-empty {
  margin: 0;
}

.tf-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.tf-label {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.tf-details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary-text);
  margin: 4px 0 10px;
}

.tf-goal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 600;
}

.tf-goal b {
  font-size: 20px;
}

.tf-goal #tfMedNote {
  font-weight: 400;
}

.tf-tbl {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -14px;
  padding: 0 14px;
}

.tf-tbl table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.tf-tbl th,
.tf-tbl td {
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.tf-tbl th {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.tf-tbl th small {
  display: block;
  font-weight: 400;
}

.tf-tbl th:first-child,
.tf-tbl td:first-child {
  text-align: left;
  position: sticky;
  left: -14px; /* the table box's edge, not its padding */
  background: var(--color-surface);
  font-weight: 600;
  box-sizing: border-box;
  width: 132px;
  min-width: 132px;
  max-width: 132px;
}

/* Rate column stays pinned next to the formula name while sliding sideways */
.tf-tbl th:nth-child(2),
.tf-tbl td:nth-child(2) {
  position: sticky;
  left: 118px; /* 132px name column minus the 14px padding */
  background: var(--color-surface);
  box-shadow: inset -1px 0 0 var(--color-border);
}

.tf-tbl td.tf-rate {
  color: var(--color-primary-text);
  font-weight: 700;
  font-size: 16px;
}

.tf-tbl tr:last-child td {
  border-bottom: none;
}

.tf-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.tf-tile {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.tf-tile span {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.tf-tile b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.tf-tile.hi {
  background: var(--color-primary-light);
  border-color: transparent;
}

.tf-tile.hi b {
  color: var(--color-primary-text);
}

.tf-ons {
  display: grid;
  grid-template-columns: 1fr 72px 56px 56px;
  gap: 6px 10px;
  align-items: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.tf-h,
.tf-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.tf-r {
  text-align: right;
}

.tf-ons label .tf-sub {
  display: block;
}

.tf-tot {
  font-weight: 700;
}

/* One unbroken line above the Total row */
.tf-line {
  grid-column: 1 / -1;
  border-top: 1px solid var(--color-border);
  margin-top: 2px;
}

/* Collapsible card: the whole title row opens / closes it */
.tf-collapse > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.tf-collapse > summary::-webkit-details-marker {
  display: none;
}

.tf-collapse > summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin-left: 4px;
  border-right: 2px solid var(--color-text-secondary);
  border-bottom: 2px solid var(--color-text-secondary);
  transform: rotate(45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.tf-collapse[open] > summary::after {
  transform: rotate(-135deg);
}

.tf-collapse > summary .tf-title {
  margin-bottom: 0;
}

.tf-collapse-sum {
  margin-left: auto;
  font-size: 13px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.tf-collapse[open] > summary {
  margin-bottom: 2px;
}

.tf-med {
  display: block;
  min-height: 16px;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-text);
}

.tf-medtotal {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* === PN dosing (ASPEN) === */
#view-pndosing {
  max-width: 560px;
  margin: 0 auto;
}

.pn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.pn-head .section-title {
  margin: 0;
}

.pn-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.pn-status {
  display: flex;
}

.pn-status .btn-sm {
  flex: 1;
  padding-top: 11px;
  padding-bottom: 11px;
}

.pn-select {
  font-size: 16px;
}

.pn-ibw {
  margin-top: 12px;
}

.pn-tiles {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.pn-tile-wide {
  grid-column: 1 / -1;
}

.pn-tile-value {
  font-size: clamp(17px, 5.2vw, 22px);
  font-weight: 800;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.pn-tile-sub {
  font-size: 12px;
}

.pn-lytes {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.pn-lytes td {
  padding: 7px 2px;
  border-bottom: 1px solid var(--color-border);
}

.pn-lytes tr:last-child td {
  border-bottom: none;
}

.pn-lytes td:last-child {
  text-align: right;
  font-weight: 800;
  white-space: nowrap;
}

.pn-flag {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--color-partial);
  font-size: 13px;
}

.pn-note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.pn-fold {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
}

.pn-chev {
  color: var(--color-text-secondary);
  font-size: 14px;
}

.pn-fold-body {
  margin-top: 12px;
}

.pn-tscroll {
  overflow-x: auto;
}

.pn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pn-table th,
.pn-table td {
  padding: 6px 5px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}

.pn-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-secondary);
}

.pn-table td + td {
  color: var(--color-text-secondary);
}

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

.pn-table .pn-group td {
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pn-gap {
  height: 10px;
}

.pn-source {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 4px 0 12px;
}

/* Space + heading that separate the PN results from the reference tables */
.pn-ref-title {
  margin: 28px 2px 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

/* === Malnutrition criteria (reference, one section per context; reuses the PN card/note/flag styles) === */
#view-malnutrition {
  max-width: 560px;
  margin: 0 auto;
}

.mn-title {
  margin-bottom: 12px;
}

.mn-rule {
  margin-bottom: 4px;
}

.mn-section {
  margin: 18px 2px 8px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary-text);
}

.mn-card {
  padding: 12px;
}

.mn-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
  line-height: 1.35;
}

.mn-table th {
  padding: 0 6px 6px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.mn-table th:first-child {
  width: 30%;
}

.mn-table td {
  padding: 7px 6px;
  vertical-align: top;
  border-top: 1px solid var(--color-surface);
}

.mn-crit {
  font-weight: 700;
  padding-left: 0 !important;
  border-top-color: var(--color-border) !important;
}

.mn-mod {
  background: var(--color-primary-light);
}

.mn-sev {
  background: var(--color-partial);
}

.mn-list {
  list-style: none;
}

.mn-list li + li {
  margin-top: 2px;
}

.mn-na {
  color: var(--color-text-secondary);
}

.mn-defs {
  font-size: 13px;
  line-height: 1.4;
}

.mn-defs dt {
  font-weight: 700;
}

.mn-defs dd {
  margin: 1px 0 8px;
  color: var(--color-text-secondary);
}

.mn-defs dd:last-child {
  margin-bottom: 0;
}

.mn-notes {
  margin: 4px 2px 12px;
}

/* === Points (js/points.js) === */
.pt-wrap {
  max-width: 440px;
  margin: 0 auto;
}

.pt-title {
  margin-bottom: 12px;
}

.pt-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.pt-card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pt-big {
  background: var(--color-primary-light);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
}

.pt-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pt-total {
  font-size: 56px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.pt-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.pt-tile {
  background: var(--color-primary-light);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.pt-tile-val {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.pt-note {
  margin-top: 12px;
  font-size: 16px;
}

.pt-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.pt-btn {
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  padding: 14px 0;
  cursor: pointer;
}

.pt-btn:active {
  transform: scale(0.97);
}

.pt-plus { background: #E4F1EA; color: #3F7D5C; }
.pt-minus { background: #F8E3DC; color: #B4533C; }
[data-theme="dark"] .pt-plus { background: #1F3A2E; color: #8CCBA8; }
[data-theme="dark"] .pt-minus { background: #4D2A22; color: #F0A08A; }

.pt-undo {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: none;
  font-family: inherit;
  color: var(--color-primary-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.pt-undo:disabled {
  opacity: 0.4;
  cursor: default;
}

.pt-log {
  list-style: none;
}

.pt-log li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.pt-log li:last-child {
  border-bottom: none;
}

.pt-amt {
  font-weight: 800;
  min-width: 28px;
  font-variant-numeric: tabular-nums;
}

.pt-amt-plus { color: #3F7D5C; }
.pt-amt-minus { color: #B4533C; }
[data-theme="dark"] .pt-amt-plus { color: #8CCBA8; }
[data-theme="dark"] .pt-amt-minus { color: #F0A08A; }

.pt-reason {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pt-none,
.pt-when {
  color: var(--color-text-secondary);
}

.pt-when {
  font-size: 12px;
  white-space: nowrap;
}

.pt-log li.pt-empty {
  justify-content: center;
  color: var(--color-text-secondary);
}

/* === Personal tab (start page with Habits + Points) === */
.ps-wrap {
  max-width: 440px;
  margin: 0 auto;
}

.ps-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.ps-tile:active {
  transform: scale(0.99);
}

.ps-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--color-primary-light);
  color: var(--color-primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ps-text {
  flex: 1;
  min-width: 0;
}

.ps-title {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.ps-sub {
  display: block;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.ps-chev {
  font-size: 24px;
  color: var(--color-text-secondary);
}

.ps-back {
  display: block;
  background: none;
  border: none;
  padding: 4px 0;
  margin: 0 auto 10px;
  max-width: 440px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary-text);
  cursor: pointer;
}
