:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --brand: #0f2b46;
    --primary: #2563eb;
    --danger: #dc2626;
    --radius: 10px;
}

* { box-sizing: border-box; }

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

/* Topbar ----------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--brand);
    color: #fff;
    padding: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 12px; opacity: 0.75; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a {
    color: #cdd6e0;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
}
.topbar nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topbar nav a.active { background: var(--primary); color: #fff; }

main { padding: 20px 24px 60px; max-width: 1800px; margin: 0 auto; }

/* Innlogging / brukere --------------------------------------------------- */
.nav-sep { flex: 1; }
.nav-user { color: #cdd6e0; font-size: 14px; font-weight: 500; padding: 0 4px; }
.nav-logout { background: rgba(255,255,255,0.12); color: #fff; border: none;
    padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; }
.nav-logout:hover { background: rgba(255,255,255,0.25); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 28px; width: min(380px, 94vw); box-shadow: 0 12px 40px rgba(0,0,0,0.15); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand .brand-name { font-weight: 700; font-size: 18px; color: var(--ink); }
.login-brand .brand-sub { font-size: 12px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.inactive-row { opacity: 0.5; }
.nowrap { white-space: nowrap; }
.pw-reset { display: inline-block; }
.pw-reset summary { list-style: none; display: inline-flex; }
.pw-reset summary::-webkit-details-marker { display: none; }

/* Demo-banner ------------------------------------------------------------ */
.demo-banner {
    background: #fef3c7; color: #92400e; text-align: center;
    padding: 8px 16px; font-weight: 600; font-size: 14px;
    border-bottom: 1px solid #fcd34d;
}

/* Flash ------------------------------------------------------------------ */
.flash-wrap { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* Knapper ---------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: #eef1f5; color: var(--ink);
    border: 1px solid var(--line);
    padding: 8px 14px; border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 500;
    text-decoration: none;
}
.btn:hover { background: #e4e8ee; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* Toolbar ---------------------------------------------------------------- */
.toolbar {
    display: flex; align-items: center; gap: 16px;
    flex-wrap: wrap; margin-bottom: 12px;
}
.field-picker { display: flex; align-items: center; gap: 8px; }
.field-picker select, .booking-form select, .booking-form input,
.booking-form textarea, .inline-form input {
    padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; font-family: inherit;
    background: #fff; color: var(--ink);
}
.week-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.week-label { margin-left: 8px; font-weight: 600; color: var(--muted); }
.goto-form { margin: 0; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.export-group { display: flex; align-items: center; gap: 6px; }
.export-label { font-size: 13px; color: var(--muted); }

.legend { display: flex; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Kalender --------------------------------------------------------------- */
.calendar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
}
.cal-head, .cal-body {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
}
.cal-head { border-bottom: 1px solid var(--line); }
.cal-corner { border-right: 1px solid var(--line); }
.cal-day-head {
    text-align: center; padding: 8px 4px;
    border-left: 1px solid var(--line);
}
.cal-day-head.today { background: #eff6ff; }
.cal-day-head .dow { font-weight: 600; font-size: 13px; }
.cal-day-head .dom { font-size: 12px; color: var(--muted); }

.cal-body { position: relative; }
.cal-hours { position: relative; border-right: 1px solid var(--line); }
.hour-label {
    position: absolute; right: 6px; transform: translateY(-50%);
    font-size: 11px; color: var(--muted);
}
.cal-col {
    position: relative;
    border-left: 1px solid var(--line);
    cursor: copy;
}
.cal-col.today { background: #f7faff; }
.hour-line {
    position: absolute; left: 0; right: 0; height: 0;
    border-top: 1px solid #eef1f4;
}

.booking {
    position: absolute;
    border-radius: 6px;
    color: #fff;
    padding: 3px 6px;
    font-size: 11px;
    line-height: 1.25;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    cursor: pointer;
}
.booking:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.45); }
.booking .b-time { font-weight: 700; }
.booking .b-zone { opacity: 0.95; }
.booking .b-team { font-weight: 700; }
.booking .b-club { opacity: 0.9; }
.booking .b-title { font-weight: 600; opacity: 0.98; }
.booking .b-by { opacity: 0.8; }
.booking .b-del {
    position: absolute; top: 1px; right: 2px; margin: 0;
}
.booking .b-del button {
    background: rgba(0,0,0,0.25); color: #fff; border: none;
    width: 16px; height: 16px; border-radius: 4px; cursor: pointer;
    font-size: 12px; line-height: 1; padding: 0;
}
.booking .b-del button:hover { background: rgba(0,0,0,0.5); }

/* Dialog ----------------------------------------------------------------- */
dialog {
    border: none; border-radius: 12px; padding: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: min(460px, 94vw);
}
dialog::backdrop { background: rgba(15,43,70,0.45); }
.booking-form { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.booking-form h2 { margin: 0 0 4px; }
.booking-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.booking-form label input, .booking-form label select, .booking-form label textarea { color: var(--ink); }
.booking-form .row { display: flex; gap: 10px; }
.booking-form .row label { flex: 1; }
.zones { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.zones legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.all-toggle { flex-direction: row !important; align-items: center; gap: 6px !important;
    font-weight: 600; color: var(--ink) !important; margin-bottom: 6px; }
.zone-check { flex-direction: row !important; align-items: center; gap: 6px !important;
    color: var(--ink) !important; padding: 2px 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Kort / lister ---------------------------------------------------------- */
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; }
.muted { color: var(--muted); }
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-card .field-head { display: flex; justify-content: space-between; align-items: center; }
.field-card h2 { margin: 0; font-size: 17px; }
.zone-list { list-style: none; padding: 0; margin: 10px 0; }
.zone-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px; border: 1px solid var(--line);
    border-radius: 8px; margin-bottom: 6px; background: #fafbfc;
}
.link-danger { background: none; border: none; color: var(--danger);
    cursor: pointer; font-size: 16px; line-height: 1; }

.club-table { width: 100%; border-collapse: collapse; }
.club-table th, .club-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.club-table th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.club-table td.right, .club-table .right { text-align: right; }
.color-form { margin: 0; }
input[type=color] { width: 42px; height: 32px; padding: 2px; border: 1px solid var(--line);
    border-radius: 6px; background: #fff; cursor: pointer; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Lag -------------------------------------------------------------------- */
.group-title { margin: 0 0 12px; font-size: 17px; }
.team-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.team-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #eef1f5; border: 1px solid var(--line);
    border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 14px; font-weight: 500;
}
.team-chip form { margin: 0; }
.team-chip button {
    background: rgba(0,0,0,0.12); color: #444; border: none;
    width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
    font-size: 12px; line-height: 1; padding: 0;
}
.team-chip button:hover { background: var(--danger); color: #fff; }

/* Baneoversikt ----------------------------------------------------------- */
.stadium { padding: 12px 16px; }
.stadium h2 { margin: 0 0 8px; padding-left: 12px; font-size: 17px; }
.stadium-grid { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.map-wrap { position: relative; line-height: 0; border-radius: 8px; overflow: hidden; flex: 0 1 auto; }
.map-wrap img { max-height: 33vh; width: auto; max-width: 100%; height: auto; display: block; }
.field-label {
    position: absolute; transform: translate(-50%, -50%);
    color: #fff; font-weight: 800; font-size: 20px; letter-spacing: 0.02em;
    padding: 5px 14px; border-radius: 7px; white-space: nowrap;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* Editor-modus for kartet */
.oversikt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.edit-controls { display: flex; align-items: center; gap: 8px; }
.edit-controls form { margin: 0; }
.edit-badge { background: #dcfce7; color: #166534; padding: 6px 12px;
    border-radius: 8px; font-size: 13px; font-weight: 600; }
.map-toolbar { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.map-hint { font-size: 12px; }
.map-wrap.editable .marker,
.map-wrap.editable .field-label { cursor: move; pointer-events: auto; }
.map-wrap.editable .marker:hover,
.map-wrap.editable .field-label:hover { outline: 2px solid #fff; }
.map-wrap.adding, .map-wrap.adding img { cursor: crosshair; }
.map-legend.editable li { cursor: pointer; padding: 3px 6px; border-radius: 6px; }
.map-legend.editable li:hover { background: #eef1f5; }
.recovery-code { font-size: 24px; font-weight: 800; letter-spacing: 3px;
    text-align: center; padding: 14px; background: #eef1f5; border-radius: 8px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.marker {
    position: absolute; transform: translate(-50%, -50%);
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 15px; line-height: 1;
    border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.map-legend { list-style: none; padding: 0; margin: 0; flex: 0 1 210px;
    display: flex; flex-direction: column; gap: 5px; }
.map-legend li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.marker-badge {
    flex: 0 0 auto;
    width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 13px;
}

@media (max-width: 700px) {
    .stadium-grid { grid-template-columns: 1fr; }
    .marker { width: 24px; height: 24px; font-size: 12px; }
}

@media (max-width: 760px) {
    .cal-head, .cal-body { grid-template-columns: 44px repeat(7, minmax(70px, 1fr)); }
    .calendar { overflow-x: auto; }
    main { padding: 16px 12px 60px; }
}
