/* Curl
 *
 * A price comparison desk. It answers one question — where are we being
 * undercut — and everything on screen either answers it or gets out of the
 * way. Prices are numbers; numbers get tabular figures and right alignment,
 * and the difference between our price and the best competitor is the single
 * most important thing on any page, so it is the thing with colour.
 *
 * The old version was three Bootstrap buttons and a table with inline styles.
 * This one has no framework: one file, no CDN, works when the CDN does not.
 */

:root {
  --bg:      #f6f7f8;
  --surface: #ffffff;
  --sunken:  #eef0f2;
  --line:    #dfe3e7;
  --line-2:  #c8cfd6;

  --ink:     #16191d;
  --ink-2:   #454c55;
  --muted:   #737c86;

  --accent:  #4a5d23;
  --accent-soft: #eef2e4;

  --up:      #b42318;  --up-soft:   #fdecea;   /* we are more expensive */
  --down:    #1b7f4a;  --down-soft: #e6f4ec;   /* we are cheapest */
  --warn:    #9a6b00;  --warn-soft: #fbf3dc;
  --ours:    #ffb300;

  --radius: 8px;
  --rail: 14rem;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317; --surface: #171b20; --sunken: #0d1013; --line: #262c33; --line-2: #384049;
    --ink: #eef1f4; --ink-2: #c0c7ce; --muted: #838c96;
    --accent: #9fbf5a; --accent-soft: #1e2614;
    --up: #f0716a; --up-soft: #2e1815; --down: #5fcf8e; --down-soft: #12281b;
    --warn: #e2b04e; --warn-soft: #2a2213;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.2rem; font-weight: 650; letter-spacing: -.015em; margin: 0; }
h2 { font-size: .92rem; font-weight: 650; margin: 1.6rem 0 .55rem; } h2:first-child { margin-top: 0; }
.muted { color: var(--muted); } .small { font-size: .85em; } .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .86em; }

/* shell */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .7rem; display: flex; flex-direction: column; gap: 1.1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.rail__brand { display: flex; align-items: center; gap: .5rem; padding: .1rem .5rem .4rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.rail__brand svg { width: 22px; height: 22px; }
.rail__group { display: grid; gap: 1px; }
.rail__label { font-size: .66rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 .5rem .3rem; }
.rail a.nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem .5rem; border-radius: 6px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.rail a.nav:hover { background: var(--sunken); color: var(--ink); }
.rail a.nav.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.rail__foot { margin-top: auto; padding: .5rem; font-size: .8rem; color: var(--muted); }
.content { padding: 1.3rem 1.7rem 5rem; min-width: 0; }

.page { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page__title { display: grid; gap: .15rem; min-width: 0; }
.page__actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* budget gauge — the one thing to see first */
.gauge { display: grid; gap: .45rem; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 16rem; }
.gauge__row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.gauge__big { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gauge__bar { height: .5rem; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.gauge__fill { height: 100%; background: var(--accent); border-radius: 99px; }
.gauge__fill.is-low { background: var(--warn); } .gauge__fill.is-out { background: var(--up); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; display: grid; gap: .1rem; text-decoration: none; color: inherit; }
.stat:hover { border-color: var(--line-2); text-decoration: none; }
.stat b { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .76rem; color: var(--muted); }
.stat--up b { color: var(--up); }

/* panel & tables */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel--flush { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .68rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .55rem .8rem; border-bottom: 1px solid var(--line); background: var(--sunken); position: sticky; top: 0; z-index: 1; }
table.list th.num { text-align: right; }
table.list td { padding: .5rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--sunken); }
table.list tr.is-off td { opacity: .5; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; opacity: .4; transition: opacity .12s; }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

/* price deltas */
.delta { font-variant-numeric: tabular-nums; font-weight: 650; padding: .12rem .45rem; border-radius: 5px; white-space: nowrap; }
.delta--up   { background: var(--up-soft);   color: var(--up); }
.delta--down { background: var(--down-soft); color: var(--down); }
.delta--even { background: var(--sunken);    color: var(--muted); }
tr.is-ours td { background: color-mix(in srgb, var(--ours) 14%, transparent); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .13rem .5rem; border-radius: 99px; font-size: .72rem; font-weight: 620; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill--ok { background: var(--down-soft); color: var(--down); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad { background: var(--up-soft); color: var(--up); }
.pill--dot::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }

/* toggles */
.toggle { appearance: none; width: 2.2rem; height: 1.25rem; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; border: 0; padding: 0; vertical-align: middle; }
.toggle::after { content: ""; position: absolute; top: .15rem; left: .15rem; width: .95rem; height: .95rem; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.is-on { background: var(--down); } .toggle.is-on::after { transform: translateX(.95rem); }

/* forms */
.stack { display: flex; flex-direction: column; gap: .85rem; max-width: 56rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 11rem; min-width: 0; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ink); font-weight: 500; }
label.inline input { width: auto; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: .42rem .55rem; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.hint { font-size: .78rem; color: var(--muted); margin: -.3rem 0 0; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.btn, button { font: inherit; font-weight: 600; font-size: .84rem; display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .8rem; border-radius: 6px; cursor: pointer; border: 1px solid transparent; background: var(--accent); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
.btn--quiet, button.quiet { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn--quiet:hover, button.quiet:hover { background: var(--sunken); filter: none; }
.btn--small { padding: .24rem .55rem; font-size: .78rem; }
button[disabled], .btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }

.flash { padding: .6rem .85rem; border-radius: 6px; margin: 0 0 1rem; border: 1px solid var(--line); background: var(--surface); font-size: .88rem; }
.flash.ok { background: var(--down-soft); color: var(--down); border-color: transparent; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.flash.error { background: var(--up-soft); color: var(--up); border-color: transparent; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1.5rem; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty strong { display: block; color: var(--ink); margin-bottom: .3rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: .8rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .7rem; border-radius: 6px; font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.tabs a.is-on { background: var(--accent-soft); color: var(--accent); }
.tabs a:hover { text-decoration: none; background: var(--sunken); }

.progress { height: .6rem; background: var(--sunken); border-radius: 99px; overflow: hidden; margin: .6rem 0; }
.progress i { display: block; height: 100%; background: var(--accent); }

.signin { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.signin .panel { width: min(100%, 21rem); margin: 0; }
.signin form { display: flex; flex-direction: column; gap: .85rem; margin-top: 1rem; }

@media (max-width: 52rem) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .75rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail__group { display: flex; flex-wrap: wrap; gap: .25rem; }
  .rail__label, .rail__foot { display: none; }
  .content { padding: 1rem 1rem 4rem; }
}

/* beskrivelser */
textarea { font: inherit; font-family: var(--mono); font-size: .82rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: .5rem .6rem; width: 100%; min-height: 12rem; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.preview { max-height: 9rem; overflow: auto; font-size: .8rem; color: var(--ink-2); background: var(--sunken); border-radius: 6px; padding: .5rem .7rem; }
.preview h3 { font-size: .82rem; margin: .5rem 0 .2rem; } .preview p, .preview ul { margin: .2rem 0; } .preview ul { padding-left: 1.2rem; }
details summary { cursor: pointer; color: var(--accent); font-size: .8rem; }
.itemno-form { display: flex; gap: .3rem; } .itemno-form input { width: 8rem; padding: .25rem .45rem; font-size: .82rem; font-family: var(--mono); }
