:root {
  --bg: #f6f6f4; --surface: #fff; --text: #1d1d1b; --muted: #6b6b66; --border: #dcdcd6;
  --accent: #1f5fa8; --accent-bg: #e6f0fb; --ok: #2f6b12; --ok-bg: #eaf3de;
  --warn: #8a5300; --warn-bg: #fbefd9; --bad: #a32d2d; --bad-bg: #fcebeb; --radius: 6px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.topbar { display: flex; gap: 24px; align-items: center; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { text-decoration: none; }
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.wide { max-width: none; padding: 16px 16px 60px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; background: var(--accent-bg); }
.flash-error { background: var(--bad-bg); color: var(--bad); border-left: 4px solid var(--bad); font-weight: 500; }
.flash-warning { background: var(--warn-bg); color: var(--warn); }
.flash-success { background: var(--ok-bg); color: var(--ok); }
button, .button { font: inherit; padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 13px; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
input[type=checkbox] { width: 18px; height: 18px; }
form p { margin: 0 0 14px; }
form p label { display: block; font-weight: 500; margin-bottom: 4px; }
.helptext { display: block; color: var(--muted); font-size: 13px; }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { font-size: 13px; color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; white-space: nowrap; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.b-new { background: var(--ok-bg); color: var(--ok); }
.b-update { background: var(--accent-bg); color: var(--accent); }
.b-unchanged { background: #eee; color: var(--muted); }
.b-stock { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.b-low { background: var(--warn-bg); color: var(--warn); }
.b-duplicate, .b-conflict { background: var(--warn-bg); color: var(--warn); }
.b-invalid { background: var(--bad-bg); color: var(--bad); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 4px 12px; border-radius: 14px; text-decoration: none; border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 20px; color: var(--text); }

/* PDF page with clickable overlays */
.review { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .review { grid-template-columns: 1fr; } }
.pdfpage { position: relative; border: 1px solid var(--border); background: #fff; }
.pdfpage img { display: block; width: 100%; height: auto; }
.box { position: absolute; border: 1px solid transparent; border-radius: 2px; cursor: pointer; }
.box:hover { border-color: var(--accent); }
.box.r-new { background: rgba(47, 107, 18, .10); }
.box.r-update { background: rgba(31, 95, 168, .10); }
.box.r-duplicate, .box.r-conflict { background: rgba(138, 83, 0, .18); }
.box.r-invalid { background: rgba(163, 45, 45, .10); }
.box.hl { border: 2px solid var(--accent); background: rgba(31, 95, 168, .08); }
.box.cell { border-color: rgba(0, 0, 0, .18); }
.box.cell.mapped { border: 2px solid var(--accent); background: rgba(31, 95, 168, .07); }
.box .tag { position: absolute; top: -15px; left: 0; font-size: 10px; line-height: 14px; background: var(--accent); color: #fff; padding: 0 4px; border-radius: 3px; white-space: nowrap; }
.sticky { position: sticky; top: 8px; }
.rowlist .row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px 8px; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rowlist .row.hl { outline: 2px solid var(--accent); outline-offset: -2px; }
.rowlist .row .name { overflow-wrap: anywhere; }
.rowlist .row .prices { font-size: 13px; color: var(--muted); }
.rowlist .row .msg { font-size: 12px; color: var(--muted); }
.rowlist .row form.edit { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; align-items: end; }
.rowlist .row form.edit label { font-size: 12px; color: var(--muted); }
.rowlist .row form.edit input { width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.set::after { content: " ✓"; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.pager a, .pager span { padding: 2px 9px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--surface); font-size: 13px; }
.pager .on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Lists, filters and record pages */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.filters input[type=search] { flex: 1 1 320px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
tr.inactive td, .contact.inactive { color: var(--muted); }
table.list th a { color: inherit; text-decoration: none; }
table.list th a:hover { text-decoration: underline; }
table.list td a { text-decoration: none; }
@media (max-width: 700px) { .hide-sm { display: none; } }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.contactlist { display: grid; gap: 8px; margin-top: 8px; }
.contact { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.contact.editing { display: block; border-color: var(--accent); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: start; }
.grid-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.grid-form label.check { display: flex; font-size: 15px; color: var(--text); }
.grid-form input:not([type=checkbox]), .grid-form select { width: 100%; }
form.stacked fieldset { margin: 0 0 12px; }
fieldset.panel legend { font-weight: 600; padding: 0 6px; }
.numbers { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.numbers > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; min-width: 180px; }
.numbers b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.topbar nav { flex-wrap: wrap; }
.userbox { display: flex; gap: 10px; align-items: center; margin: 0; }

/* Orders */
.status { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 9px; border-radius: 10px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white); }
h1 .status { font-size: 13px; vertical-align: middle; }
.status-chip { display: inline-flex; gap: 6px; align-items: center; border-color: color-mix(in srgb, var(--c) 40%, white); }
.status-chip:has(input:checked) { background: color-mix(in srgb, var(--c) 18%, white); border-color: var(--c); }
.status-chip input { width: 14px; height: 14px; margin: 0; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 12px; text-align: center; }
.pair { display: flex; gap: 6px; }
.pair input { min-width: 0; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .order-grid { grid-template-columns: 1fr; } }
.add-line { position: relative; display: flex; gap: 8px; margin: 10px 0; }
.add-line input { flex: 1; }
.add-line #product-results { position: absolute; top: 40px; left: 0; right: 0; z-index: 5; }
.results { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.08); max-height: 360px; overflow-y: auto; }
.result { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 8px 12px; }
.result:hover { background: var(--accent-bg); }
table.lines tr.editing td { background: var(--accent-bg); }
table.lines tr.in-stock td { background: #f3f9ee; }
table.lines tr.in-stock td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
.nowrap { white-space: nowrap; }
button.link.danger { color: var(--bad); }
.totals { display: flex; gap: 32px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.totals dl.facts { min-width: 220px; }
.totals dd.num { text-align: right; }
#lines .incl, #lines .when-incl, #lines .when-nodg { display: none; }
#lines.incl-vat .incl, #lines.incl-vat .when-incl { display: inline; }
#lines.incl-vat .ex, #lines.incl-vat .when-ex { display: none; }
#lines.hide-dg .dg { display: none; }
#lines.hide-dg .when-dg { display: none; }
#lines.hide-dg .when-nodg { display: inline; }
.contact.due { border-color: var(--warn); background: var(--warn-bg); }
details.complete summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-top: 6px; }
.complete-form { display: grid; gap: 4px; margin-top: 6px; }

/* Main menu: daily work up front, the rest under ☰ */
.topbar .main-nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.topbar .main-nav a { text-decoration: none; font-weight: 500; }
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; font-size: 22px; line-height: 1; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.menu summary::-webkit-details-marker { display: none; }
details.menu[open] summary { background: var(--accent-bg); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 6px 0; }
.menu-panel a, .menu-panel .menu-logout { display: block; width: 100%; text-align: left; padding: 9px 16px; text-decoration: none; color: var(--text); border: 0; border-radius: 0; background: none; font: inherit; }
.menu-panel a:hover, .menu-panel .menu-logout:hover { background: var(--accent-bg); }
.menu-panel form { margin: 0; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.menu-user { padding: 6px 16px 8px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--accent-bg); }

/* ---------------------------------------------------------------------------
   Mobile (SPEC: every screen must work on a phone). Phones are ~360–430 px wide.
   --------------------------------------------------------------------------- */
.show-sm { display: none; }
/* «clip» (not «hidden»): stops sideways scrolling without turning the page into its own scroll box, which in Chrome
   clipped the ☰ menu and blocked scrolling on short pages. */
html, body { overflow-x: clip; }
img { max-width: 100%; }
@media (max-width: 700px) {
  body { font-size: 16px; }
  .show-sm { display: block; }
  /* 16 px stops iPhone from zooming into fields; 44 px is a comfortable tap target */
  input, select, textarea, button, .button { font-size: 16px; }
  input:not([type=checkbox]):not([type=radio]), select, button, .button { min-height: 44px; }
  button.link { min-height: 32px; padding: 4px 0; }
  .page, .wide { padding: 12px 12px 48px; }
  h1 { font-size: 20px; }
  h2 { font-size: 17px; }

  .topbar { gap: 10px; padding: 8px 12px; position: sticky; top: 0; z-index: 30; }
  .topbar .main-nav { gap: 14px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topbar .main-nav::-webkit-scrollbar { display: none; }
  .topbar .main-nav a { white-space: nowrap; padding: 6px 0; }
  .menu-panel { position: fixed; top: 56px; right: 8px; left: auto; max-width: calc(100vw - 16px); }
  .menu-panel a, .menu-panel .menu-logout { padding: 13px 18px; }

  .toolbar { gap: 8px; }
  .toolbar > .button, .toolbar > form > button { flex: 0 0 auto; }
  .filters input[type=search] { flex: 1 1 100%; }
  .filters select { flex: 1 1 45%; }
  .grid-form { grid-template-columns: 1fr; }
  .pair { flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .numbers > div { min-width: 0; flex: 1 1 100%; }
  table.list { font-size: 14px; }
  table.list th, table.list td { padding: 8px 6px; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dt { margin-top: 8px; font-size: 13px; }

  /* Order lines become cards */
  table.lines thead { display: none; }
  table.lines, table.lines tbody { display: block; }
  table.lines tr.line { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.lines tr.line td { display: flex; justify-content: space-between; gap: 8px; border: 0; padding: 2px 0; text-align: left; }
  table.lines tr.line td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  table.lines tr.line td:empty { display: none; }
  table.lines tr.line .c-desc { grid-column: 1 / -1; font-weight: 600; order: -2; }
  table.lines tr.line .c-desc::before, table.lines tr.line .c-actions::before { content: none; }
  table.lines tr.line .c-nr { grid-column: 1 / -1; order: -1; }
  table.lines tr.line .c-net { font-weight: 600; }
  table.lines tr.line .c-actions { grid-column: 1 / -1; justify-content: flex-start; gap: 20px; }
  #lines.hide-dg table.lines tr.line .dg { display: none; }
  table.lines tr.line.in-stock { background: #f3f9ee; border-left: 4px solid var(--ok); padding-left: 8px; }
  table.lines tr.line.in-stock td:first-child { box-shadow: none; }
  table.lines tr.line .c-desc { flex-wrap: wrap; justify-content: flex-start; }
  table.lines tr.editing,table.lines tr.editing td { display: block; }
  .add-line { flex-wrap: wrap; }
  .add-line input { flex: 1 1 100%; }
  .add-line #product-results { top: 48px; }
  .totals { justify-content: stretch; gap: 0; }
  .totals dl.facts { min-width: 0; width: 100%; grid-template-columns: 1fr auto; gap: 4px 12px; }
  .totals dl.facts dt { margin: 0; }

  /* Order page: status and actions stack nicely */
  #status-form { flex-wrap: wrap; }
  #status-form select { flex: 1 1 100%; }
  #lost-fields { flex-wrap: wrap; width: 100%; }
  #lost-fields select, #lost-fields input { flex: 1 1 100%; }
  .status-chip { font-size: 14px; }

  /* Import review: the PDF goes under the lines list */
  .review .sticky { position: static; }
}
@media (max-width: 700px) {
  #filters .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  #filters .chips .chip { flex: 0 0 auto; white-space: nowrap; }
  table.lines tr.line .c-nr { justify-content: flex-start; gap: 12px; }
  table.lines tr.line .c-nr br { display: none; }
}

/* Fieldsets default to min-width: min-content and would push forms wider than a phone screen. */
fieldset { min-width: 0; }
input, select, textarea { max-width: 100%; }
.grid-form > * { min-width: 0; }
@media (max-width: 700px) { .grid-form { grid-template-columns: minmax(0, 1fr); } }
textarea { font: inherit; width: 100%; }
.danger-text { color: var(--bad); }
label.source-choice { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
label.source-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }

/* Front page */
.home-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.home-search { display: flex; gap: 6px; flex: 1 1 420px; max-width: 640px; }
.home-search input { flex: 1; min-width: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-col { display: grid; gap: 16px; }
.dashboard h2 { margin: 0 0 10px; }
a.reminder { display: grid; gap: 2px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 0; text-decoration: none; color: var(--text); background: var(--surface); }
a.reminder.due { border-left-color: var(--warn); background: var(--warn-bg); }
a.reminder:hover { background: var(--accent-bg); }
a.reminder span { color: var(--muted); }
table.list.compact th, table.list.compact td { padding: 5px 6px; }
@media (max-width: 900px) { .dashboard { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .home-search { flex-wrap: wrap; }
  .home-search input { flex: 1 1 100%; }
  .home-search button { flex: 1 1 0; }
  .quick .button { flex: 1 1 45%; text-align: center; }
}

/* Calendar (SPEC 5.12) */
.cal-head { margin-bottom: 6px; }
.cal-week { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cal-week table { border-collapse: collapse; width: 100%; min-width: 980px; table-layout: fixed; }
.cal-week th, .cal-week td { border: 1px solid var(--border); vertical-align: top; padding: 4px; }
.cal-week thead th { font-size: 13px; color: var(--muted); font-weight: 500; text-align: left; padding: 6px; }
.cal-week th.cal-res { width: 130px; text-align: left; font-size: 14px; background: var(--bg); }
.cal-cell { min-height: 70px; height: 70px; }
.cal-cell.drop { background: var(--accent-bg); outline: 2px dashed var(--accent); }
.cal-today { background: #fffbe8; }
.job { display: grid; gap: 1px; padding: 4px 6px; margin-bottom: 4px; font-size: 12px; line-height: 1.3; text-decoration: none; color: var(--text);
  background: color-mix(in srgb, var(--c) 12%, white); border-left: 3px solid var(--c); border-radius: 3px; cursor: pointer; }
.job[draggable="true"] { cursor: grab; }
.job.dragging { opacity: .5; }
.job span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-time { font-weight: 600; color: var(--text) !important; }
.cal-agenda { display: none; }
.cal-agenda h2 { margin: 18px 0 8px; }
.cal-agenda h2::first-letter { text-transform: uppercase; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); background: var(--border); gap: 1px; }
.cal-dayname { background: var(--bg); padding: 6px; font-size: 13px; color: var(--muted); }
.cal-mday { background: var(--surface); min-height: 96px; padding: 4px; display: grid; align-content: start; gap: 2px; }
.cal-mday.other { background: var(--bg); color: var(--muted); }
.cal-date { font-size: 13px; text-decoration: none; color: inherit; }
.mjob { font-size: 11px; padding: 1px 4px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 12%, white); text-decoration: none; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) {
  .cal-week, .cal-hint { display: none; }
  .cal-agenda { display: block; }
  .cal-agenda section.cal-today { background: none; }
  .cal-agenda section.cal-today h2::after { content: " · i dag"; color: var(--accent); }
  .cal-month { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-mday { min-height: 64px; }
  .mjob { font-size: 0; height: 6px; padding: 0; }
  .cal-head { flex-wrap: wrap; }
}

/* Compact top bar on phones: short brand, Kunder moves into the ☰ menu */
.show-sm-inline, .menu-panel a.show-sm-block { display: none; }
@media (max-width: 700px) {
  .show-sm-inline { display: inline; }
  .menu-panel a.show-sm-block { display: block; }
  .topbar .main-nav { gap: 12px; font-size: 15px; }
}

/* Job photos and completion (SPEC 5.12) */
a.reminder.done { border-left-color: var(--ok); background: var(--ok-bg); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0; }
.photos a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: #eee; }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload input[type=file] { width: 100%; }
.big-button { width: 100%; font-size: 18px; min-height: 52px; }

/* Action bar at the bottom of an order or invoice (like the old system) */
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; margin: 20px 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.action-bar form { margin: 0; }
.action-bar .spacer { flex: 1 1 auto; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > .panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 300px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.action-menu .menu-links a { display: block; padding: 6px 0; }
button.good, .button.good { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger-button, .button.danger-button { color: var(--bad); border-color: var(--bad); background: var(--surface); }
@media (max-width: 640px) {
  .action-bar > * { flex: 1 1 45%; }
  .action-bar .button, .action-bar button { width: 100%; text-align: center; }
  .action-bar .spacer { display: none; }
  .action-menu[open] > .panel { position: static; min-width: 0; margin-top: 6px; box-shadow: none; }
}

/* Quote reminders in the calendar */
.cal-reminder { display: block; font-size: 12px; padding: 2px 6px; margin: 2px 0; border-radius: 4px; background: var(--warn-bg); color: var(--warn); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-reminders td, .cal-reminders th { background: #fffaf0; }

/* «Ordreplan»: the one order to place, above the week */
.plan-panel { margin-bottom: 12px; border-left: 4px solid var(--accent); }
.plan-job { max-width: 360px; margin: 8px 0 0; font-size: 13px; }
.plan-job span { white-space: normal; }

/* «Lagret ✓» */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ok); color: #fff;
  padding: 10px 18px; border-radius: 20px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.18); opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Product pictures in the quote */
.quote-images figure { margin: 0; }
.quote-images figcaption { margin-top: 2px; }

/* Upsell search on the work order */
.upsell-result { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 0; }
.upsell-buy { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.upsell-buy input { width: 52px; text-align: right; }

/* Front page: installer finished a job – shown on top so the seller sees it right away */
.done-banner { margin: 12px 0 16px; border-left: 4px solid var(--ok); }
.done-banner h2 { margin: 0 0 10px; color: var(--ok); }

/* «Ordre i arbeid» */
table.pipeline tr.needs-action td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.pipeline td .status { font-size: 12px; }
@media (max-width: 640px) {
  table.pipeline thead { display: none; }
  table.pipeline, table.pipeline tbody { display: block; }
  table.pipeline tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 10px 6px; border-bottom: 1px solid var(--border); }
  table.pipeline td { display: block; border: 0; padding: 0; grid-column: 2; }
  table.pipeline td.c-pick { grid-column: 1; grid-row: 1 / span 5; }
  table.pipeline tr.needs-action { box-shadow: inset 4px 0 0 var(--warn); }
  table.pipeline tr.needs-action td:first-child { box-shadow: none; }
}

/* My reminders month: readable on a phone too (the job calendar shrinks its items to dots) */
.reminder-month .cal-reminder { font-size: 12px; }
.reminder-month .cal-reminder.due { background: var(--bad-bg); color: var(--bad); }
.reminder-month .cal-date { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) { .reminder-month .cal-reminder { font-size: 0; height: 8px; padding: 0; } }

/* Meetings and site visits in «Min kalender» */
a.reminder.appt { border-left-color: #6b4fbb; }
.cal-appt { display: block; font-size: 12px; padding: 2px 6px; margin: 2px 0; border-radius: 4px; background: #efeafb; color: #4b3590;
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .reminder-month .cal-appt { font-size: 0; height: 8px; padding: 0; } }

/* «Planlagt montering/utlevering» on a purchase order */
.planned-line { margin-top: 6px; padding: 4px 10px; display: inline-block; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.planned-line.set { background: var(--ok-bg); color: var(--ok); }

/* Calendar time grid: hours down, one column per employee under each day (like the old system) */
.tgrid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tgrid { display: flex; min-width: max-content; --hour: 52px; }
.tgrid-gutter { flex: 0 0 44px; position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.tgrid-dayhead { height: 30px; padding: 6px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tgrid-dayhead a { color: var(--text); text-decoration: none; }
.tgrid-reshead { height: 26px; padding: 4px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.tgrid-body { position: relative; height: calc(var(--hours) * var(--hour)); }
.tgrid-hour { height: var(--hour); font-size: 12px; color: var(--muted); padding: 2px 6px; border-top: 1px solid var(--border); text-align: right; }
.tgrid-day { border-right: 2px solid #c9c9c2; }
.tgrid-day.cal-today .tgrid-dayhead { background: #fff3c4; }
.tgrid-cols { display: flex; }
.tgrid-col { width: 92px; flex: 0 0 92px; border-right: 1px solid var(--border); }
.tgrid-slot { height: var(--hour); border-top: 1px solid #ecece7; }
.tgrid-slot:nth-child(odd) { background: #fcfcfa; }
.tgrid-body.drop { background: var(--accent-bg); outline: 2px dashed var(--accent); }
.tjob { position: absolute; box-sizing: border-box; padding: 2px 4px 6px; overflow: hidden; font-size: 11px; line-height: 1.25;
  color: #fff; background: var(--c); border: 1px solid rgba(0,0,0,.15); border-radius: 3px; text-decoration: none; display: flex; flex-direction: column; gap: 1px; z-index: 1; }
.tjob:hover { z-index: 2; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.tjob[draggable="true"] { cursor: grab; }
.tjob.dragging { opacity: .5; }
.tjob-status { font-size: 10px; background: rgba(255,255,255,.25); border-radius: 2px; padding: 0 3px; align-self: flex-start; }
.tjob-title { font-weight: 600; }
.tjob-desc { opacity: .9; }
.tjob-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; background: rgba(0,0,0,.12); }
@media (max-width: 700px) { .tgrid-wrap { display: none; } }

/* Appointments from Outlook (read-only) */
.reminder.outlook { display: grid; gap: 2px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); border-left: 4px solid #0f6cbd; background: var(--surface); }
.reminder.outlook span { color: var(--muted); }
.cal-outlook { display: block; font-size: 12px; padding: 2px 6px; margin: 2px 0; border-radius: 4px; background: #e5f0fa; color: #0f548c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .reminder-month .cal-outlook { font-size: 0; height: 8px; padding: 0; } }

/* Huskelapp: internal note on the order */
.huskelapp { background: #fff8d6; border-color: #ecd98a; }
.huskelapp summary { cursor: pointer; }
.huskelapp[open] .huskelapp-preview { display: none; }
.huskelapp-preview { display: block; margin-top: 2px; color: var(--text); }

/* Documents on the order */
.doc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.doc-row form { margin: 0; }
.doc-row > a { flex: 1 1 200px; }
.internal-docs { border-left: 4px solid #8a8a84; }


/* ==========================================================================
   Look and feel (27.10.2026): Port Sør colours – dark top bar with the logo, blue accent from the logo,
   panels with dark title bands, clearer tables and buttons. Placed last so it overrides the plain base above.
   ========================================================================== */
:root {
  --bg: #e9e8e4; --surface: #fff; --text: #22201e; --muted: #6d6a65; --border: #dcdad4;
  --accent: #1d6fc1; --accent-bg: #e4effa; --brand: #2e2926; --brand-2: #3d3632;
  --radius: 8px; --shadow: 0 1px 3px rgba(30, 25, 20, .10), 0 1px 1px rgba(30, 25, 20, .05);
}
body { background: var(--bg); }
h1 { color: var(--brand); font-weight: 700; letter-spacing: -.01em; }

/* Top bar */
.topbar { background: linear-gradient(180deg, #3a332f 0%, #2a2522 100%); border-bottom: 3px solid var(--accent); padding: 8px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,.18); position: sticky; top: 0; z-index: 30; }
.topbar .brand img { display: block; height: 40px; width: auto; border-radius: 3px; }
.topbar .main-nav { gap: 4px; }
.topbar .main-nav a { color: #ece6e0; padding: 7px 12px; border-radius: 6px; font-weight: 500; }
.topbar .main-nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.topbar .main-nav a.on { background: var(--accent); color: #fff; }
details.menu summary { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.25); }
details.menu[open] summary { background: var(--accent); border-color: var(--accent); }
.menu-panel { min-width: 250px; padding: 4px 0 6px; max-height: calc(100vh - 80px); overflow-y: auto; }
.menu-user { padding: 10px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.menu-head { padding: 10px 16px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.menu-panel a { padding: 7px 16px 7px 22px; }

/* Panels: soft shadow, dark title band on the front page and the order's side panels */
.panel, .card { border: 1px solid #e3e1dc; box-shadow: var(--shadow); border-radius: var(--radius); }
.dashboard .panel > h2:first-child, .order-grid aside .panel > h2:first-child, .done-banner > h2:first-child {
  margin: -16px -16px 14px !important; padding: 10px 16px; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--brand-2); color: #fff; font-size: 15px; font-weight: 600; }
.done-banner > h2:first-child { background: var(--ok); }
.panel h2 { color: var(--brand); }

/* Buttons and fields */
button, .button { border-radius: 6px; transition: background .12s, box-shadow .12s, border-color .12s; }
button:hover, .button:hover { border-color: #b9b6af; background: #fafaf8; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 1px 2px rgba(29,111,193,.35); }
button.primary:hover, .button.primary:hover { background: #185ea6; border-color: #185ea6; }
button.good, .button.good { box-shadow: 0 1px 2px rgba(47,107,18,.35); }
button.good:hover, .button.good:hover { background: #275a0f; }
button.link, button.link:hover { background: none; border: 0; box-shadow: none; }
input, select, textarea { border-radius: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, white); outline-offset: 0; border-color: var(--accent); }

/* Tables */
table.list { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th { background: #f2f1ed; color: #57534d; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
table.list tbody tr:nth-child(even) td { background: #fbfbf9; }
table.list tbody tr:hover td { background: #eef5fc; }
table.list.lines tbody tr.in-stock td { background: #f1f8ea; }

/* Tabs, status, front page, stats */
.tabs a { border-radius: 16px; font-weight: 500; }
.tabs a:hover { border-color: var(--accent); }
.status { font-weight: 600; }
.quick .button { padding: 10px 18px; font-weight: 600; }
.quick .button:not(.primary) { background: var(--surface); box-shadow: var(--shadow); }
a.reminder { border-radius: 6px; }
a.reminder:hover { background: #eef5fc; }
.stat { border: 0; box-shadow: var(--shadow); border-top: 3px solid var(--accent); }

/* Phones: smaller logo */
@media (max-width: 700px) {
  .topbar { padding: 6px 10px; gap: 10px; }
  .topbar .brand img { height: 30px; }
  .topbar .main-nav a { padding: 6px 8px; }
}

.huskelapp { padding: 12px 16px; }
.huskelapp-text { margin: 6px 0 0; white-space: normal; }
.huskelapp-edit summary { cursor: pointer; color: var(--accent); margin-top: 6px; display: inline-block; }
.huskelapp-edit[open] summary { display: none; }

table.lines tr.cancelled td { color: var(--muted); text-decoration: line-through; }
table.lines tr.cancelled td .badge { text-decoration: none; }

/* Notifications */
.notice-banner { margin: 12px 0 16px; }
.notice-banner > h2:first-child { margin: -16px -16px 14px !important; padding: 10px 16px; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
.topbar .bell { color: #fff; text-decoration: none; font-size: 18px; position: relative; padding: 4px 6px; }
.topbar .bell .count { position: absolute; top: -4px; right: -6px; }

/* ☰ menu: log out always visible at the top; the list scrolls inside the window */
.menu-user { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.menu-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-user form { margin: 0; flex: 0 0 auto; }
.menu-logout-top { font-size: 13px; padding: 4px 10px; color: var(--bad); border-color: var(--bad); background: var(--surface); }
.menu-panel { max-height: calc(100vh - 90px); overflow-y: auto; overscroll-behavior: contain; }

.site-photos figure { margin: 0; }
.site-photos figcaption { margin-top: 2px; }

/* Line editor: big touch-friendly fields for pricing on phone/iPad */
.line-editor { display: block; }
.line-editor label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.line-editor input, .line-editor select { width: 100%; font-size: 17px; padding: 9px 10px; }
.le-desc { margin-bottom: 8px; }
.le-main { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.le-net { display: grid; gap: 2px; padding: 9px 10px; background: var(--surface); border: 1px dashed var(--border); border-radius: 6px; }
.le-net strong { font-size: 18px; }
.le-more { margin-top: 8px; }
.le-more summary { cursor: pointer; color: var(--accent); margin-bottom: 6px; }
.big-touch { padding: 10px 20px; font-size: 16px; }
@media (max-width: 640px) { .le-main { grid-template-columns: 1fr 1fr; } }

/* Picture picker */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.picker form { margin: 0; }
.picker button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; width: 100%; background: var(--surface); text-align: left; }
.picker button:hover { border-color: var(--accent); }
.picker img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.picker span { display: block; padding: 4px 6px; font-size: 13px; }
.picker .added { opacity: .45; }

@media (max-width: 700px) {
  .topbar .main-nav { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; min-width: 0; }
  .topbar .main-nav::-webkit-scrollbar { display: none; }
}
/* Timeføring */
.timeform label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.timeform input, .timeform select { width: 100%; min-width: 0; font-size: 17px; padding: 9px 10px; }
.timeform .le-main > div { min-width: 0; }

.target-choice ul, .target-choice > div { display: flex; gap: 14px; list-style: none; padding: 0; margin: 0 0 10px; flex-wrap: wrap; }
.target-choice label { display: inline-flex; gap: 6px; align-items: center; font-size: 16px; font-weight: 500; color: var(--text); }
.target-choice input { width: auto; }

/* «Tidligere tilbud med denne varen» */
.similar-box { margin: 10px 0; padding: 12px 14px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--accent-bg); }
.similar-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #c9dcf0; flex-wrap: wrap; }
.similar-row:first-of-type { border-top: 0; }
.check-columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; }
.similar-content { display: block; margin-top: 2px; color: var(--text, #222); }
/* Drag and drop of files onto upload panels */
.drop-over { outline: 3px dashed var(--accent); outline-offset: 4px; background: var(--accent-bg); }
.drop-busy { opacity: .6; pointer-events: none; }
.drop-hint { align-self: center; }
@media (hover: none) { .drop-hint { display: none; } }
/* The ☰ menu is long: never taller than the window, scrolls inside itself */
.menu-panel { max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 700px) { .menu-panel { max-height: calc(100dvh - 68px); } }
/* Pinned to the window (not the page): some Chrome versions clipped it at the bottom of short pages. */
.menu-panel { position: fixed; top: 58px; right: 12px; max-height: calc(100vh - 70px); max-height: calc(100dvh - 70px); }
@media (max-width: 700px) { .menu-panel { top: 56px; right: 8px; max-height: calc(100dvh - 64px); } }
/* System alerts */
.alert-banner { border-left: 4px solid #c0392b; }
.alert-banner h2 { color: #a32d22; }
.alert-row { align-items: flex-start; }
