:root {
  --me: #2563eb;        /* blå – Du (DK) */
  --me-soft: #dbeafe;
  --emma: #db2777;      /* rosa – Emma (SE) */
  --emma-soft: #fce7f3;
  --atf: #7c3aed;       /* lila – ATF */
  --feriefri: #0d9488;  /* grön – feriefridagar */
  --holiday: #dc2626;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1f2937;
  --muted: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 16px 48px;
  max-width: 1100px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 0 12px;
}
.topbar h1 { font-size: 1.4rem; margin: 0; }
.actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.btn:hover { background: #f0f2f5; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn--primary:hover { background: #1d4ed8; }
.btn--sm { padding: 5px 10px; font-size: 0.82rem; }

/* --- Saldokort --- */
.balances {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  border-left: 6px solid var(--border);
}
.card--me { border-left-color: var(--me); }
.card--emma { border-left-color: var(--emma); }
.card__title { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.card__tag {
  font-size: 0.75rem; font-weight: 500; color: var(--muted);
  background: var(--bg); border-radius: 6px; padding: 2px 8px;
}
.cat { padding: 8px 0; border-top: 1px dashed var(--border); }
.cat:first-of-type { border-top: none; }
.cat__head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.cat__head .card__tag { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.cat__big { font-size: 1.5rem; font-weight: 700; margin: 2px 0; }
.cat__big small { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.cat__sub { font-size: 0.78rem; color: var(--muted); }
.cat__warnings { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.warn { font-size: 0.75rem; font-weight: 600; border-radius: 5px; padding: 2px 7px; }
.warn--error { background: #fee2e2; color: #b91c1c; }
.warn--warning { background: #fef9c3; color: #854d0e; }
.warn--info { background: #e0f2fe; color: #0369a1; }
.neg { color: var(--holiday) !important; }

/* --- Policy-banner --- */
.policy-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px;
  font-size: 0.88rem; font-weight: 500;
}
.policy-banner--error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.policy-banner--warning { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }
.policy-sep { color: inherit; opacity: 0.5; }
.policy-dismiss {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 1rem; color: inherit; opacity: 0.6; padding: 0 4px;
}
.policy-dismiss:hover { opacity: 1; }

/* --- Verktygsrad --- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
}
.picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.picker__label { color: var(--muted); font-size: 0.9rem; }
.chip {
  border: 1px solid var(--border); background: var(--card);
  border-radius: 999px; padding: 6px 16px; cursor: pointer; font-size: 0.9rem;
}
.chip.active { background: var(--chip-color, #2563eb); color: #fff; border-color: var(--chip-color, #2563eb); }
.type-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
#type-select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); }

.monthnav { display: flex; align-items: center; gap: 8px; }
.monthnav__title { min-width: 150px; text-align: center; font-weight: 600; text-transform: capitalize; }

.hint { color: var(--muted); font-size: 0.82rem; margin: 4px 0 12px; }
kbd {
  background: #fff; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; font-size: 0.8em;
}

/* --- Kalender --- */
.cal-weekdays, .cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-weekday {
  text-align: center; font-size: 0.78rem; color: var(--muted);
  font-weight: 600; padding: 4px 0;
}
.cal-grid { grid-auto-rows: minmax(84px, auto); }

.cal-day {
  position: relative; text-align: left; font: inherit;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  overflow: hidden;
}
.cal-day:hover { border-color: #c3c8d0; }
.cal-day--other { opacity: 0.4; }
.cal-day--weekend { background: #fafbfc; }
.cal-day--holiday .cal-day__num { color: var(--holiday); font-weight: 700; }
.cal-day--today { outline: 2px solid #f59e0b; outline-offset: -2px; }

.cal-day__num { font-size: 0.85rem; font-weight: 600; }
.cal-day__holiday {
  font-size: 0.66rem; color: var(--holiday); line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-day__badges { display: flex; flex-direction: column; gap: 3px; margin-top: auto; }
.badge {
  font-size: 0.68rem; font-weight: 600; color: #fff;
  border-radius: 5px; padding: 2px 6px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge--me { background: var(--me); }
.badge--emma { background: var(--emma); }
.badge--atf { background: var(--atf); }
.badge--feriefri { background: var(--feriefri); }

/* --- Modal / inställningar --- */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px;
}
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.modal__panel {
  position: relative; background: var(--card); border-radius: 14px;
  width: min(820px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal__head, .modal__foot {
  display: flex; align-items: center; padding: 14px 18px;
}
.modal__head { justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal__head h2 { margin: 0; font-size: 1.15rem; }
.modal__foot { justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.modal__body { padding: 8px 18px; overflow-y: auto; }

.settings-person { padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings-person h3 { margin: 4px 0 10px; }
.settings-top { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }

.cat-edit {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
}
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.fld input, .fld select { font-size: 0.9rem; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.fld input[type="color"] { padding: 2px; width: 44px; height: 32px; }
.fld--wide input { min-width: 150px; }
.cat-edit .fld input[type="text"] { min-width: 90px; }

@media (max-width: 560px) {
  .cal-grid { grid-auto-rows: minmax(64px, auto); gap: 3px; }
  .cal-day { border-radius: 7px; padding: 4px; }
  .cal-day__holiday { display: none; }
}
