:root {
  --navy: #16213e;
  --navy-deep: #0d1526;
  --navy-soft: #1f2d4d;
  --gold: #b89150;
  --gold-soft: #cda968;
  --gold-tint: #f6efe2;
  --gold-text: #8a6a2f; /* mørkere gull for tekst på lys bakgrunn (god nok kontrast) */
  --silver: #e8eaef;
  --silver-light: #f4f5f8;
  --paper: #fbfbfd;
  --card: #ffffff;
  --ink: #0d1526;
  --muted: #5a6275;
  --line: rgba(22, 33, 62, .12);
  --up: #1d7a4c;
  --up-tint: #e6f3ec;
  --down: #b3362d;
  --down-tint: #fbeceb;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(13, 21, 38, .05), 0 8px 24px rgba(13, 21, 38, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); line-height: 1.55; -webkit-font-smoothing: antialiased; font-size: 15px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: .01em; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; border-radius: 4px; }
.topbar :focus-visible, .login-hero :focus-visible, .toast :focus-visible, .skip-link:focus-visible { outline-color: var(--gold-soft); }
[tabindex="-1"]:focus { outline: none; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--navy-deep); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }
.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

/* ---------- Knapper og felt ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 10px 18px; font-weight: 600; font-size: 14px; transition: background .15s, border-color .15s, opacity .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover:not(:disabled) { background: #a98243; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: var(--navy-soft); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--gold); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 6px; }
.btn-buy { background: var(--up-tint); color: var(--up); }
.btn-buy:hover { background: #d4eadd; }
.btn-sell { background: var(--down-tint); color: var(--down); }
.btn-sell:hover { background: #f5dad8; }
.btn-link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 11px 13px; font-size: 16px; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(184, 145, 80, .35); }
.error-text { color: var(--down); font-size: 13px; margin-top: 8px; min-height: 1em; }

/* ---------- Innlogging ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--navy-deep); }
.login-hero { position: relative; padding: 56px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; background: radial-gradient(ellipse at 20% 0%, rgba(184, 145, 80, .18), transparent 60%), linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 70%); }
.login-hero .brand img { height: 44px; }
.login-hero h1 { font-size: clamp(40px, 5vw, 64px); margin: 24px 0 16px; }
.login-hero h1 em { font-style: normal; color: var(--gold-soft); }
.login-hero p.lead { color: rgba(255, 255, 255, .72); max-width: 460px; font-size: 17px; }
.hero-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 32px; justify-content: start; margin-top: 40px; }
.hero-facts b { display: block; font-family: var(--serif); font-size: 30px; color: var(--gold-soft); font-weight: 600; }
.hero-facts span { font-size: 13px; color: rgba(255, 255, 255, .6); }
.hero-chart { position: absolute; right: -40px; bottom: 80px; width: 70%; opacity: .16; pointer-events: none; }
.login-panel { background: var(--paper); display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 32px; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-bottom: 24px; }
.login-card .btn { width: 100%; padding: 12px; }
.login-foot { margin-top: 20px; font-size: 13px; color: var(--muted); }
.demo-note { background: var(--gold-tint); border: 1px solid rgba(184, 145, 80, .35); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 20px; color: #6b5328; }

/* ---------- App-ramme ---------- */
.topbar { background: var(--navy-deep); color: #fff; position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 28px; }
.topbar .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.topbar .brand img { height: 30px; }
.topbar .brand span { font-family: var(--serif); font-size: 20px; font-weight: 600; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { text-decoration: none; padding: 8px 14px; border-radius: 6px; font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, .68); white-space: nowrap; }
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.tabs a.active { color: #fff; background: rgba(184, 145, 80, .22); box-shadow: inset 0 -2px 0 var(--gold); }
.user-menu { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255, 255, 255, .7); flex-shrink: 0; }
.user-menu b { color: #fff; font-weight: 600; }
.user-menu button { background: none; border: 1px solid rgba(255, 255, 255, .2); color: rgba(255, 255, 255, .85); border-radius: 6px; padding: 5px 10px; font-size: 13px; }
.user-menu button:hover { border-color: var(--gold); }

.statusbar { background: var(--navy); color: rgba(255, 255, 255, .78); font-size: 13px; }
.statusbar-in { max-width: 1180px; margin: 0 auto; padding: 8px 24px; display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: #7a8296; }
.dot.open { background: #3ecf8e; box-shadow: 0 0 0 3px rgba(62, 207, 142, .2); }
.dot.gold { background: var(--gold-soft); }
.demo-pill { margin-left: auto; background: var(--gold); color: #fff; font-weight: 600; font-size: 11px; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; }
.demo-pill button { background: none; border: 0; color: #fff; text-decoration: underline; font-size: 11px; margin-left: 6px; }

main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 38px; }
.page-head p { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 22px; }
.card-body { padding: 20px; }
.stack > * + * { margin-top: 20px; }

/* ---------- Nøkkeltall ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 18px 20px; }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
.kpi .value { font-variant-numeric: lining-nums; font-family: var(--serif); font-size: 32px; font-weight: 600; margin-top: 4px; line-height: 1.1; }
.kpi .sub { font-size: 13px; margin-top: 4px; }
.kpi.hl { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.hl .label { color: rgba(255, 255, 255, .6); }
.kpi.hl .sub { color: rgba(255, 255, 255, .75); }
.kpi.hl .up { color: #6fdca5; }
.kpi.hl .down { color: #ff9c92; }

.chart-wrap { padding: 12px 20px 16px; }
.chart-wrap svg { display: block; width: 100%; height: 220px; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); padding: 0 20px 14px; }
.chart-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--navy); }
.chart-legend i.dash { background: repeating-linear-gradient(90deg, var(--gold) 0 4px, transparent 4px 7px); }

/* ---------- Tabeller ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--silver-light); }
th.r, td.r { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .arrow { color: var(--gold-text); }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; text-align: inherit; }
.th-sort:hover { color: var(--ink); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
.ticker { font-weight: 600; letter-spacing: .02em; }
.stock-name { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.me td { background: var(--gold-tint) !important; }
tr.me td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.medal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 600; font-size: 13px; background: var(--silver); }
.medal.m1 { background: #e9d29a; color: #5d4513; }
.medal.m2 { background: #dcdfe6; color: #3d4455; }
.medal.m3 { background: #e7c3a3; color: #5c3517; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-family: var(--serif); font-size: 22px; margin-bottom: 4px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.badge.pending { background: var(--gold-tint); color: #7a5c24; }
.badge.filled { background: var(--up-tint); color: var(--up); }
.badge.cancelled { background: var(--silver); color: var(--muted); }
.badge.rejected { background: var(--down-tint); color: var(--down); }
.side-buy { color: var(--up); font-weight: 600; }
.side-sell { color: var(--down); font-weight: 600; }
.side-dividend { color: #7a5c24; font-weight: 600; }

.search { position: relative; max-width: 320px; width: 100%; }
.search input { padding-left: 36px; font-size: 15px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); }

.weight-bar { height: 4px; background: var(--silver); border-radius: 2px; margin-top: 5px; width: 80px; margin-left: auto; overflow: hidden; }
.weight-bar i { display: block; height: 100%; background: var(--gold); }

/* ---------- Regler ---------- */
.rules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.rule { padding: 22px; }
.rule h3 { font-size: 22px; margin-bottom: 8px; }
.rule p, .rule li { color: var(--muted); }
.rule ul { padding-left: 18px; }
.rule li + li { margin-top: 4px; }
.rule .n { font-family: var(--serif); color: var(--gold-text); font-size: 15px; font-weight: 700; letter-spacing: .06em; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(13, 21, 38, .55); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s ease-out; }
.modal { background: var(--paper); width: 100%; max-width: 440px; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); overflow: hidden; animation: pop .18s ease-out; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 24px; }
.modal-close { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.modal-body { padding: 20px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--silver); border-radius: 8px; padding: 3px; margin-bottom: 18px; }
.seg button { border: 0; background: transparent; padding: 8px; border-radius: 6px; font-weight: 600; color: var(--muted); }
.seg button.on-buy { background: #fff; color: var(--up); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg button.on-sell { background: #fff; color: var(--down); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.quote { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; gap: 12px; }
.quote .price { font-family: var(--serif); font-size: 30px; font-weight: 600; }
.qty-row { display: flex; gap: 8px; }
.qty-row .input { flex: 1; }
.est { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px; }
.est div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.est div.total { font-weight: 600; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.hint { font-size: 12.5px; color: var(--muted); background: var(--silver-light); border-radius: 8px; padding: 10px 12px; margin: 14px 0; }
.modal .btn-wide { width: 100%; padding: 12px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--navy-deep); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); border-left: 3px solid var(--gold); animation: pop .2s ease-out; }
.toast.error { border-left-color: #ff7a6e; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }


/* ---------- Toppliste, vinnere og deltakere ---------- */
.plink { font-weight: 600; text-decoration: none; }
.plink:hover { color: var(--gold-text); text-decoration: underline; }
.period-select { display: flex; align-items: center; gap: 10px; }
.period-select select { width: auto; min-width: 190px; font-size: 15px; padding: 9px 12px; cursor: pointer; }
.me-line { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.me-line a { color: var(--gold-text); text-decoration: none; margin-left: 4px; }
.footnote { margin-top: 14px; font-size: 13px; color: var(--muted); max-width: 760px; }
.footnote a { color: var(--gold-text); }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 10px; }
.back-link:hover { color: var(--gold-text); }

.podium { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr); gap: 14px; align-items: end; margin-bottom: 18px; }
.podium-card { text-decoration: none; text-align: center; padding: 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .15s, border-color .15s; }
.podium-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.podium-card.p1 { order: 2; padding: 26px 14px; background: linear-gradient(180deg, var(--gold-tint), #fff); border-color: rgba(184, 145, 80, .45); }
.podium-card.p2 { order: 1; }
.podium-card.p3 { order: 3; }
.podium-card .medal { width: 34px; height: 34px; font-size: 15px; }
.podium-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.podium-value { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.1; }
.podium-card.p1 .podium-value { font-size: 34px; }

.section-title { font-size: 26px; margin: 8px 0 14px; }
.section-title ~ .section-title { margin-top: 36px; }
.winner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.winner-card { display: flex; flex-direction: column; }
.winner-card:not(.done) { border-color: rgba(184, 145, 80, .45); }
.winner-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding: 16px 18px 12px; }
.winner-head h3 { font-size: 24px; }
.winner-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon label pct" "icon name name"; align-items: center; column-gap: 12px; row-gap: 2px; margin: 0 18px; padding: 12px 14px; background: var(--silver-light); border-radius: 8px; }
.winner-card.done .winner-main { background: var(--gold-tint); }
.trophy { grid-area: icon; font-size: 26px; line-height: 1; }
.winner-label { grid-area: label; }
.winner-name { grid-area: name; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner-pct { grid-area: pct; text-align: right; font-family: var(--serif); font-size: 24px; line-height: 1.1; font-weight: 600; white-space: nowrap; }
.winner-main > * { min-width: 0; }
.winner-rest { list-style: none; padding: 10px 18px 4px; flex: 1; }
.winner-rest li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.winner-rest .medal { width: 22px; height: 22px; font-size: 12px; }
.winner-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px 14px; border-top: 1px solid var(--line); margin-top: 8px; }
.winner-foot a { color: var(--gold-text); text-decoration: none; font-weight: 600; }

/* ---------- Responsivt ---------- */
@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 24px 40px; }
  .hero-chart { display: none; }
  .hero-facts { gap: 20px; margin-top: 24px; }
  .hero-facts b { font-size: 24px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .rules { grid-template-columns: 1fr; }
  .topbar .brand span { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar-in { padding: 0 16px; gap: 12px; height: 56px; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy-deep); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; border-top: 1px solid rgba(255, 255, 255, .08); z-index: 30; }
  .tabs { overflow-x: auto; justify-content: space-between; }
  .tabs a { padding: 8px 6px; font-size: 12px; }
  .podium { gap: 8px; }
  .podium-card { padding: 12px 6px; }
  .podium-card.p1 { padding: 16px 6px; }
  .podium-value, .podium-card.p1 .podium-value { font-size: 20px; }
  .podium-name { font-size: 13px; }
  .period-select { width: 100%; }
  .period-select select { flex: 1; }
  .winner-grid { grid-template-columns: 1fr; }
  .user-menu { margin-left: auto; }
  .user-menu .who { display: none; }
  .statusbar-in { padding: 8px 16px; gap: 12px; }
  main { padding: 22px 16px 96px; }
  .page-head h1 { font-size: 30px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 24px; }
  .kpis { gap: 10px; }
  .hide-sm { display: none; }
  th, td { padding: 9px 7px; }
  th:first-child, td:first-child { padding-left: 12px; }
  th:last-child, td:last-child { padding-right: 10px; }
  .btn-sm { padding: 5px 9px; }
  .card-head, .card-body { padding: 14px 16px; }
  .search { max-width: none; }
  .actions { flex-direction: column; align-items: stretch; gap: 4px; }
  .stock-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .weight-bar { width: 56px; }
  #toasts { bottom: 76px; }
}
.winner-rest li > :nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner-rest li > :last-child { white-space: nowrap; }
.winner-name a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Bunntekst og juridiske lenker ---------- */
.hero-foot { color: rgba(255, 255, 255, .65); }
.login-foot.legal { margin-top: 18px; }
.login-foot.legal a { color: var(--muted); }
.app-foot { max-width: 1180px; margin: 0 auto; padding: 0 24px 40px; font-size: 13px; color: var(--muted); }
.app-foot a { color: var(--muted); }
.rule a { color: var(--gold-text); }
@media (max-width: 720px) {
  main { padding-bottom: 24px; } /* bunnteksten under tar plassen over menyen nederst */
  .app-foot { padding: 0 16px 110px; }
}
