:root {
  /* Vintertema «Isblå» — kjølig isbreblå. Bytt disse tre for annet tema. */
  --primary: #26617d;
  --primary-dark: #1d4d63;
  --primary-light: #dbeaf1;
  --bg: #eef3f6;
  --card: #ffffff;
  --text: #1c2b31;
  --muted: #5f7480;
  --border: #d3dde3;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  background: var(--primary);
  color: #fff;
  padding: 0 1rem;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  margin-right: auto;
}
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
  color: #fff;
  padding: .4rem .7rem;
  border-radius: 6px;
  font-size: .95rem;
}
.topbar nav a:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.22); }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }

.auth-wrap { max-width: 400px; margin: 3rem auto; }

label { display: block; font-weight: 600; margin: .75rem 0 .25rem; font-size: .9rem; }
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .55rem 1.1rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.secondary:hover { background: var(--primary-light); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a5281c; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; }

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; }
.flashes li {
  padding: .7rem 1rem;
  border-radius: 6px;
  margin-bottom: .5rem;
  font-size: .95rem;
}
.flashes .error { background: var(--danger-bg); color: var(--danger); }
.flashes .success { background: var(--primary-light); color: var(--primary-dark); }
.flashes .info { background: #eef2f7; color: #33475b; }

.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Booking-rutenett */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.day-nav .today-label { font-weight: 700; font-size: 1.1rem; }

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .6rem;
}
.slot {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem;
  background: #fff;
}
.slot .hour { font-weight: 700; font-size: 1.05rem; }
.slot.free { border-style: dashed; }
.slot.booked { background: var(--primary-light); border-color: var(--primary); }
.slot.mine { background: #fff7e6; border-color: #e0a800; }
.slot.past { opacity: .45; }
.slot .who { font-size: .85rem; color: var(--muted); margin: .2rem 0; }
.slot form { margin: 0; }

/* Tabeller */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.badge.admin { background: #fdecea; color: var(--danger); }
.badge.warn { background: #fff3cd; color: #7a5c00; }

/* Turneringsmatrise */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; min-width: max-content; }
table.matrix th, table.matrix td {
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  padding: .5rem;
  min-width: 90px;
}
table.matrix th.corner { background: var(--primary); color: #fff; }
table.matrix th { background: var(--primary-light); font-size: .8rem; white-space: nowrap; }
table.matrix td.self { background: #f0f0f0; }
table.matrix td a { display: block; }
table.matrix .winner-name { font-size: 1.05rem; font-weight: 700; color: var(--primary-dark); line-height: 1.2; }
table.matrix .draw-name { font-size: 1rem; font-weight: 700; color: var(--muted); }
table.matrix .course-name { font-size: .72rem; color: var(--muted); display: block; margin-top: .15rem; }
table.matrix .pending { color: var(--muted); font-size: .8rem; }

.inline-form { display: inline; }

/* Booking: to kolonner med månedskalender til venstre */
.booking-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.calendar { flex: 0 0 230px; }
.booking-main { flex: 1; min-width: 0; }
@media (max-width: 680px) {
  .booking-layout { flex-direction: column; }
  .calendar { flex: none; width: 100%; max-width: 340px; margin: 0 auto; }
}

.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem;
}
.cal-title { font-weight: 700; font-size: 1rem; }
.cal-nav {
  padding: .15rem .55rem; border: 1px solid var(--border);
  border-radius: 6px; color: var(--primary); font-weight: 700;
}
.cal-nav:hover { background: var(--primary-light); text-decoration: none; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center; font-size: .72rem; color: var(--muted);
  font-weight: 600; padding: .2rem 0;
}
.cal-day {
  position: relative; text-align: center; padding: .45rem 0;
  border-radius: 6px; color: var(--text); font-size: .85rem;
}
.cal-day:hover { background: var(--primary-light); text-decoration: none; }
.cal-day.other-month { color: var(--muted); opacity: .45; }
.cal-day.today { border: 1px solid var(--primary); }
.cal-day.selected { background: var(--primary); color: #fff; font-weight: 700; }
.cal-dot {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.cal-day.selected .cal-dot { background: #fff; }

/* Maskotfigur i sidetopp */
.page-hero {
  display: flex; align-items: stretch; gap: 1rem;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem 0;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.page-hero .hero-text { flex: 1; align-self: center; padding-bottom: 1.1rem; }
.page-hero .hero-text h1 { margin: 0 0 .3rem; }
.page-hero .hero-text p { margin: 0; }
.hero-fig { height: 150px; width: auto; flex: none; align-self: flex-end; display: block; }
@media (max-width: 680px) {
  .page-hero { padding: .9rem 1rem 0; }
  .hero-fig { height: 105px; }
}

/* Turnering: spillervalg med avkrysning */
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .4rem;
}
.player-check {
  display: flex; align-items: center; gap: .5rem; margin: 0;
  padding: .55rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-weight: 400;
}
.player-check input { width: auto; }
.player-check:hover { background: var(--primary-light); }

/* Resultatliste – kompakt så den får plass på mobil (scroller i matrix-wrap ved behov) */
table.standings th, table.standings td { padding: .45rem .4rem; white-space: nowrap; }
table.standings .standings-name { white-space: normal; }
table.standings td:first-child, table.standings th:first-child { padding-left: .25rem; text-align: right; color: var(--muted); }
@media (max-width: 680px) {
  table.standings th, table.standings td { padding: .4rem .3rem; font-size: .92rem; }
}

/* Generisk liste-rad (stables pent på mobil) – brukes for turneringer, bookinger m.m. */
.list-stack { display: flex; flex-direction: column; gap: .5rem; }
.list-row {
  display: flex; align-items: center; gap: .75rem;
  border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem;
}
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-weight: 700; font-size: 1.05rem; display: inline-block; }
.list-row-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.list-row-meta .muted { font-size: .85rem; }
.list-row form { flex: none; margin: 0; }
.list-row > .btn { flex: none; }

/* Admin: brukerkort (stables på mobil, flere kolonner på desktop) */
.user-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
}
.user-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .8rem 1rem;
}
.user-card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.user-name { font-weight: 700; font-size: 1.05rem; }
.user-meta { font-size: .85rem; margin-bottom: .7rem; word-break: break-word; }
.user-hcp { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; margin-bottom: .7rem; }
.hcp-field {
  display: flex; flex-direction: column; gap: .2rem; margin: 0;
  font-size: .78rem; color: var(--muted); font-weight: 600;
}
.hcp-field input { width: 90px; }
.user-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Mobil: unngå iOS-zoom (input < 16px zoomer inn ved fokus) og større trykkflater */
@media (max-width: 680px) {
  input[type=text], input[type=email], input[type=password],
  input[type=number], input[type=date], select, textarea {
    font-size: 16px;
  }
  .cal-day { padding: .6rem 0; }
  .btn.small { padding: .45rem .7rem; }
}
