:root {
  /* Pastel palette: soft mint base with periwinkle, mint, peach, rose. */
  --bg: #ffe0c2;                 /* pastel orange */
  --bg-gradient: linear-gradient(160deg, #ffe0c2 0%, #ffedd6 50%, #fff6ea 100%);
  --card: #ffffff;
  --ink: #3a3651;                /* soft deep violet-grey */
  --muted: #9b96b3;              /* muted lilac-grey */
  --primary: #8a9be8;            /* pastel periwinkle */
  --primary-hover: #7688e0;
  --primary-ink: #ffffff;
  --primary-soft: #eaeefc;       /* periwinkle tint for badges */
  --danger: #e08a9b;             /* dusty rose */
  --danger-strong: #d16d81;
  --border: #e7e3f3;             /* pale lilac border */
  --hover: #f4f2fb;

  /* Priority accents (pastel) */
  --low: #a8d8c4;                /* mint */
  --low-soft: #e6f5ee;
  --medium: #f6d6a8;             /* peach */
  --medium-soft: #fdf1e0;
  --high: #e8a7b4;               /* rose */
  --high-soft: #fbe8ec;

  /* Recurrence badge (pastel green) */
  --recur-ink: #5a9e86;
  --recur-soft: #e6f5ee;

  --radius: 12px;
  --radius-control: 10px;        /* shared radius for buttons + inputs */
  --control-h: 40px;             /* shared height for buttons + inputs */
  --shadow: 0 2px 8px rgba(93, 84, 143, 0.08);
  --shadow-lg: 0 12px 40px rgba(93, 84, 143, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; }

/* --- buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  padding: 0 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-control);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease,
              box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--hover); border-color: #d9d3ec; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger-strong); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--high-soft); border-color: transparent; }
.btn.small { height: 32px; padding: 0 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- auth --- */
#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.auth-card { width: 360px; max-width: 90vw; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
form label {
  display: block;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
}
form input, form textarea, form select, .select {
  width: 100%;
  height: var(--control-h);
  padding: 0 0.75rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Textarea is multi-line, so it opts out of the fixed control height. */
form textarea {
  height: auto;
  min-height: 72px;
  padding: 0.55rem 0.75rem;
  resize: vertical;
}
form input:focus, form textarea:focus, form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Custom pastel dropdown arrow for selects (removes native OS styling). */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238a9be8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}
label.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); }
label.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* --- topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 0.5rem; }
.tab {
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
}
.tab:hover { background: var(--hover); }
.tab.active { background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

main { padding: 1.5rem; max-width: 900px; margin: 0 auto; }

/* --- panel headings + toolbar --- */
.panel-heading {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.toolbar .panel-heading { margin: 0; }

.inline-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: stretch; }
.inline-form input { flex: 1; margin-top: 0; }
.inline-form .btn { margin-top: 0; }

/* --- task list --- */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; }
.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.task-card.priority-low { border-left-color: var(--low); background: linear-gradient(90deg, var(--low-soft), var(--card) 40%); }
.task-card.priority-medium { border-left-color: var(--medium); background: linear-gradient(90deg, var(--medium-soft), var(--card) 40%); }
.task-card.priority-high { border-left-color: var(--high); background: linear-gradient(90deg, var(--high-soft), var(--card) 40%); }
.task-card.done { opacity: 0.55; }
.task-card.done .task-title { text-decoration: line-through; }
/* Allow the text column to shrink so long content wraps instead of overflowing.
   Flex items default to min-width:auto, which lets unbreakable strings (URLs)
   push past the card edge. */
.task-main { min-width: 0; flex: 1; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-notes {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.task-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; align-items: center; }
.task-actions { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-end; flex-shrink: 0; }

.badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  text-transform: capitalize;
}
.badge.prio { background: var(--primary-soft); color: var(--primary-hover); }
.badge.prio-low { background: var(--low-soft); color: var(--recur-ink); }
.badge.prio-medium { background: var(--medium-soft); color: #c08a3e; }
.badge.prio-high { background: var(--high-soft); color: var(--danger-strong); }
.badge.recur { background: var(--recur-soft); color: var(--recur-ink); }
.badge.owner { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.due { font-size: 0.8rem; color: var(--muted); }

/* --- stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.stat-panel { padding: 1.25rem 1.5rem; }
.stat-name {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--ink);
}
.stat-figures { display: flex; gap: 1rem; }
.stat-figure {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  border-radius: var(--radius-control);
}
.stat-figure.open { background: var(--primary-soft); }
.stat-figure.closed { background: var(--recur-soft); }
.stat-number {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}
.stat-figure.open .stat-number { color: var(--primary-hover); }
.stat-figure.closed .stat-number { color: var(--recur-ink); }
.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- member list --- */
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.member-list li:last-child { border-bottom: none; }

/* --- oil --- */
.oil-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 700px) {
  .oil-layout { grid-template-columns: 1fr; }
}
.oil-chart, .oil-gauge { padding: 1rem 1.25rem; }
.oil-panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.oil-chart-svg, .oil-gauge-svg { width: 100%; height: auto; display: block; }
.oil-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.oil-dot { fill: var(--primary); }
.oil-grid { stroke: var(--border); stroke-width: 1; }
.oil-axis { fill: var(--muted); font-size: 10px; font-family: inherit; }

.oil-gauge { display: flex; flex-direction: column; align-items: center; }
.oil-gauge-svg { max-width: 260px; }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 14; stroke-linecap: round; }
.gauge-fill { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge-ok .gauge-fill { stroke: var(--low); }
.gauge-warn .gauge-fill { stroke: var(--medium); }
.gauge-critical .gauge-fill { stroke: var(--high); }
.gauge-needle { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.gauge-hub { fill: var(--ink); }
.oil-gauge-value {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.oil-litres { font-size: 1.6rem; font-weight: 700; color: var(--ink); }

/* --- medication --- */
.medication-list { display: flex; flex-direction: column; gap: 0.75rem; }
.medication-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-left: 4px solid var(--low);
}
.medication-card.warning {
  border-left-color: var(--high);
  background: linear-gradient(90deg, var(--high-soft), var(--card) 40%);
}
.medication-main { min-width: 0; flex: 1; }
.medication-name {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.medication-figure { margin: 0.35rem 0 0.35rem; }
.medication-number {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin-right: 0.35rem;
}
.medication-unit { color: var(--muted); font-size: 0.9rem; }
.medication-meta { font-size: 0.8rem; }

/* --- weekend --- */
.weekend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.weekend-day h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--ink);
}
.weekend-day label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.weekend-day label:last-child { margin-bottom: 0; }
.weekend-day textarea {
  display: block;
  width: 100%;
  height: 96px;              /* fixed height, all four boxes match */
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  resize: none;              /* not user-resizable */
}

/* --- dialog --- */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 440px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(58, 54, 81, 0.28); backdrop-filter: blur(2px); }
.row { display: flex; gap: 0.75rem; }
.row > label { flex: 1; }
fieldset.recurrence { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 0.8rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
