/* Färger och form matchade mot Ianseo Patrullplanering */
:root {
  --navy: #0d3d5c;        /* toppfält, nummerbrickor */
  --navy-deep: #082b42;
  --navy-line: #2b5875;
  --orange: #f28c1c;      /* accent */
  --orange-soft: #fdebd5;
  --paper: #eef1f4;
  --surface: #ffffff;
  --ink: #16283a;
  --muted: #5f6f7e;
  --line: #d6dde4;
  --bow-r: #3f6ea0;       /* blå stapel */
  --bow-dark: #1c1c1c;    /* svart stapel */
  --bow-red: #c9433c;     /* röd stapel */
  --ok: #2f7a47;
  --red: #c9433c;
  --blue: #2a6aa0;
  --radius-s: 6px;
  --radius-m: 10px;
  --head: "Roboto", "Segoe UI", Arial, sans-serif;
  --body: "Roboto", "Segoe UI", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--body); }
a { color: var(--blue); }
a:hover { color: var(--navy); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; line-height: 1.15; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }

/* ---------- Topp och fot ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem clamp(1rem, 4vw, 2.5rem);
  background: var(--navy); color: #fff; border-bottom: 1px solid var(--navy-deep);
}
.topbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1rem; }
.topbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1.6rem; margin-left: auto; }
.topbar .hero-pill { font-size: .9rem; padding: .3rem .7rem; }
.topbar .hero-status { margin-left: 0; font-size: .78rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand:hover { color: #fff; }
.brand small { font-family: var(--mono); font-weight: 500; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--orange); margin-left: .3rem; }
.brand-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 8px;
  background: #2d5a78; color: #fff; box-shadow: 3px 3px 0 var(--orange); }
.brand-mark svg { width: 20px; height: 20px; }
.topbar nav { display: flex; gap: 1.2rem; }
.topbar nav a { color: #fff; text-decoration: none; font-weight: 500; }
.topbar nav a:hover { color: #fff; }
.topbar nav a:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem; }
.site-footer {
  max-width: 1100px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  color: var(--muted); font: .85rem var(--mono); border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); }

.flash { max-width: 1100px; margin: 1rem auto 0; padding: .75rem 1rem; border-radius: var(--radius-s);
  background: #e6f2e9; border-left: 4px solid var(--ok); }
.flash-error { background: #fbe9e7; border-left-color: var(--red); }
@media (max-width: 1160px) { .flash { margin: 1rem clamp(1rem, 4vw, 2.5rem) 0; } }

/* ---------- Toppblock (som Patrullplanering) ---------- */
.hero {
  display: flex; align-items: center; flex-wrap: wrap; gap: .9rem 1rem;
  margin: 1.2rem 0 2rem; padding: 1.3rem clamp(1rem, 3vw, 1.8rem);
  background: var(--navy); color: #fff; border-radius: var(--radius-s);
}
.hero-icon { width: 52px; height: 52px; display: grid; place-items: center; flex: none;
  border-radius: 10px; background: #2d5a78; color: #fff; box-shadow: 4px 5px 0 var(--orange); }
.hero-icon svg { width: 28px; height: 28px; }
.hero .hero-title { margin: 0; color: #fff; font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700;
  padding: .45rem 1rem; border: 1px solid var(--navy-line); border-radius: var(--radius-s); background: rgba(255,255,255,.04); }
.hero-pill { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; padding: .55rem .9rem;
  border: 1px solid var(--navy-line); border-radius: var(--radius-s); color: #dbe6ee; }
.hero-status { display: flex; align-items: center; gap: .6rem; margin-left: auto;
  font-family: var(--mono); font-size: .85rem; letter-spacing: .14em; text-transform: uppercase; color: #cfdde8; }
.hero-status .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px rgba(242,140,28,.25); flex: none; }
@media (max-width: 700px) { .hero-status { margin-left: 0; width: 100%; } }
.list-section .hero { margin: 1.2rem 0 1.2rem; }
.list-section + .list-section .hero { margin-top: 0; }

/* ---------- Tävlingslista (som patrullkort) ---------- */
.list-section { margin-bottom: 2.5rem; }
.list-section > h2 { font-size: 1.2rem; color: var(--navy); }
.list-section.past .comp-list { opacity: .75; }
.comp-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.comp-card {
  position: relative; display: flex; gap: 1rem; align-items: flex-start;
  padding: 1rem 1rem 1.2rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-m);
  color: inherit; text-decoration: none; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.comp-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--bow-r); }
.comp-card.state-open::after { background: var(--orange); }
.comp-card.state-closed::after, .comp-card.state-deadline::after { background: var(--bow-dark); }
.comp-card.state-full::after { background: var(--bow-red); }
.comp-card:hover { color: inherit; border-color: var(--navy); box-shadow: 0 4px 14px rgba(13,61,92,.12); }
.comp-date {
  flex: none; width: 58px; min-height: 58px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--navy); color: #fff; line-height: 1; padding: .4rem 0;
}
.comp-date .day { font-size: 1.55rem; font-weight: 700; }
.comp-date .mon { font-family: var(--mono); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; margin-top: .25rem; color: #cfdde8; }
.state-closed .comp-date, .state-deadline .comp-date { background: #5f6f7e; }
.comp-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.comp-name { font-size: 1.2rem; font-weight: 700; line-height: 1.2; color: var(--ink); }
.comp-where { font-family: var(--mono); font-size: .88rem; color: var(--muted); }
.comp-gren { font-size: .88rem; font-weight: 500; color: var(--navy); }

/* Klubbloggor */
.club-cell { display: inline-flex; align-items: center; gap: .5rem; }
.club-logo { width: 28px; height: 28px; object-fit: contain; flex: none; }
.club-preview { width: 56px; height: 56px; margin-top: .4rem; }
.comp-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; align-items: center; font-size: .88rem; color: var(--muted); margin-top: .35rem; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 4px; font-family: var(--mono); font-weight: 700;
  font-size: .75rem; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--line); background: #f4f6f8; color: var(--muted); }
.badge-open { border-color: var(--orange); background: var(--orange-soft); color: #9a5305; }
.badge-full { border-color: var(--bow-red); background: #fbe9e7; color: var(--bow-red); }
.badge-draft { border-color: #b7c3cd; background: #fff; color: var(--navy); }
.empty { padding: 1.5rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-m); color: var(--muted); }

/* ---------- Tävlingssida ---------- */
.back { margin: 1.5rem 0 .6rem; font-size: .92rem; }
.back a::before { content: "‹ "; }
.comp-head { margin-bottom: 2rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem 1.5rem; margin: 1rem 0 0;
  padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--navy); border-radius: var(--radius-s); }
.facts dt { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.invitation, .register, .entry-list { margin-bottom: 2.5rem; }
.prose { max-width: 70ch; }
.register { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: clamp(1.1rem, 3vw, 2rem); }
.count { display: inline-block; min-width: 2rem; padding: .05rem .5rem; border-radius: 6px; background: var(--navy); color: #fff;
  font: 700 .95rem var(--mono); text-align: center; vertical-align: middle; }

/* ---------- Formulär ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 1.6rem; }
legend { font-family: var(--head); font-weight: 700; font-size: 1.1rem; color: var(--navy); margin-bottom: .6rem; padding: 0; }
.grid { display: grid; gap: 1rem 1.2rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.wide { grid-column: 1 / -1; }
.label { font-weight: 500; font-size: .92rem; }
.label em { font-style: normal; font-weight: 400; color: var(--muted); }
.hint { font-size: .85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: .6rem .7rem; border: 1px solid #b9c5d0; border-radius: var(--radius-s); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy); outline: 2px solid var(--orange); outline-offset: 0; }
input[type=radio], input[type=checkbox] { width: auto; accent-color: var(--navy); transform: scale(1.2); }
[aria-invalid=true], [aria-invalid=true] input { border-color: var(--red); }
.field-error { color: var(--red); font-size: .9rem; font-weight: 600; }
.choices { display: flex; gap: 1.2rem; padding: .55rem 0; }
.choice { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
[hidden] { display: none !important; }

/* Flera skyttar i samma anmälan */
.shooters { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.shooter { position: relative; margin: 0; padding: 1rem 1.1rem 1.2rem; border: 1px solid var(--line);
  border-left: 5px solid var(--orange); border-radius: var(--radius-s); background: #fbfcfd; }
.shooter legend { float: left; width: 100%; margin-bottom: .8rem; }
.shooter legend + * { clear: both; }
.shooter .shooter-remove { position: absolute; top: 1rem; right: 1.1rem; font-size: .92rem; }
.shooter .grid { clear: both; }
.shooter.team { border-left-color: var(--navy); }
.section-title { margin-top: 2.5rem; color: var(--navy); }
.admin-table td.members { white-space: normal; min-width: 220px; font-family: var(--body); font-size: .92rem; }

.btn {
  display: inline-block; font: 500 1rem var(--body); padding: .65rem 1.2rem;
  border: 0; border-radius: var(--radius-s); background: var(--navy); color: #fff; text-decoration: none; cursor: pointer; box-shadow: 3px 3px 0 var(--orange);
}
.btn:hover { background: var(--navy-deep); color: #fff; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--orange); }
.btn-big { font-size: 1.1rem; padding: .85rem 1.6rem; }
.btn-quiet { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.btn-quiet:hover { background: var(--navy); color: #fff; }
.btn-danger { background: var(--red); box-shadow: none; }
.btn-danger:hover { background: #9f241e; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-decoration: underline; }
.linklike.danger { color: var(--red); }

.notice { padding: .8rem 1rem; border-radius: var(--radius-s); background: var(--orange-soft); border-left: 4px solid var(--orange); }
.notice.ok { background: #e6f2e9; border-left-color: var(--ok); }
.notice.error { background: #fbe9e7; border-left-color: var(--red); }

/* ---------- Tabeller ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: #dbe6ee; background: var(--navy); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.admin-table td { white-space: nowrap; }
.admin-table td:first-child { white-space: normal; min-width: 180px; }
.comment { font-size: .85rem; color: var(--muted); white-space: normal; max-width: 280px; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.warn { color: var(--red); font-size: .85rem; }
.row-actions { display: flex; gap: .8rem; align-items: baseline; }
.row-actions form { margin: 0; }

/* ---------- Admin ---------- */
.panel { padding-top: .5rem; }
.panel.narrow { max-width: 440px; margin: 2.5rem auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 1.8rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0 1rem; }
.panel-head h1 { margin: 0; }
.back + .panel-head { margin-top: 0; }
.head-links { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.admin-list { display: grid; gap: .8rem; }
.admin-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: var(--radius-s); }
.admin-row-main { display: flex; flex-direction: column; gap: .15rem; }
.admin-row-title { font-size: 1.15rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.admin-row-actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-weight: 500; }
.toolbar { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1.2rem 0; }
.summary { margin-bottom: 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: .7rem 1rem; }
.summary summary { cursor: pointer; font-weight: 500; color: var(--navy); }
.summary-list { list-style: none; padding: 0; margin: .6rem 0 0; columns: 2 220px; }
.summary-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border-bottom: 1px dotted var(--line); break-inside: avoid; }
.danger-zone { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.entry-form textarea.mono { font-size: .88rem; line-height: 1.5; }

.export-options { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.2rem; margin-bottom: 1.2rem; }
.export-options fieldset.checks { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; }
.export-options fieldset.checks legend { font-size: 1.1rem; width: 100%; }
.export-box { margin-bottom: 2rem; }
.export-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; margin-bottom: .6rem; }
.export-box textarea { background: #fbfcfb; white-space: pre; overflow: auto; }
.howto ol { padding-left: 1.3rem; max-width: 68ch; }
.howto li { margin-bottom: .4rem; }

/* Klubbnamn i monospace som i Ianseo-modulen */
.entry-list td:nth-child(2), .admin-table td:nth-child(3) { font-family: var(--mono); font-size: .88rem; }
.panel-head h1, .panel h1 { color: var(--navy); }
