/* Morot · Admin — the hosted dashboard.
 *
 * Visual direction: the back office of a fresh Swedish product. Warm cream
 * plane, milk-white cards, Morot's deep green carrying the frame and the
 * primary actions, carrot coral reserved for consequences — the color you
 * see when something irreversible is about to happen. One family (Nunito,
 * same as app and site), real data everywhere, no metaphors.
 *
 * The signature survives from the first dashboard: the .consequence strip.
 * Nothing irreversible happens without first stating how many real people
 * it reaches.
 *
 * Chart series palette (validated, dataviz six checks, all-pairs):
 * green #18854a · blue #2a78d6 · violet #4a3aa7. Committed light look.
 */

:root {
  --page: #f6f4ec;
  --card: #fffdf8;
  --card-2: #f5f2e8;
  --ink: #24312a;
  --ink-2: #5b675f;
  --ink-3: #6b7770;
  --line: #e7e2d3;
  --line-2: #d9d3c0;

  --green: #18854a;
  --green-dark: #116a3a;
  --green-deep: #0c3b23;
  --green-soft: #e4f2e8;
  --green-text: #116a3a;

  --coral: #cf4520;
  --coral-dark: #b53a18;
  --coral-soft: #fdeee7;

  --danger: #bb3524;
  --danger-soft: #f9e8e3;
  --amber-soft: #f9f0d8;
  --amber-ink: #7c5d10;

  --s1: #18854a;
  --s2: #2a78d6;
  --s3: #4a3aa7;

  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-card: 0 1px 2px rgba(36, 49, 42, 0.05),
    0 10px 28px -20px rgba(36, 49, 42, 0.25);
  --shadow-pop: 0 4px 10px -2px rgba(36, 49, 42, 0.12),
    0 16px 40px -18px rgba(36, 49, 42, 0.3);
  --r: 10px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }

/* The hidden attribute must beat every class's display value — the gate and
 * the shell are both display-styled and toggled with [hidden]. */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--green);
}

::selection { background: var(--green); color: #fff; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

button { font-family: inherit; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.015em;
}
h2 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.sub-head {
  margin: 24px 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.lede { margin: 4px 0 0; max-width: 56ch; color: var(--ink-2); font-size: 13.5px; }
.caption { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
.muted { color: var(--ink-3); font-size: 13.5px; }

/* ── Gate: login / denied ─────────────────────────────────────────────── */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(50rem 30rem at 85% -10%, var(--green-soft) 0%, transparent 60%),
    var(--page);
}

.gate__card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
  text-align: center;
}

.gate__glyph { font-size: 34px; display: inline-block; }
.gate__wait { color: var(--ink-3); margin: 14px 0 0; }
.gate__name { font-size: 26px; margin-top: 8px; }
.gate__role {
  margin: 2px 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green-text);
}
.gate__text { margin: 16px 0 22px; color: var(--ink-2); font-size: 13.5px; text-align: left; }
.gate__text code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; }

.gate__uid {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 8px 8px 12px;
  margin-bottom: 18px;
}
.gate__uid code { word-break: break-all; text-align: left; }
.gate__actions { display: flex; gap: 10px; justify-content: center; }

.btn--google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-2);
  font-weight: 700;
  padding: 11px 16px;
}
.btn--google:hover { border-color: var(--ink-3); background: #fff; }

/* ── Shell ────────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100dvh;
}

.stage {
  padding: 30px 36px 80px;
  max-width: 1120px;
  width: 100%;
  min-width: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--green-deep);
  color: #e8f2ea;
  padding: 22px 14px 16px;
}

.side__brand { padding: 0 10px 18px; }
.side__glyph { font-size: 20px; display: block; }
.side__name {
  display: block;
  margin-top: 4px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
}
.side__env {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9fc0aa;
}

.side__nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.side__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: 700 13.5px var(--sans);
  text-align: left;
  color: #c3d6c8;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.side__item svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.side__item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side__item.is-current { background: rgba(255, 255, 255, 0.14); color: #fff; }
.side__item.is-current svg { opacity: 1; }
.side__item:focus-visible { outline-color: #fff; }

.side__badge {
  margin-left: auto;
  min-width: 19px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.side__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.side__who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #9fc0aa;
}
.side__out {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: #9fc0aa;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.side__out svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side__out:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.side__out:focus-visible { outline-color: #fff; }

/* ── Panels & page head ───────────────────────────────────────────────── */

.panel { display: none; }
.panel.is-current { display: block; animation: settle 200ms cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes settle {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* ── Cards ────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card > .muted { margin-top: 0; }

.stack { display: grid; gap: 10px; margin-bottom: 16px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.split .card { margin-bottom: 0; }

/* ── KPI board ────────────────────────────────────────────────────────── */

.kpi-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  min-width: 0;
}
.kpi__label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.kpi__value {
  margin-top: 3px;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi__value.is-missing { font-size: 13px; font-weight: 700; color: var(--danger); }
.kpi__note { margin-top: 3px; font-size: 11.5px; color: var(--ink-3); }

.kpi__delta { font-size: 12.5px; font-weight: 800; letter-spacing: 0; margin-left: 7px; }
.kpi__delta.is-up { color: var(--green-text); }
.kpi__delta.is-down { color: var(--danger); }
.kpi__delta.is-flat { color: var(--ink-3); }

.kpi--hero {
  grid-column: span 2;
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 22px;
}
.kpi--hero .kpi__label { color: #b9d2c0; }
.kpi--hero .kpi__value { font-size: 46px; letter-spacing: -0.025em; }
.kpi--hero .kpi__note { color: #9fc0aa; font-size: 12.5px; }
.kpi--hero .kpi__delta.is-up { color: #7fd8a4; }
.kpi--hero .kpi__delta.is-down { color: #f0a794; }
.kpi--hero .kpi__delta.is-flat { color: #9fc0aa; }

/* ── Charts ───────────────────────────────────────────────────────────── */

.chart-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-grid .card { margin-bottom: 0; }
.chart-grid .card:last-child { grid-column: 1 / -1; }

.table-toggle {
  border: 0;
  background: none;
  padding: 2px 4px;
  font: 700 12px var(--sans);
  color: var(--ink-3);
  cursor: pointer;
  transition: color 150ms ease;
}
.table-toggle:hover { color: var(--ink); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.chart__legend .key {
  display: inline-block;
  width: 14px;
  height: 0;
  border-top: 2.5px solid;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
}

.chart__empty {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  color: var(--ink-3);
  font-size: 12.5px;
  text-align: center;
  padding: 12px;
}

.chart-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.chart-table th {
  text-align: right;
  font-weight: 700;
  color: var(--ink-2);
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
}
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.chart-table tr:last-child td { border-bottom: 0; }

.viz-tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  padding: 9px 12px;
  font-size: 12.5px;
  min-width: 130px;
}
.viz-tooltip__date { font-weight: 800; margin-bottom: 5px; }
.viz-tooltip__row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.viz-tooltip__row .key {
  width: 12px;
  height: 0;
  border-top: 2.5px solid;
  border-radius: 2px;
  flex-shrink: 0;
}
.viz-tooltip__row .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.viz-tooltip__row .lbl { color: var(--ink-2); }

/* ── Todo (att hantera) ───────────────────────────────────────────────── */

.todo { display: grid; gap: 8px; }
.todo__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.todo__item:hover { border-color: var(--line-2); background: var(--card-2); }
.todo__count {
  min-width: 34px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--card-2);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.todo__item.is-due .todo__count { background: var(--coral-soft); color: var(--coral-dark); }
.todo__text { flex: 1; font-size: 13px; color: var(--ink-2); }
.todo__item.is-due .todo__text { color: var(--ink); font-weight: 600; }
.todo__item svg { flex-shrink: 0; fill: none; stroke: var(--ink-3); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ── Figures (wellness summary) ───────────────────────────────────────── */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.figures:empty { display: none; }
.figure {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.figure__label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.figure__value {
  margin-top: 3px;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.figure__value.is-missing { font-size: 13px; color: var(--danger); }
.figure__note { margin-top: 3px; font-size: 11.5px; color: var(--ink-3); }

/* ── Consequence: the signature ───────────────────────────────────────── */

.consequence {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 18px 0 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-2);
  transition: background 150ms ease, border-color 150ms ease;
}
.consequence__count {
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.consequence__text { font-size: 13px; color: var(--ink-2); }
.consequence.is-armed { background: var(--coral-soft); border-color: #f2cebd; }
.consequence.is-armed .consequence__count { color: var(--coral-dark); }
.consequence.is-armed .consequence__text { color: var(--ink); }
.consequence.is-empty { background: var(--green-soft); border-color: #cbe4d2; }
.consequence.is-empty .consequence__count { color: var(--green-text); }

/* ── Controls ─────────────────────────────────────────────────────────── */

label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
label.check {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
  font: 400 14px/1.4 var(--sans);
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
input[type="color"] { padding: 3px; height: 36px; }
input[type="checkbox"] { accent-color: var(--green); width: 15px; height: 15px; }
label.check input { width: auto; margin: 0; }
textarea { resize: vertical; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 14px;
}

.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  font: 700 13.5px var(--sans);
  color: #fff;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease,
    color 150ms ease, transform 100ms ease;
}
.btn:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn:active { transform: translateY(1px); }
.btn svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.btn--ghost { background: none; border-color: var(--line-2); color: var(--ink-2); }
.btn--ghost:hover { background: var(--card-2); border-color: var(--ink-3); color: var(--ink); }
.btn--grave { background: var(--coral); border-color: var(--coral); }
.btn--grave:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn--slim { padding: 7px 13px; font-size: 13px; }
.btn--icon { padding: 7px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--green); }
.btn--ghost:disabled:hover { background: none; border-color: var(--line-2); color: var(--ink-2); }
.btn--grave:disabled:hover { background: var(--coral); }

/* ── Rows, tags, notices, tables ──────────────────────────────────────── */

.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.row--split { align-items: center; }
.row .row { padding: 0; border: 0; background: none; gap: 8px; }
.row__main { min-width: 0; }
.row__title { font-size: 14.5px; font-weight: 800; }
.row__meta { margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.row__actions { display: flex; gap: 8px; flex-shrink: 0; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--card-2);
  color: var(--ink-2);
  vertical-align: middle;
}
.tag--live { background: var(--green); color: #fff; }
.tag--off { background: var(--card-2); color: var(--ink-3); }
.tag--warn { background: var(--coral-soft); color: var(--coral-dark); }

.notice {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card-2);
  font-size: 13px;
  white-space: pre-wrap;
}
.notice--good { background: var(--green-soft); border-color: #cbe4d2; color: var(--green-text); }
.notice--bad { background: var(--danger-soft); border-color: #eccabf; color: var(--danger); }
.notice--warn { background: var(--amber-soft); border-color: #ead9ac; color: var(--amber-ink); margin: 0 0 20px; }

.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.data td {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.data td:first-child {
  width: 38%;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  padding-right: 10px;
}
.data tr:last-child td { border-bottom: 0; }

/* ── Campaign card preview ────────────────────────────────────────────── */

.preview {
  margin-top: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 420px;
}
.preview__top { display: flex; gap: 12px; align-items: flex-start; }
.preview__emoji {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 19px;
}
.preview__title { font-weight: 800; font-size: 15px; color: #20262e; }
.preview__body { margin-top: 2px; font-size: 13px; color: #6b7280; }
.preview__bar {
  margin-top: 13px; height: 7px;
  border-radius: 999px; background: rgba(32, 38, 46, 0.08);
  overflow: hidden;
}
.preview__fill { height: 100%; width: 30%; }

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .kpi-board { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .split .card { margin-bottom: 0; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
    padding: 14px 14px 10px;
  }
  .side__brand { padding: 0 6px 10px; }
  .side__glyph { display: inline; margin-right: 6px; }
  .side__name { display: inline; }
  .side__env { display: inline; margin-left: 8px; }
  .side__nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
  }
  .side__item { white-space: nowrap; padding: 8px 11px; }
  .side__foot { display: none; }
  .stage { padding: 20px 16px 60px; }
  .page-head { flex-wrap: wrap; }
  .kpi--hero .kpi__value { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel.is-current { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
