/* Dugg Kunderelasjon. Layout copied from the sister product's pilot (Nov 2026), colours from
   the Dugg palette: light canvas, white cards, slim top bar, a bottom tab bar on phones.
   No inline styles anywhere: the Content-Security-Policy forbids them, so every layout
   tweak is a class in this file. */

/* Inter, served from this app (CSP font-src 'self'): no font CDN, so no third party sees visitors. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/InterVariable-4.1.woff2") format("woff2");
}

:root {
  /* Dugg palette (founders' rebuild plan, Nov 2026). Every text/background pair is
     checked for WCAG 2.2 AA (4.5:1) by the contrast test in assets.rs. */
  --canvas: #f7f9fb;        /* Morgen */
  --card: #ffffff;
  --text: #0c3b54;          /* Natt */
  --muted: #4a6272;
  --faint: rgba(12, 59, 84, 0.08);
  --line: rgba(12, 59, 84, 0.16);
  --primary: #1a6fa8;       /* Dugg */
  --primary-hover: #145783;
  --primary-soft: #e7f2f9;  /* Dis */
  --brand: #0c3b54;         /* Natt */
  /* Mose, Rav and Tegl for fills and icons; the -text shades for words. */
  --good: #1e8a5f;
  --good-text: #176c4a;
  --good-soft: #e5f3ec;
  --warn: #b7791f;
  --warn-text: #855712;
  --warn-soft: #fbf1df;
  --bad: #c2412d;
  --bad-text: #a83623;
  --bad-soft: #fbeae6;
  --radius: 8px;
  --shadow: 0 0 0 1px rgba(12, 59, 84, 0.08);
  --font: "Inter", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 14px/1.42857 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; line-height: 1.4; }
h2 { font-size: 16px; line-height: 1.5; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.neg { color: var(--bad-text); }
.pos { color: var(--good-text); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--faint);
}
.topbar-inner {
  max-width: 1128px; margin: 0 auto; height: 52px;
  display: flex; align-items: center; gap: 8px; padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 2px; font-weight: 700; font-size: 20px; color: var(--brand); }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 4px;
  background: var(--brand); color: #fff; font-size: 16px; letter-spacing: -0.5px;
}
.brand-name { color: var(--brand); white-space: nowrap; }
.search { flex: 0 1 280px; margin-left: 4px; }
.search input {
  width: 100%; height: 34px; border: 0; border-radius: 4px; padding: 0 12px 0 34px;
  background: var(--primary-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M15.5 14h-.8l-.3-.3A6.5 6.5 0 1 0 14 15.5l.3.3v.8l5 5 1.5-1.5zm-6 0a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E") no-repeat 10px center / 16px;
  font: inherit;
}
.nav { display: flex; margin-left: auto; height: 100%; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 80px; height: 100%; padding: 0 4px; color: var(--muted); font-size: 12px;
  border-bottom: 2px solid transparent; position: relative;
}
.nav-item:hover { color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--text); border-bottom-color: var(--text); }
.nav-item svg { width: 24px; height: 24px; fill: currentColor; }
.nav-item .count {
  position: absolute; top: 4px; left: calc(50% + 4px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.avatar {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 600;
}
.avatar.lg { width: 72px; height: 72px; font-size: 26px; border: 2px solid #fff; }

/* ---------- page grid ---------- */
.page { max-width: 1128px; margin: 24px auto; padding: 0 16px; }
.grid { display: grid; grid-template-columns: 225px minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.grid.two { grid-template-columns: minmax(0, 1fr) 300px; }
.grid.wide { grid-template-columns: minmax(0, 1fr); }
.col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sticky { position: sticky; top: 76px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-body { padding: 16px; }
.card-head { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head + .card-body { padding-top: 0; }
.card-foot { padding: 8px 16px; border-top: 1px solid var(--faint); }
.card-foot a { display: block; text-align: center; color: var(--muted); font-weight: 600; }
.divider { border: 0; border-top: 1px solid var(--faint); margin: 0; }

/* profile card */
.profile .cover { height: 56px; background: linear-gradient(120deg, var(--brand) 0%, var(--primary) 60%, #5b9bc8 100%); }
.profile .who { padding: 0 16px 16px; margin-top: -36px; text-align: left; }
.profile .who h2 { margin-top: 8px; }
.stat-row { display: flex; justify-content: space-between; padding: 6px 16px; font-size: 12px; }
.stat-row b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 6px 16px; border-radius: 16px; border: 1px solid var(--primary);
  background: transparent; color: var(--primary); font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--primary-soft); text-decoration: none; box-shadow: inset 0 0 0 1px var(--primary); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--primary-soft); box-shadow: none; }
.btn.danger { border-color: var(--bad); color: var(--bad-text); }
.btn.lg { min-height: 48px; padding: 10px 24px; border-radius: 24px; font-size: 16px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- badges, notices ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--muted); }
.badge-open { background: var(--primary-soft); color: var(--primary); }
.badge-locked { background: var(--warn-soft); color: var(--warn-text); }
.badge-done, .badge-good { background: var(--good-soft); color: var(--good-text); }
.badge-bad { background: var(--bad-soft); color: var(--bad-text); }
.notice { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--primary-soft); }
.notice svg { flex: none; width: 20px; height: 20px; fill: var(--primary); }
.notice.warn { background: var(--warn-soft); } .notice.warn svg { fill: var(--warn); }
.notice.bad { background: var(--bad-soft); } .notice.bad svg { fill: var(--bad); }
.notice.good { background: var(--good-soft); } .notice.good svg { fill: var(--good); }

/* ---------- key figures ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 12px 16px; border-left: 1px solid var(--faint); }
.kpi:first-child { border-left: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.big-number { font-size: 32px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 16px; text-align: left; border-top: 1px solid var(--faint); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); border-top: 0; }
tr.total td { font-weight: 600; border-top: 1px solid var(--line); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--canvas); }
td a.row-link { color: var(--text); font-weight: 600; }

/* ---------- forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; font: inherit; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login h1 { font-size: 32px; font-weight: 400; margin-bottom: 4px; }

/* bottom tab bar (phones) */
.tabbar { display: none; }

@media (max-width: 991px) {
  .grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .grid > .left { display: none; }
}
@media (max-width: 767px) {
  .aside-first > aside { order: -1; }

  body { padding-bottom: 64px; }
  .page { margin: 8px auto; padding: 0; }
  .grid, .grid.two { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .grid > .left { display: flex; }
  .grid > .left .profile { display: none; }
  .card { border-radius: 0; }
  .sticky { position: static; }
  .topbar-inner { padding: 0 12px; }
  .nav { display: none; }
  .search { flex: 1; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 16px; }
  th, td { padding: 8px 12px; }
  .hide-sm { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; height: 60px;
    background: var(--card); border-top: 1px solid var(--faint); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar .nav-item { flex: 1; min-width: 0; font-size: 10px; border-bottom: 0; border-top: 2px solid transparent; }
  .tabbar .nav-item span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .nav-item.active { border-top-color: var(--text); }
}


/* ---------- Dugg Kunderelasjon additions ---------- */
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.center { text-align: center; }
.login .card-body { padding: 24px; }
.login .lead { margin: 0 0 20px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 600; font-size: 18px; color: var(--brand); }
.login-brand .logo { width: 36px; height: 36px; }
.code-input { font: 600 22px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 6px; text-align: center; }
.qr { width: 216px; margin: 8px auto 12px; background: #fff; padding: 8px; border-radius: 4px; box-shadow: var(--shadow); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { font: 13px/1.5 ui-monospace, Menlo, monospace; word-break: break-all; background: var(--canvas); padding: 8px 12px; border-radius: 4px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 12px 0; padding: 12px; background: var(--canvas); border-radius: 4px; font: 13px/1.6 ui-monospace, Menlo, monospace; white-space: nowrap; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.placeholder { padding: 48px 24px; text-align: center; }
.placeholder svg { width: 48px; height: 48px; fill: var(--muted); }
.who .sub { margin: 2px 0 0; }
.who .sub + .sub { margin-top: 0; }
.pad-y { padding: 8px 0; }
.no-border { border: 0; }
a.notice { color: inherit; }
.avatar.md { width: 48px; height: 48px; font-size: 16px; }
.error-status { margin: 0; }
.error-title { margin: 4px 0 12px; }
.brand .logo { flex: none; }

/* product catalogue */
textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; font: inherit; background: #fff; resize: vertical;
}
textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { font-size: 12px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.label-sm { font-size: 12px; color: var(--muted); }
.pre { white-space: pre-line; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
