/* Fargeprofil hentet fra logoen «Banen»: skifer, krem og en dempet terrakotta. */
:root {
  --ink: #2F4858;          /* skifer – logoens bakgrunn */
  --ink-deep: #233846;
  --cream: #EDE6DA;        /* logoens linjer */
  --clay: #E3A587;         /* logoens ball */
  --clay-strong: #B8684A;  /* mørkere terrakotta for tekst og detaljer */

  --bg: #F6F3EE;
  --card: #FFFDFA;
  --text: #1E2B34;
  --muted: #5F6B72;
  --line: #E4DED3;
  --field: #EFEAE1;        /* rolig flate for tabellhoder o.l. */
  --accent: var(--ink);
  --accent-text: #FFFFFF;
  --accent-soft: #E7EDEF;
  --highlight: var(--clay-strong);
  --danger: #B3432F;
  --conflict: #F6D9CF;
  --break: #F1E8DA;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 56, 70, .05), 0 6px 18px rgba(35, 56, 70, .06);
  --focus: 0 0 0 3px rgba(47, 72, 88, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #172229;
    --card: #1E2C35;
    --text: #ECE7DF;
    --muted: #A3ADB2;
    --line: #2F404B;
    --field: #24343E;
    --accent: #C9D6DC;
    --accent-text: #172229;
    --accent-soft: #263A45;
    --highlight: #E3A587;
    --danger: #E58B76;
    --conflict: #5A3328;
    --break: #2B3A40;
    --shadow: none;
    --focus: 0 0 0 3px rgba(227, 165, 135, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; margin: 18px 0 10px; }
h2:first-child { margin-top: 0; }
h3 { font-size: .98rem; font-weight: 700; margin: 14px 0 6px; }
.muted { color: var(--muted); font-size: .9rem; }
.info { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 8px; padding: 9px 12px; font-weight: 600; margin: 10px 0; }
.info:empty { display: none; }
small { font-weight: normal; opacity: .8; }
a { color: var(--highlight); text-underline-offset: 2px; }

/* Ikoner (linjeikoner som arver tekstfargen) */
.i { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Toppmeny */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--cream);
  box-shadow: 0 2px 10px rgba(23, 34, 41, .18);
}
.brand { font-weight: 800; font-size: 1.08rem; letter-spacing: -.01em; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 34px; border-radius: 22%; display: block; box-shadow: 0 0 0 1px rgba(237, 230, 218, .25); }
.sport-badge { font-size: 1rem; font-weight: normal; }
.sport-badge:empty { display: none; }
.top-actions { display: flex; gap: 8px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab {
  position: relative;
  border: 0; background: none; color: rgba(237, 230, 218, .72);
  padding: 8px 12px; border-radius: 8px; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--cream); background: rgba(237, 230, 218, .08); }
.tab.active { color: #fff; }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 1px; height: 3px; border-radius: 3px; background: var(--clay); }
.topbar .btn { background: rgba(237, 230, 218, .1); border-color: rgba(237, 230, 218, .22); color: var(--cream); }
.topbar .btn:hover { background: rgba(237, 230, 218, .18); border-color: rgba(237, 230, 218, .4); }
.topbar .btn.primary { background: var(--cream); border-color: var(--cream); color: var(--ink-deep); }
.topbar .btn.primary:hover { background: #fff; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px 4px; row-gap: 6px; }
  .brand span:not(.logo) { display: none; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -8px; }
  .top-actions { margin-left: auto; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 8px 11px; }
}

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > .card { margin-bottom: 0; }
.cols + .card { margin-top: 16px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--muted); }
label[hidden] { display: none; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; font-weight: 500; margin: 7px 0; }

input, select, textarea {
  font: inherit; font-weight: 500; color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #CFC6B8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--ink); }
input[type=color] { width: 42px; height: 32px; padding: 2px; }
input.short { max-width: 110px; }
input.tiny { max-width: 64px; }
textarea { resize: vertical; }

.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.row.end { justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  flex-direction: row;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(.9); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

.icon { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .95rem; padding: 4px 8px; border-radius: 6px; }
.icon:hover { color: var(--danger); background: var(--conflict); }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--field); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }
.badge:empty { display: none; }

/* Tabeller */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
table.list th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 6px 4px; }
table.list td { padding: 3px 4px; vertical-align: middle; }
table.list tr.absent input:not([type=checkbox]) { opacity: .45; text-decoration: line-through; }

table.grid { min-width: 700px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 4px; vertical-align: top; }
table.grid th { background: var(--field); font-size: .82rem; font-weight: 700; text-align: left; padding: 7px 8px; }
table.grid select { font-size: .85rem; padding: 4px 6px; }
table.grid td.time { white-space: nowrap; width: 1%; }
table.grid td.time input { width: 64px; padding: 4px; font-size: .85rem; }
table.grid td.time input + input { margin-top: 2px; }
table.grid tr.break td { background: var(--break); text-align: center; font-weight: 600; }
table.grid tr.break td input { text-align: center; font-weight: 600; background: transparent; }
td.conflict select, select.conflict { background: var(--conflict); }
td.assign { display: flex; flex-wrap: wrap; gap: 4px; }
td.assign select { flex: 1 1 180px; }
.match-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }
#ref-schedule select + select { margin-top: 2px; }

/* Laginndeling */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.team-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.team-head { padding: 9px 12px; font-weight: 700; }
.team-card.unassigned .team-head { background: var(--field); }
.team-coach { padding: 3px 12px; font-size: .85rem; color: var(--muted); min-height: 1.2em; }
.team-card ul { list-style: none; margin: 0; padding: 4px 12px 10px; }
.team-card li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.team-card li:last-child { border-bottom: 0; }
.team-card li select { width: auto; max-width: 130px; font-size: .8rem; padding: 2px 4px; }

.counts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.counts li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 0; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 3px 0; }

/* Forside */
.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 28px;
  padding: 32px 36px; margin-bottom: 24px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--cream);
}
.eyebrow { font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--clay); margin-bottom: 10px; }
.hero h1 { font-size: 2rem; color: #fff; margin-bottom: 10px; }
.hero p { margin: 0; max-width: 58ch; font-size: 1.02rem; color: rgba(237, 230, 218, .88); }
.hero a { color: var(--clay); font-weight: 700; }
.hero-art { width: 230px; flex: none; color: rgba(237, 230, 218, .55); }
@media (max-width: 700px) {
  .hero { padding: 24px 22px; }
  .hero h1 { font-size: 1.45rem; }
  .hero-art { position: absolute; right: -50px; bottom: -40px; width: 200px; opacity: .25; }
}
.section-title { margin-top: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.lead { font-size: 1.02rem; max-width: 80ch; }

/* Regler og råd */
.rights { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.right { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--field); }
.right-no {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--cream); font-weight: 700; font-size: .85rem;
}
.right p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.ages { list-style: none; padding: 0; margin: 0; }
.ages li { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ages li:last-child { border-bottom: 0; }
.age {
  flex: 0 0 56px; text-align: center; font-weight: 700; font-size: .88rem;
  padding: 3px 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.checks, .tips { padding-left: 0; list-style: none; }
.checks li, .tips li { position: relative; padding: 5px 0 5px 26px; }
.checks li::before {
  content: ""; position: absolute; left: 3px; top: 11px; width: 10px; height: 5px;
  border-left: 2px solid var(--highlight); border-bottom: 2px solid var(--highlight); transform: rotate(-45deg);
}
.tips li::before { content: ""; position: absolute; left: 4px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--clay); }

/* Dialog og melding */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text);
  padding: 22px; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(23, 34, 41, .25);
}
dialog::backdrop { background: rgba(23, 34, 41, .45); }

#toast {
  font-weight: 600;
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(30px);
  background: var(--ink-deep); color: var(--cream); padding: 11px 18px; border-radius: 10px;
  border-left: 4px solid var(--clay);
  max-width: calc(100vw - 32px);
  box-shadow: 0 10px 30px rgba(23, 34, 41, .25);
  opacity: 0; pointer-events: none; transition: .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Utskrift / PDF ---------- */
#print-area { display: none; }

@page { size: A4 landscape; margin: 10mm; }

/* Utskriftsversjonen (brukes både ved utskrift og «Lagre som PDF») */
.p-doc { background: #fff; color: #1E2B34; font-size: 10pt; font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.p-runhead, .p-runfoot { font-size: 8pt; font-weight: 600; color: #2F4858; text-align: left; letter-spacing: .02em; }
.p-runhead { padding-bottom: 1.5mm; border-bottom: .3mm solid #2F4858; margin-bottom: 3mm; }
.p-runfoot { padding-top: 1.5mm; border-top: .3mm solid #2F4858; background: #fff; }
.p-wrap { width: 100%; border-collapse: collapse; }
.p-wrap > * > tr > td { padding: 0; border: 0; }

.p-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 12px; border-radius: 10px; background: #2F4858; color: #EDE6DA; }
.p-logo { width: 36px; height: 36px; flex: none; box-shadow: 0 0 0 1px rgba(237, 230, 218, .3); border-radius: 22%; }
.p-sub { font-weight: 700; font-size: 8pt; text-transform: uppercase; letter-spacing: .16em; color: #E3A587; }
.p-title { font-weight: 800; font-size: 14pt; color: #fff; line-height: 1.2; }
.p-meta { font-size: 8.5pt; color: rgba(237, 230, 218, .85); }

.p-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-bottom: 10px; border: 1px solid #D6CFC3; border-radius: 8px; overflow: hidden; }
.p-table th, .p-table td { border-right: 1px solid #E4DED3; border-bottom: 1px solid #E4DED3; padding: 3px 7px; text-align: left; font-size: 9pt; vertical-align: top; }
.p-table tr > :last-child { border-right: 0; }
.p-table tbody tr:last-child td { border-bottom: 0; }
.p-table thead th { background: #2F4858; color: #fff; border-color: #44606F; font-weight: 700; font-size: 8.5pt; }
.p-table tbody tr:nth-child(even):not(.p-break) td { background: #F8F5F0; }
.p-table td:first-child { font-weight: 600; color: #2F4858; white-space: nowrap; }
.p-table tr.p-break td { background: #F1E6D6; color: #8A4E37; text-align: center; font-weight: 700; }
.p-table tr.p-break td:first-child { text-align: left; color: #8A4E37; }
.p-small { width: auto; min-width: 40%; break-inside: avoid; page-break-inside: avoid; }
.p-tasks td { font-size: 10pt; padding: 7px; }
.p-match { font-size: 8pt; color: #5F6B72; font-weight: 400; }

.p-teams { display: flex; gap: 10px; }
.p-team { flex: 1; border: 1px solid #D6CFC3; border-radius: 8px; overflow: hidden; }
.p-team-name { font-weight: 700; padding: 6px 9px; }
.p-download .p-page { padding-top: 4px; }
.p-team-coach { padding: 3px 9px; border-bottom: 1px solid #E4DED3; font-size: 8.5pt; color: #5F6B72; }
.p-team ol { margin: 0; padding: 8px 9px 10px 30px; font-weight: 600; font-size: 11pt; }
.p-team li { padding: 2px 0; }
.p-team li::marker { color: #B8684A; }


@media print {
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar::after { display: none; }
  .topbar, main, dialog, #toast { display: none !important; }
  #print-area { display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .p-runfoot { position: fixed; left: 0; right: 0; bottom: 0; }
  .p-footspace { height: 10mm; }
  .p-page { break-after: page; page-break-after: always; }
  .p-page:last-child { break-after: auto; page-break-after: auto; }
}
