/* Kontrastverdiene i kommentarene er målt mot --surface (#fffdf8).
   WCAG krever 4.5:1 for tekst og 3:1 for rammer og andre grafiske elementer.
   Den gamle --line lå på 1.33:1, som gjorde rutenett og felt nærmest
   usynlige for svaksynte. */
:root {
  --bg: #f5f0e8;
  --surface: #fffdf8;
  --ink: #241f1a;        /* 16.06:1 */
  --muted: #5b544b;      /*  7.34:1 */
  --brand: #6d4220;      /*  8.43:1 */
  --danger: #a12626;
  --line: #96826a;       /*  3.63:1 - rammer og rutenett */

  /* Røde dager og merkedager i kalenderen */
  --sunday: #9c1c1c;     /*  7.96:1 */
  --sunday-bg: #fdf1ef;
  --holiday-bg: #fbe4e2;
  --marked-bg: #f6ecdc;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, #f0e4d2, var(--bg) 45%);
  color: var(--ink);
}

.wrap {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(4px);
}

.topbar .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

nav a:hover { color: var(--ink); }
nav a.site-link { color: var(--brand); font-weight: 600; }

main.wrap { padding: 1.5rem 0 2rem; }

h1, h2, h3 { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.narrow {
  width: min(420px, 100%);
  margin: 3rem auto;
}

.stats {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stat p {
  font-size: 1.8rem;
  margin: 0;
  color: var(--brand);
}

.stat .muted {
  display: block;
  margin-top: 0.35rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #d9c8b4;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: #fff;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.check input { width: auto; }

.full { grid-column: 1 / -1; }

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

.inline-form {
  display: flex;
  gap: 0.6rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.btn, button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0.48rem 0.75rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.secondary {
  background: #b7a487;
  color: #231b14;
}

.btn.danger {
  background: var(--danger);
}

.btn.small {
  padding: 0.3rem 0.55rem;
  font-size: 0.84rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

.actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.actions-row {
  display: flex;
  gap: 0.5rem;
}

.flash-wrap { margin-bottom: 0.9rem; }

.flash {
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.45rem;
}

.flash.success {
  background: #def5e6;
  border: 1px solid #8dd3a6;
}

.flash.error {
  background: #fde6e6;
  border: 1px solid #ef9f9f;
}

.flash.info {
  background: #eef4fb;
  border: 1px solid #a9c7e8;
}

.conflict-flag {
  margin-bottom: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid #e8aa6f;
  background: #fff4e8;
  color: #6e3d12;
}

.conflict-meta {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  color: #875126;
}

.hidden {
  display: none !important;
}

.datetime-field {
  display: grid;
  gap: 0.35rem;
}

.date-time-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1.25fr) minmax(110px, 0.8fr);
}

/* Heldagsbooking (utleie): klokkeslettet er skjult, datoen tar hele bredden. */
.date-time-grid.date-only {
  grid-template-columns: minmax(0, 1fr);
}

.status-note {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-scroll {
  overflow-x: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-forespurt { background: #fdf0d0; color: #6d4c00; }
.status-reservert { background: #e9ecff; color: #3447a6; }
.status-godkjent { background: #def5e6; color: #25663d; }
.status-avslatt { background: #fde6e6; color: #8e2b2b; }
.status-avlyst { background: #f1ece6; color: #6f685f; }
.status-gjennomfort { background: #e2f0fb; color: #265b89; }

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

.stack-sm {
  display: grid;
  gap: 0.75rem;
}

.metric-row,
.request-snippet {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child,
.request-snippet:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.qr-card {
  text-align: center;
}

.qr-image {
  width: min(220px, 100%);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.75rem;
}

.qr-image.small {
  width: min(160px, 100%);
}

.cards-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.subtle-box {
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed #d9c8b4;
  border-radius: 10px;
  padding: 0.9rem;
}

.booking-form {
  align-items: start;
}

.quick-status {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.icon-picker {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.icon-choice {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  text-align: center;
  padding: 0.75rem 0.65rem;
  border: 1px solid #d9c8b4;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.icon-choice.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(127, 79, 36, 0.15);
}

.icon-choice-image {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.icon-choice-image img {
  width: 36px;
  height: 36px;
}

.icon-none {
  font-size: 0.82rem;
  color: var(--muted);
}

.dialog-card {
  border: 0;
  border-radius: 16px;
  padding: 1.1rem;
  width: min(460px, 92vw);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 45px rgba(45, 42, 38, 0.22);
}

.dialog-card::backdrop {
  background: rgba(45, 42, 38, 0.35);
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

.hero-text {
  max-width: 62ch;
}

.hidden-field {
  position: absolute;
  left: -9999px;
}

.request-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.65);
}

.request-card h3 {
  margin-bottom: 0.4rem;
}

.request-meta {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.request-actions {
  display: grid;
  gap: 0.75rem;
}

.request-actions textarea {
  min-height: 90px;
}

.status-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.year-filter-form select {
  min-width: 110px;
}

.month-type-card {
  margin-bottom: 1rem;
}

.month-type-card .row-between {
  margin-bottom: 0.55rem;
}

.month-type-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, max-content));
  gap: 0.5rem 0.9rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.35rem;
}

.month-type-list {
  display: grid;
  gap: 0.6rem;
}

.month-type-row {
  display: grid;
  gap: 0.35rem;
}

.month-type-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.month-type-bar {
  height: 13px;
  border-radius: 999px;
  background: #eadfce;
  overflow: hidden;
  display: flex;
}

.segment {
  height: 100%;
}

.segment-mote {
  background: #9b7d5b;
}

.segment-utleie {
  background: #7f4f24;
}

.segment-barneaktivitet {
  background: #cf9a54;
}

.segment-annet {
  background: #b8a089;
}

.chart-list {
  display: grid;
  gap: 0.6rem;
}

.chart-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.bar-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #eadfce;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #cc9e67, #7f4f24);
}

.line-chart-card {
  margin-top: 1rem;
}

.line-chart-wrap {
  position: relative;
  width: 100%;
  padding-top: 0.75rem;
  overflow-x: auto;
}

#typeLineChart {
  width: 100%;
  height: auto;
  min-height: 280px;
}

.line-chart-grid {
  stroke: #eadfce;
  stroke-width: 1;
}

.line-chart-axis {
  stroke: #d4c6b2;
  stroke-width: 1.5;
}

.line-chart-label {
  fill: #6f6558;
  font-size: 12px;
  text-anchor: middle;
}

.line-chart-y-label {
  fill: #8b7c69;
  font-size: 11px;
}

.line-chart-y-label-left {
  text-anchor: end;
}

.line-chart-y-label-right {
  text-anchor: start;
}

.line-chart-point {
  cursor: pointer;
}

.line-chart-point:hover {
  stroke: #ffffff;
  stroke-width: 1.5;
}

.line-chart-tooltip {
  position: absolute;
  z-index: 5;
  background: #2e2419;
  color: #f7f1e8;
  font-size: 0.82rem;
  line-height: 1.2;
  padding: 0.36rem 0.5rem;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.public-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
}

.info-list {
  display: grid;
  gap: 0.55rem;
}

.cleaning-access {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .form-grid.two-col { grid-template-columns: 1fr; }
  .row-between { align-items: stretch; flex-direction: column; }
  .public-layout { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .field-with-action { grid-template-columns: 1fr; }
  .date-time-grid { grid-template-columns: 1fr; }
}
