:root {
  --red: #b3202a;
  --red-dark: #8c1820;
  --green: #1f6f43;
  --green-light: #e3f3e9;
  --gold: #e0a526;
  --gold-light: #fdf3dc;
  --bg: #fbf6ef;
  --card: #ffffff;
  --text: #2a2522;
  --muted: #6f6660;
  --border: #e6ddd2;
  --blue-light: #e6f0fb;
  --blue: #2c5d8f;
  --danger-light: #fde4e4;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
}
a { color: var(--red); }
h1 { font-size: 1.9rem; margin: .4em 0 .3em; }
h2 { font-size: 1.3rem; margin: 0 0 .5em; }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .8rem; font-weight: normal; }
.todo { color: var(--red); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 64px; }

/* Topp och meny */
.topbar {
  background: var(--red); color: #fff;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center;
  padding: 12px 16px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.who { display: flex; gap: 12px; align-items: center; font-size: .95rem; flex-wrap: wrap; }
.who form { margin: 0; }
.topbar .btn-link { color: #fff; }
.mainnav {
  background: var(--green); display: flex; overflow-x: auto; gap: 4px; padding: 6px 8px;
  position: sticky; top: 0; z-index: 10;
}
.mainnav a {
  color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; font-size: .85rem; white-space: nowrap; flex: 1 0 auto;
}
.mainnav a span { font-size: 1.4rem; line-height: 1.2; }
.mainnav a.active, .mainnav a:hover { background: rgba(255,255,255,.2); font-weight: 700; }

/* Knappar */
.btn {
  display: inline-block; border: 2px solid var(--border); background: var(--card); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer;
  text-decoration: none; font-family: inherit; margin: 4px 0;
}
.btn:hover { border-color: var(--red); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-big { font-size: 1.2rem; padding: 14px 28px; width: 100%; max-width: 420px; }
.btn-claim { background: var(--gold-light); border-color: var(--gold); }
.btn-vegan { background: var(--green-light); border-color: var(--green); color: var(--green); }
.btn-danger-outline { border-color: var(--red); color: var(--red); background: transparent; }
.btn-link {
  background: none; border: none; padding: 0; color: var(--red); text-decoration: underline;
  cursor: pointer; font-size: .95rem; font-family: inherit;
}
.btn-link.danger { color: var(--red); }
.small-link { font-size: .9rem; margin-left: 6px; }
.back { display: inline-block; margin-top: 8px; text-decoration: none; font-weight: 600; }

/* Meddelanden */
.message { padding: 12px 16px; border-radius: 12px; margin: 8px 0 16px; font-weight: 600; }
.message.success { background: var(--green-light); color: var(--green); }
.message.error { background: var(--danger-light); color: var(--red-dark); }
.error-text { color: var(--red); font-weight: 600; margin: 4px 0; }

/* Kort */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-host { background: var(--gold-light); border-color: var(--gold); margin: 12px 0; }
.plain { list-style: none; padding: 0; margin: 0 0 12px; }
.plain li { padding: 4px 0; }
.plain .subhead { font-weight: 700; margin-top: 6px; }
.small-title { font-size: 1rem; margin: 12px 0 4px; }
.time-chip { display: inline-block; background: var(--gold-light); border-radius: 6px; padding: 0 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: #f1ebe3; }
.badge.vegan { background: var(--green); color: #fff; }
.badge.mine { background: var(--green-light); color: var(--green); }
.badge.taken { background: var(--blue-light); color: var(--blue); }
.holiday-badge { background: var(--red); color: #fff; }
.section-title { margin-top: 32px; }
.empty-state { background: var(--card); border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }
.host-bar { background: var(--gold-light); border: 1px solid var(--gold); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { padding: 4px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .9rem; }
.chip.active { background: var(--red); color: #fff; border-color: var(--red); }
.note { font-style: italic; color: var(--muted); }

/* Formulär */
.form .field { margin-bottom: 16px; }
.form label { display: block; font-weight: 700; margin-bottom: 4px; }
.form input[type=text], .form input[type=password], .form input[type=number], .form input[type=date],
.form input[type=time], .form select, .form textarea {
  width: 100%; font-size: 1.1rem; padding: 12px; border: 2px solid var(--border); border-radius: 10px;
  background: #fff; font-family: inherit; color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 3px solid var(--gold); border-color: var(--gold); }
.narrow { max-width: 520px; }
.check-big {
  display: flex !important; align-items: center; gap: 12px; padding: 14px; border: 2px solid var(--border);
  border-radius: 12px; background: #fff; cursor: pointer; margin-bottom: 16px; font-size: 1.1rem;
}
.check-big input { width: 28px; height: 28px; accent-color: var(--green); }
.check-big:has(input:checked) { border-color: var(--green); background: var(--green-light); }
.delete-form { margin-top: 32px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.inline-form .field { flex: 1 1 220px; margin: 0; }
.inline-form .check-big { margin: 0; padding: 10px 14px; }

.login-box { max-width: 460px; margin: 32px auto; background: var(--card); padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center; }
.login-box .form { text-align: left; }
.big-emoji { font-size: 3.5rem; }

/* Vistelse-formulär */
.step { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 1rem; margin-right: 6px;
}
.help { margin-top: 0; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.choice {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 14px 48px; position: relative;
  border: 2px solid var(--border); border-radius: 12px; cursor: pointer; background: #fff;
}
.choice input { position: absolute; left: 14px; top: 16px; width: 22px; height: 22px; accent-color: var(--red); }
.choice:has(input:checked) { border-color: var(--red); background: #fff5f5; box-shadow: 0 0 0 2px var(--red) inset; }
.choice-title { font-weight: 700; font-size: 1.1rem; }
.choice-sub { color: var(--muted); font-size: .95rem; }
.room-status { font-size: .95rem; font-weight: 600; margin-top: 4px; }
.room-status.ok { color: var(--green); }
.room-status.warn { color: #9a6a00; }
.room-status.bad { color: var(--red); }
.room-choice.full { opacity: .55; cursor: not-allowed; }
.date-inputs { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.date-inputs .field { flex: 1 1 200px; margin: 0; }
.date-summary { margin-top: 12px; font-size: 1.1rem; font-weight: 700; background: var(--gold-light); padding: 10px 14px; border-radius: 10px; }
.date-summary:empty { display: none; }
.stepper { display: flex; gap: 8px; align-items: center; max-width: 260px; }
.stepper .btn { font-size: 1.5rem; width: 56px; padding: 6px 0; margin: 0; }
.stepper input { text-align: center; font-size: 1.4rem !important; font-weight: 700; }

/* Kalender */
.calendar { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.month h3 { margin: 0 0 6px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.weekdays span { text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.day {
  min-height: 62px; border-radius: 10px; border: 2px solid var(--border); background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 2px;
  font-family: inherit; color: var(--text); overflow: hidden;
}
.day .num { font-weight: 700; font-size: 1.05rem; }
.day .hol { font-size: .62rem; color: var(--red); font-weight: 700; line-height: 1.1; text-align: center; }
.day .mark { font-size: .65rem; line-height: 1.1; text-align: center; }
.day.blank { border: none; background: transparent; }
.day.outside { background: transparent; border-color: transparent; color: #c9bfb4; }
.day.holiday { border-color: #f0c6c9; }
button.day { cursor: pointer; }
button.day:hover { border-color: var(--red); }
.day.sel-start, .day.sel-end { background: var(--red); border-color: var(--red); color: #fff; }
.day.sel-start .hol, .day.sel-end .hol { color: #fff; }
.day.sel-range { background: #f8d7d9; border-color: #f0b7bb; }
.day.sleep { background: var(--green-light); border-color: var(--green); }
.day.leave { background: var(--blue-light); border-color: var(--blue); }
.day.visit { background: var(--gold-light); border-color: var(--gold); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.legend-item { padding: 4px 12px; border-radius: 8px; border: 2px solid; font-size: .9rem; }
.legend-item.sleep { background: var(--green-light); border-color: var(--green); }
.legend-item.leave { background: var(--blue-light); border-color: var(--blue); }
.legend-item.visit { background: var(--gold-light); border-color: var(--gold); }

/* Vistelselista */
.stay-list { display: grid; gap: 12px; margin-bottom: 12px; }
.stay-card {
  background: var(--card); border: 1px solid var(--border); border-left: 8px solid var(--green);
  border-radius: var(--radius); padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
}
.stay-card.visit { border-left-color: var(--gold); }
.stay-title { font-size: 1.15rem; }
.stay-actions { display: flex; gap: 8px; align-items: center; }
.stay-actions form { margin: 0; }

/* Översikt */
.summary-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.summary-row { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: none; }
.summary-name { font-weight: 700; }
@media (max-width: 560px) { .summary-row { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.grid-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.grid-table th, .grid-table td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }
.grid-table thead th { background: #f6efe6; position: sticky; top: 0; }
.grid-table tbody th { white-space: nowrap; }
.grid-table td.booked { background: var(--green-light); }
.grid-table td.over { background: var(--danger-light); color: var(--red-dark); font-weight: 700; }
.grid-table td.sleep { background: var(--green-light); }
.grid-table td.visit { background: var(--gold-light); }
.grid-table .center { text-align: center; }
.grid-table .total { font-weight: 700; text-align: center; }
.grid-table .free { color: #c2b8ad; font-size: .8rem; }
.grid-table .empty-row th { color: var(--muted); font-weight: normal; }
.grid-table .holiday-row th { color: var(--red); }

/* Mat */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.stats { font-size: 1rem; }
.vegan-text { color: var(--green); font-weight: 700; }
.dish-group { margin-top: 24px; }
.dishes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.dish {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center;
}
.dish.is-vegan { border: 2px solid var(--green); background: #f6fcf8; }
.dish.is-free { border-style: dashed; }
.dish-name { font-size: 1.15rem; font-weight: 700; margin-right: 6px; }
.dish-who { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dish-who form { margin: 0; }

/* Schema */
.day-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.timeline { list-style: none; padding: 0; margin: 0 0 8px; }
.timeline li { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--border); align-items: flex-start; }
.timeline li:last-child { border-bottom: none; }
.timeline .time { min-width: 76px; font-weight: 800; font-size: 1.25rem; color: var(--red); font-variant-numeric: tabular-nums; }
.timeline .until { display: block; font-size: .9rem; color: var(--muted); font-weight: 600; }
.timeline .what { flex: 1; }
.timeline .what-title { font-size: 1.2rem; font-weight: 700; }
.timeline .what p { margin: 4px 0 0; color: var(--muted); }

/* Familj */
.members { list-style: none; padding: 0; max-width: 520px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.members li { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 1.1rem; }
.members li:last-child { border-bottom: none; }
.members form { margin: 0; }

/* Lediga dagar */
.card-period {
  margin: 12px 0; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  border: 2px solid var(--green); background: var(--green-light);
}
.period-label { font-weight: 700; color: var(--green); }
.period-dates { font-size: 1.3rem; font-weight: 800; }

/* Tidslinje på startsidan */
.timeline-card { margin: 12px 0; padding: 18px 0 12px; }
.timeline-card h2, .timeline-card .tl-legend, .timeline-card .tl-hint { padding: 0 18px; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; font-size: .9rem; }
.tl-key { display: inline-flex; align-items: center; gap: 6px; }
.tl-swatch { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }
.tl-swatch.visit, .tl-bar.visit { background: var(--gold-light); border: 2px solid var(--gold); color: var(--text); }
.tl-hint { margin: 0 0 8px; }
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl { --name-w: 170px; --day-w: 46px; min-width: max-content; }
.tl-row {
  display: grid; grid-template-columns: var(--name-w) repeat(var(--days), var(--day-w));
  row-gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--border); position: relative;
  /* lodräta linjer mellan dagarna */
  background-image: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px var(--day-w));
  background-position: var(--name-w) 0; background-repeat: no-repeat; background-size: calc(100% - var(--name-w)) 100%;
}
.tl-row.mine { background-color: #fff8e8; }
.tl-name {
  grid-column: 1; position: sticky; left: 0; z-index: 2; background: var(--card);
  display: flex; align-items: center; padding: 0 8px 0 14px; font-weight: 700; font-size: .95rem; line-height: 1.2;
  overflow-wrap: anywhere; min-width: 0; overflow: hidden;
  border-right: 2px solid var(--border);
}
.tl-row.mine .tl-name { background: #fff8e8; }
.tl-head { position: sticky; top: 0; z-index: 3; background-color: #f6efe6; }
.tl-head .tl-name { background: #f6efe6; }
.tl-day { grid-row: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 2px 0; font-size: .8rem; }
.tl-day .tl-num { font-weight: 800; font-size: 1rem; }
.tl-day .tl-wd { color: var(--muted); text-transform: capitalize; }
.tl-day .tl-month { color: var(--muted); font-size: .7rem; }
.tl-day.weekend .tl-wd { color: var(--text); font-weight: 700; }
.tl-day.holiday { background: var(--red); color: #fff; border-radius: 8px; }
.tl-day.holiday .tl-wd, .tl-day.holiday .tl-month { color: #fff; }
.tl-bar {
  z-index: 1; margin: 0 2px; border-radius: 10px; color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; gap: 4px; padding: 0 10px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.tl-people { font-weight: 500; opacity: .9; }
.tl-empty { grid-row: 1; align-self: center; padding-left: 10px; color: var(--muted); font-style: italic; }
.tl-today { background: rgba(179, 32, 42, .12); border-left: 2px solid var(--red); z-index: 0; }
@media (max-width: 560px) { .tl { --name-w: 110px; --day-w: 40px; } .tl-name { padding-left: 12px; font-size: .85rem; } }

/* Boka direkt i tidslinjen */
.tl-howto { padding: 0 18px; margin: 0 0 8px; }
.tl-cell {
  z-index: 0; border: none; background: transparent; padding: 0; margin: 0; cursor: pointer; border-radius: 8px;
}
.tl-cell:hover, .tl-cell:focus-visible { background: rgba(179, 32, 42, .12); outline: none; }
.tl-row.editable .tl-empty, .tl-today { pointer-events: none; }
.tl-row.editable .tl-empty { z-index: 1; }
button.tl-bar { border: none; font-family: inherit; cursor: pointer; text-align: left; }
button.tl-bar:hover { filter: brightness(1.1); box-shadow: 0 0 0 2px var(--text); }
.tl-bar.editing { box-shadow: 0 0 0 3px var(--red), 0 0 0 5px #fff inset; }
.tl-selection {
  z-index: 3; pointer-events: none; margin: 0 2px; border-radius: 10px;
  background: rgba(179, 32, 42, .22); border: 3px dashed var(--red);
}
.tl-status { margin: 10px 18px 0; }
.booking { margin: 12px 0; border: 2px solid var(--red); scroll-margin-top: 90px; }
.booking h3 { font-size: 1.05rem; margin: 16px 0 8px; }
.booking .tl-swatch { vertical-align: -3px; }
.bk-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.bk-actions .btn-big { width: auto; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.bk-delete { margin-top: 12px; }
#tidslinje { scroll-margin-top: 90px; }

.bk-dates { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
.bk-dates label { display: flex; flex-direction: row; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; font-weight: 600; font-size: 0.95rem; }
.bk-dates input[type="date"] { width: auto; min-width: 0; padding: 4px 6px; font-size: 0.95rem !important; margin: 0; }

.food-summary {
  background: linear-gradient(180deg, var(--gold-light), #fff 70%);
  border: 2px solid var(--gold); border-top: 6px solid var(--red);
  border-radius: var(--radius); padding: 16px 18px 18px; margin: 14px 0 18px;
  box-shadow: 0 2px 8px rgba(179, 32, 42, .08);
}
.fs-head { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 14px; }
.fs-head h2 { margin: 0; color: var(--red); text-align: center; }
.fs-deco { font-size: 1.6rem; }
.fs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.fs-cat { background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--green); border-radius: 12px; padding: 10px 14px; }
.fs-cat:nth-child(even) { border-left-color: var(--red); }
.fs-cat h3 { margin: 0 0 8px; font-size: 1rem; color: var(--green); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fs-cat:nth-child(even) h3 { color: var(--red); }
.fs-count { background: var(--gold-light); color: var(--text); border: 1px solid var(--gold); border-radius: 999px; font-size: .8rem; padding: 0 9px; }
.fs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fs-chip { background: #f7f1e8; border-radius: 999px; padding: 3px 12px; font-size: .95rem; }
.fs-chip.vegan { background: var(--green-light); color: var(--green); }
.fs-empty { text-align: center; margin: 0; }
