:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #25281c;
  --muted: #6b6f5c;
  --moss: #4a5d3a;
  --moss-dark: #38492c;
  --rust: #a8552a;
  --amber: #b07c10;
  --line: #e2ddd0;
  --shadow: 0 2px 10px rgba(40, 45, 28, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #b3261e; min-height: 1.2em; margin: 8px 0 0; font-size: 0.9rem; }
.info { color: var(--moss); min-height: 1.2em; margin: 4px 0 0; font-size: 0.9rem; }
.saved { color: var(--moss); margin-left: 10px; font-size: 0.9rem; }

button {
  cursor: pointer;
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--moss);
  color: #fff;
  transition: background 0.15s ease;
}
button:hover { background: var(--moss-dark); }
button.link {
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  text-decoration: underline;
}
button.link:hover { color: var(--ink); background: none; }
button.ghost {
  background: none;
  color: var(--moss);
  border: 1px solid var(--moss);
  padding: 6px 12px;
}
button.ghost:hover { background: rgba(74, 93, 58, 0.08); }
button.tiny { padding: 4px 10px; font-size: 0.85rem; }
button.danger { background: none; color: var(--rust); padding: 4px 8px; }
button.danger:hover { background: rgba(168, 85, 42, 0.1); }

input, textarea, select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--moss); border-color: var(--moss); }
.mini-form select.cat-select { flex: 0 1 auto; min-width: 140px; width: auto; cursor: pointer; }

/* Auth ---------------------------------------------------------------------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { margin: 0 0 4px; }
.inapp-hint {
  background: #fff6e6;
  border: 1px solid var(--amber);
  color: #6b4e0f;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 16px 0 0;
}
.google-btn {
  width: 100%;
  margin-top: 18px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.google-btn:hover { background: #f4f1ea; }
.or {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 14px 0 2px;
}
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.tabs { display: flex; gap: 6px; margin-top: 20px; }
.tab {
  flex: 1;
  background: #efeadd;
  color: var(--muted);
}
.tab.active { background: var(--moss); color: #fff; }

/* App ----------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  background: var(--moss-dark);
  color: #fff;
  padding: 12px 20px;
  position: relative;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; }
.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.navbtn { background: rgba(255, 255, 255, 0.1); }
.navbtn.active { background: var(--rust); }
.me-name { font-size: 0.9rem; opacity: 0.9; margin-left: auto; }
.logoutbtn { background: rgba(255, 255, 255, 0.08); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; cursor: pointer; }
.logoutbtn:hover { background: rgba(255, 255, 255, 0.18); }
.nav-toggle { display: none; background: rgba(255, 255, 255, 0.14); border: none; color: #fff; font-size: 1.3rem; line-height: 1; padding: 7px 12px; border-radius: 8px; cursor: pointer; }

/* Mobil: samle menyvalg bak hamburger-knappen (☰) */
@media (max-width: 640px) {
  .brand { order: 1; }
  .me-name { order: 2; }
  .nav-toggle { order: 3; display: inline-flex; }
  .nav {
    order: 4;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    display: none;
    margin-top: 8px;
    gap: 8px;
  }
  .nav.open { display: flex; }
  .nav > * { width: 100%; text-align: left; justify-content: flex-start; }
}
.chatbtn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease;
}
.chatbtn:hover { background: rgba(255, 255, 255, 0.2); }
.navbtn-link {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease;
}
.navbtn-link:hover { background: rgba(255, 255, 255, 0.2); }
.who { display: flex; align-items: center; gap: 8px; }
.who #me-name { font-size: 0.9rem; opacity: 0.9; }
.who .link { color: #e8e3d4; }

.container { max-width: 760px; margin: 0 auto; padding: 24px 20px 60px; }
.view h2 { margin-top: 0; }

.inline-form { display: flex; gap: 8px; margin-bottom: 20px; }
.inline-form input { flex: 1; }
.stack-form { display: flex; flex-direction: column; gap: 12px; max-width: 440px; }
.stack-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }

.row-between { display: flex; justify-content: space-between; align-items: center; }

/* Cards --------------------------------------------------------------------- */
.trip-card, .member-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.trip-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.trip-head h3 { margin: 0; }
.trip-head h3.editable { cursor: text; }
.trip-head h3.editable:hover { text-decoration: underline; text-decoration-style: dotted; }
.edit-hint { opacity: 0; font-size: 0.8rem; color: var(--muted); transition: opacity 0.15s ease; }
.trip-head h3.editable:hover .edit-hint { opacity: 1; }
.trip-rename { font-size: 1.1rem; font-weight: 700; max-width: 340px; }
.trip-body { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }

.block { margin-bottom: 18px; }
.block h4 { margin: 0 0 8px; font-size: 0.95rem; color: var(--moss-dark); }

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.option:last-child { border-bottom: none; }
.option .label { flex: 1; }
.option .count {
  background: #efeadd;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 34px;
  text-align: center;
}
.option .voted { background: var(--moss); color: #fff; }
.leading { font-weight: 600; }
.leading .label::after { content: " 🏆"; }

.voters { font-size: 0.8rem; color: var(--muted); }

.locked-banner {
  background: rgba(74, 93, 58, 0.12);
  border: 1px solid var(--moss);
  color: var(--moss-dark);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.option.locked { background: rgba(74, 93, 58, 0.08); border-radius: 6px; }
.option.locked .label::after { content: " 🔒"; }
.locked-note { font-style: italic; }

.add-date-caption { margin: 14px 0 6px; font-size: 0.85rem; font-weight: 600; color: var(--moss-dark); }
.date-form { align-items: center; flex-wrap: nowrap; }
.date-form .date-lbl { color: var(--muted); font-size: 0.85rem; flex: 0 0 auto; }
.date-form input[type="date"] { flex: 1 1 110px; min-width: 110px; }
.date-form button { flex: 0 0 auto; }

/* Kan / Kan ikke ------------------------------------------------------------ */
.avail-yes, .avail-maybe, .avail-no { font-weight: 700; min-width: 30px; padding: 4px 7px; }
.avail-yes { background: none; color: var(--moss); border: 1px solid var(--moss); }
.avail-yes.on { background: var(--moss); color: #fff; }
.avail-maybe { background: none; color: var(--amber); border: 1px solid var(--amber); }
.avail-maybe.on { background: var(--amber); color: #fff; }
.avail-no { background: none; color: var(--rust); border: 1px solid var(--rust); }
.avail-no.on { background: var(--rust); color: #fff; }
.option .count { cursor: default; }

/* Velg-dato-meny under oversikten */
.lock-picker { margin-top: 4px; }
.lock-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9rem; font-weight: 600; color: var(--moss-dark); }
.lock-select { width: auto; min-width: 170px; cursor: pointer; }

/* Tilgjengelighets-matrise -------------------------------------------------- */
.matrix-block { margin-top: 4px; }
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: collapse; font-size: 0.85rem; }
.matrix th, .matrix td {
  border: 1px solid var(--line);
  padding: 4px 7px;
  text-align: center;
  white-space: nowrap;
}
.matrix th { background: #efeadd; color: var(--moss-dark); font-weight: 600; }
.matrix th.corner { background: transparent; border: none; }
.matrix th.locked-col { background: var(--moss); color: #fff; }
.matrix td.mname { text-align: left; font-weight: 600; background: #faf8f2; }
.matrix .cell.yes { color: var(--moss); font-weight: 700; }
.matrix .cell.maybe { color: var(--amber); font-weight: 700; }
.matrix .cell.no { color: var(--rust); }
.matrix .cell.none { color: var(--line); }
.matrix tr.tally td { background: #faf8f2; font-weight: 700; color: var(--moss-dark); }

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.item:last-child { border-bottom: none; }
.item .name { flex: 1; }
.item .cat { font-size: 0.75rem; color: var(--muted); background: #efeadd; border-radius: 6px; padding: 2px 7px; }
.item .by { font-size: 0.85rem; }
.item .by.taken { color: var(--moss); font-weight: 600; }
.item .by.free { color: var(--rust); }

.pending-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.pending-section h3 { margin: 0 0 4px; }

.member-card { display: flex; flex-direction: column; gap: 2px; }
.member-card .name { font-weight: 600; }
.member-card .meta { font-size: 0.88rem; color: var(--muted); }
.member-card button { align-self: flex-start; margin-top: 8px; }

.mini-form { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mini-form input { flex: 1; min-width: 120px; }
