/* Havnio hjelp. Havnio's profile (havnio-backend/assets/brand/BRAND.md):
   Inter in 400 and 500, Dypvann and Natt for text and dark surfaces, Sjøgrønn
   only for «press here», light surfaces for admin. */
@font-face{font-family:'Inter';font-style:normal;font-weight:400 500;font-display:swap;src:url(/fonts/inter-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Inter';font-style:normal;font-weight:400 500;font-display:swap;src:url(/fonts/inter-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

:root {
  --dypvann: #0F3D56;
  --natt: #0A2434;
  --sjogronn: #2BB0A0;
  --sjogronn-dyp: #17695E;
  --fjord: #7FB6C9;
  --brygge: #E8DCC8;
  --skum: #F5F7F8;

  --bg: var(--skum);
  --surface: #FFFFFF;
  --surface-sunk: #EEF2F4;
  --text: var(--natt);
  --text-2: #3E5768;
  --muted: #6B8496;
  --border: #D7DFE4;
  --border-strong: #B9C6CF;
  --action: var(--sjogronn);
  --action-text: #04342C;
  --focus: var(--fjord);
  --link: #0F6E8C;

  --danger: #B42318;
  --danger-bg: #FDECEA;
  --warn: #9A5B00;
  --warn-bg: #FFF4E0;
  --ok: #17695E;
  --ok-bg: #E3F4F1;
  --info: #0F5E7A;
  --info-bg: #E4F1F6;
  --note-bg: #FFF9EB;
  --note-border: #EBD9A8;

  --radius: 12px;
  --radius-sm: 8px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(10, 36, 52, .06), 0 1px 1px rgba(10, 36, 52, .04);

  /* Colours that differ between light and dark beyond the ones above. */
  --topbar: var(--dypvann);
  --row-hover: #F8FAFB;
  --press: #F2F6F8;
  --agent-bg: #F2F8FA;
  --agent-border: #CFE2EA;
  --pending-bg: #EEF0F7;
  --pending: #4A5578;
  --alert-border: #F2C4BF;
  --action-hover: #26A092;
  --bar: var(--dypvann);
  --bar-high: #D98B1F;
  --bar-low: var(--fjord);
  --chart-grid: #E3E9ED;
  --chart-text: #6B8496;
  --chart-new: var(--dypvann);
  --chart-resolved: var(--sjogronn);
  --toast-bg: var(--natt);
  --popover-shadow: 0 8px 24px rgba(10, 36, 52, .14);
  color-scheme: light;
}

/* Dark mode, when the device is in it: Havnio's night palette, as on the
   guest pages (Natt ground, raised Dypvann-blue cards, Fjord for links). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--natt);
    --surface: #123449;
    --surface-sunk: #0D2B3D;
    --text: #FFFFFF;
    --text-2: #DBE1EE;
    --muted: #AAB2C4;
    --border: #1E4A63;
    --border-strong: #2C5B77;
    --link: #7FB6C9;
    --focus: #7FB6C9;

    --danger: #FF8F87;
    --danger-bg: rgba(229, 72, 77, .18);
    --warn: #F4BE63;
    --warn-bg: rgba(244, 190, 99, .15);
    --ok: #6ED8C9;
    --ok-bg: rgba(43, 176, 160, .18);
    --info: #9ACFE2;
    --info-bg: rgba(127, 182, 201, .16);
    --note-bg: rgba(244, 204, 110, .09);
    --note-border: rgba(244, 204, 110, .32);
    --shadow: none;

    --topbar: #0F3D56;
    --row-hover: #16394F;
    --press: #183D54;
    --agent-bg: #143B52;
    --agent-border: #25546F;
    --pending-bg: rgba(160, 172, 220, .15);
    --pending: #B9C3EA;
    --alert-border: rgba(255, 143, 135, .45);
    --action-hover: #33BFAE;
    --bar: var(--fjord);
    --bar-high: #F4BE63;
    --bar-low: #4F7F93;
    --chart-grid: #1E4A63;
    --chart-text: #AAB2C4;
    --chart-new: var(--fjord);
    --chart-resolved: var(--sjogronn);
    --toast-bg: #1E4A63;
    --popover-shadow: 0 8px 28px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
  /* The arrow in the dropdowns, lighter. */
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23AAB2C4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); font-feature-settings: "tnum" 0;
}
h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
a { color: var(--link); }
p { margin: 0 0 12px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Top bar ---- */
.topbar {
  background: var(--topbar); color: #fff; position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: none; }
.brand img { width: 28px; height: 28px; border-radius: 7px; display: block; }
.brand-word { font-size: 18px; font-weight: 500; letter-spacing: -0.2px; }
.brand-word span { color: var(--fjord); font-weight: 400; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a {
  color: #DBE1EE; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
.nav .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 12px; text-align: center; }
.nav .count.alert { background: #E5484D; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #DBE1EE; flex: none; }
.who button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer; }
.who button:hover { background: rgba(255,255,255,.08); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---- Buttons and fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--font); padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); text-decoration: none;
  min-height: 40px;
}
.btn:hover { background: var(--surface-sunk); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-text); }
.btn.primary:hover { background: var(--action-hover); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.topbar-cta { background: var(--action); border-color: var(--action); color: var(--action-text); min-height: 34px; padding: 7px 12px; flex: none; }
.btn.topbar-cta .short { display: none; }

label.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field .hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select, textarea {
  width: 100%; font: 400 16px/1.4 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; min-height: 42px;
}
/* One fixed height for fields and dropdowns alike. Safari ignores height and
   min-height on a select drawn the native way, so the native look is turned
   off and the arrow drawn here instead. */
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select {
  height: 42px; min-height: 0; padding-top: 0; padding-bottom: 0; line-height: normal;
}
select {
  -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236B8496' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--sjogronn); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.error { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.success { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head .muted { font-size: 13px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12.5px; font-weight: 500; line-height: 1; padding: 5px 8px; border-radius: 999px;
  background: var(--surface-sunk); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.s-new { background: var(--info-bg); color: var(--info); }
.s-open { background: var(--warn-bg); color: var(--warn); }
.s-pending { background: var(--pending-bg); color: var(--pending); }
.s-resolved { background: var(--ok-bg); color: var(--ok); }
.s-closed { background: var(--surface-sunk); color: var(--muted); }
.p-urgent { background: var(--danger-bg); color: var(--danger); }
.p-high { background: var(--warn-bg); color: var(--warn); }
.p-normal { background: var(--surface-sunk); color: var(--text-2); }
.p-low { background: var(--surface-sunk); color: var(--muted); }
.overdue { color: var(--danger); font-weight: 500; }
.due-soon { color: var(--warn); font-weight: 500; }

/* ---- Dashboard ---- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
a.kpi:hover { border-color: var(--border-strong); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 30px; font-weight: 500; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.alert .value { color: var(--danger); }
.kpi.alert { border-color: var(--alert-border); }

.dash { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 16px; }

.statlist { list-style: none; margin: 0; padding: 8px 20px 14px; }
.statlist li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.statlist li:last-child { border-bottom: 0; }
.statlist b { font-weight: 500; font-variant-numeric: tabular-nums; }

.bars { padding: 10px 20px 16px; display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 32px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-track { height: 10px; background: var(--surface-sunk); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 5px; min-width: 2px; }
.bar-fill.p-urgent { background: var(--danger); }
.bar-fill.p-high { background: var(--bar-high); }
.bar-fill.p-normal { background: var(--bar); }
.bar-fill.p-low { background: var(--bar-low); }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

.chart { padding: 8px 20px 16px; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); padding: 0 20px 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--row-hover); }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list .subj { font-weight: 500; color: var(--text); text-decoration: none; }
table.list .who-line { font-size: 13px; color: var(--muted); margin-top: 2px; }
table.list .id { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list td.right, table.list th.right { text-align: right; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.replied-tag { font-size: 12px; color: var(--muted); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: var(--surface-sunk); padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; font: 500 13.5px/1 var(--font); color: var(--text-2); padding: 8px 12px; border-radius: 7px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filters input[type=search] { max-width: 280px; height: 40px; font-size: 15px; }
.filters select { width: auto; height: 40px; font-size: 14px; }

/* ---- One case ---- */
.case { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .case { grid-template-columns: minmax(0, 1fr); } }
.case-title { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.case-title h1 { flex: 1; min-width: 200px; }
.case-meta { color: var(--muted); font-size: 14px; margin-bottom: 18px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; font-size: 14px; color: var(--link); text-decoration: none; margin-bottom: 10px; }

.thread { display: grid; gap: 12px; margin-bottom: 16px; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.msg-head { display: flex; justify-content: space-between; gap: 12px; padding: 11px 16px 0; font-size: 13.5px; flex-wrap: wrap; }
.msg-head .author { font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
/* Halvor's face beside his own messages and on his card. */
.halvor-av { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; display: block; }
.halvor-head .halvor-av { width: 30px; height: 30px; }
.msg-head .author .role { font-weight: 400; color: var(--muted); }
.msg-body { padding: 8px 16px 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.agent { background: var(--agent-bg); border-color: var(--agent-border); }
.msg.note { background: var(--note-bg); border-color: var(--note-border); border-style: dashed; }
.msg-foot { padding: 0 16px 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.msg-foot button { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; }
.att:hover { border-color: var(--border-strong); }
.delivery { font-size: 12.5px; }
.delivery.failed { color: var(--danger); font-weight: 500; }
.delivery.held { color: var(--warn); }

.composer { padding: 0; overflow: hidden; }
.composer .tabs { margin: 12px 12px 0; display: inline-flex; }
.composer-body { padding: 12px 16px 16px; }
.composer.note-mode textarea { background: var(--note-bg); border-color: var(--note-border); }
.composer-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.composer-actions select { width: auto; font-size: 14px; height: 40px; }
.composer-actions label { font-size: 13.5px; color: var(--text-2); }

.side .card { margin-bottom: 16px; }
.side .card-pad h2 { margin-bottom: 12px; font-size: 15px; }
.side dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 13.5px; }
.side dt { color: var(--muted); }
.side dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.side .field { margin-bottom: 10px; }
.side input, .side select { font-size: 15px; height: 40px; padding-left: 10px; }
.side select { padding-right: 32px; background-position: right 10px center; }
.events { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--text-2); display: grid; gap: 7px; }
.events time { color: var(--muted); display: block; font-size: 12px; }
.copyline { display: flex; gap: 6px; }
.copyline input { font-size: 13px; height: 34px; color: var(--muted); }

/* ---- Login and public pages ---- */
.center-page { min-height: 100vh; display: flex; flex-direction: column; }
.center-wrap { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.narrow { width: 100%; max-width: 520px; }
.wide { width: 100%; max-width: 720px; }
.public-top { background: var(--topbar); }
.public-top .topbar-inner { max-width: 720px; }
.lead { font-size: 16px; color: var(--text-2); }
.contact-strip { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); margin: 4px 0 20px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
footer.site { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px 36px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--toast-bg); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(10,36,52,.25); max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--danger); }

@media (max-width: 640px) {
  .topbar-inner { padding: 0 12px; gap: 10px; }
  .brand-word { display: none; }
  main { padding: 18px 16px 48px; }
  .who .name { display: none; }
  /* The top bar has room for the menu and «+ Ny» only; log out is on Varsler. */
  .who { display: none; }
  .filters input[type=search] { max-width: none; flex: 1 1 100%; }
  .nav a { padding: 7px 8px; }
  .btn.topbar-cta { padding: 7px 10px; }
  .btn.topbar-cta .long { display: none; }
  .btn.topbar-cta .short { display: inline; }
  .who button { padding: 5px 8px; }
  .dash table.list th:nth-child(5), .dash table.list td:nth-child(5) { display: none; }
}
.legend .lg-new { background: var(--chart-new); }
.legend .lg-res { background: var(--chart-resolved); }

/* ---- The customer's page ---- */
.case-public .msg.agent .author::after { content: ""; }
.status-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 20px; color: var(--muted); font-size: 14px; }

/* ---- Varsler ---- */
.wide > .card, .wide > .error { margin-bottom: 16px; }
.prefs { margin: 8px 0 4px; max-width: 420px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.tips { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-2); font-size: 14px; }
.tips b { font-weight: 500; color: var(--text); }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.devices li:last-child { border-bottom: 0; }

.live-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--info-bg); color: var(--info); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

/* ---- Cases as cards on a phone (instead of the tables) ---- */
.narrow-only { display: none; }
/* Up to a tablet on its side: the tables don't fit without scrolling sideways. */
@media (max-width: 820px) {
  .wide-only { display: none; }
  .narrow-only { display: block; }
}
.tcard-list { list-style: none; margin: 0; padding: 4px 0; }
.tcard { border-bottom: 1px solid var(--border); }
.tcard:last-child { border-bottom: 0; }
.tcard-head {
  display: grid; gap: 3px; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 12px 44px 12px 16px; position: relative; font: inherit; color: inherit;
}
.tcard-head:active { background: var(--press); }
.tcard-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tcard-top .id { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.tcard-wait { margin-left: auto; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tcard-wait.overdue { color: var(--danger); font-weight: 500; }
.tcard-subj { font-weight: 500; font-size: 15.5px; line-height: 1.35; }
.tcard-who { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-chev {
  position: absolute; right: 16px; top: 50%; width: 9px; height: 9px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s;
}
.tcard-head[aria-expanded="true"] .tcard-chev { transform: rotate(-135deg); margin-top: -2px; }
.tcard-more { padding: 0 16px 14px; }
.tcard-more dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.tcard-more dt { color: var(--muted); }
.tcard-more dd { margin: 0; }

.account-card { display: none; }
@media (max-width: 640px) { .account-card { display: block; } }

/* ---- Harbour suggestions in the phone case form ---- */
.has-suggest { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--popover-shadow); max-height: 320px; overflow-y: auto;
}
.suggest li { display: grid; gap: 1px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-sunk); }
.suggest-name { font-weight: 500; font-size: 14.5px; }
.suggest-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- The reply box on a phone: the tabs across, status and send on one line ---- */
@media (max-width: 640px) {
  .composer .tabs { display: flex; margin: 10px 10px 0; }
  .composer .tabs button { flex: 1; padding: 10px 8px; }
  .composer-body { padding: 10px 12px 12px; }
  .composer-actions { flex-wrap: nowrap; gap: 8px; margin-top: 8px; }
  .composer-actions .status-pick { flex: 1; min-width: 0; display: flex; }
  .composer-actions .status-pick-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .composer-actions select { width: 100%; }
  .composer-actions .btn { flex: none; }
  .composer-body > .small { margin: 8px 0 0; font-size: 12.5px; }
}

/* The weekly chart: colours from here, so dark mode reaches them too. */
.chart .grid { stroke: var(--chart-grid); }
.chart .axis { fill: var(--chart-text); }
.chart .bar-new { fill: var(--chart-new); }
.chart .bar-resolved { fill: var(--chart-resolved); }

/* ---- Halvor in a case ---- */
.halvor { margin-bottom: 12px; border-left: 3px solid var(--sjogronn); }
.halvor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.halvor-head h2 { margin: 0; font-size: 15px; }
.halvor-summary { margin: 0 0 6px; }
.halvor .row-actions { margin-top: 8px; }
.halvor-note { margin: 0 0 8px; font-size: 13px; color: var(--ok); background: var(--ok-bg); padding: 6px 10px; border-radius: var(--radius-sm); }
.halvor-mode { padding: 0 20px 14px; margin: 0; }

/* Halvor answered on his own: marked in the lists until someone has checked it. */
.halvor-chip { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 2px 8px 2px 2px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; vertical-align: middle;
  background: color-mix(in srgb, var(--sjogronn) 16%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, var(--sjogronn) 50%, transparent); }
.halvor-chip img { width: 18px; height: 18px; border-radius: 50%; display: block; }
.halvor-chip.checked { background: transparent; border-color: var(--border); color: var(--muted); font-weight: 400; }
.tcard-top .halvor-chip { margin-left: 0; }
.halvor-check { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--sjogronn) 12%, var(--surface)); font-size: 13.5px; }
.halvor-check span { flex: 1; min-width: 200px; }
.halvor-check.done { background: none; padding: 0; color: var(--muted); }
.statlist b.warn-text { color: var(--warn); font-weight: 600; }

/* Search in the top bar: every case, whatever its status. */
.gsearch { position: relative; flex: 0 1 300px; min-width: 180px; display: flex; align-items: center; }
.gsearch > svg { position: absolute; left: 10px; width: 16px; height: 16px; color: #AFC0CC; pointer-events: none; }
.gsearch input[type=search] { height: 36px; padding-left: 34px; padding-right: 30px; font-size: 14px; border-radius: 9px;
  background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; }
.gsearch input[type=search]::placeholder { color: #AFC0CC; }
.gsearch input[type=search]:focus { background: var(--surface); color: var(--text); border-color: var(--surface); outline: none; box-shadow: 0 0 0 3px rgba(43,176,160,.45); }
.gsearch:focus-within > svg { color: var(--muted); }
.gsearch-key { position: absolute; right: 9px; font: 500 11px/1 var(--font); color: #AFC0CC; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 2px 5px; pointer-events: none; }
.gsearch:focus-within .gsearch-key { display: none; }
.gsearch-list { position: absolute; top: calc(100% + 6px); right: 0; width: min(520px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow-y: auto;
  margin: 0; padding: 6px; list-style: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(10,36,52,.22); z-index: 30; }
.gsearch-list[hidden] { display: none; }
.gsearch-list li { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.gsearch-list li.active, .gsearch-list li:hover { background: var(--surface-sunk); }
.gs-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gs-ref { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); flex: none; font-size: 13px; }
.gs-subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; }
.gs-line .badge { flex: none; }
.gs-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsearch-list li.gs-all { color: var(--link); font-size: 13.5px; font-weight: 500; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 4px; }
.gsearch-list li.gs-all:only-child { color: var(--muted); border-top: 0; cursor: default; }
/* When the bar gets tight the search gets a row of its own under the menu. */
@media (max-width: 1100px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 8px; }
  .gsearch { order: 10; flex: 1 1 100%; min-width: 0; }
  .gsearch-key { display: none; }
  .gsearch-list { left: 0; right: 0; width: auto; }
}

.sms-form { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 0 14px; align-items: end; max-width: 640px; }
.sms-form .row-actions { grid-column: 1 / -1; }
@media (max-width: 640px) { .sms-form { grid-template-columns: minmax(0, 1fr); } }
