:root {
  --bg: #f4f6f9; --card: #fff; --text: #1d2430; --muted: #667085; --line: #e3e7ee;
  --primary: #1f4e79; --primary-2: #2d6aa3; --ok: #1e7b4f; --warn: #b26b00; --danger: #b42318;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--primary); color: #fff; min-height: 52px; }
.brand { font-weight: 700; letter-spacing: .3px; }
nav { display: flex; gap: 4px; flex: 1; align-items: center; }
nav a { color: #dbe7f3; text-decoration: none; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
nav a.active, nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
nav .spacer { flex: 1; }
nav .who { color: #bcd0e4; font-size: 13px; padding: 0 6px; }
.icon-btn { display: none; background: none; border: 0; color: #fff; font-size: 22px; margin-left: auto; cursor: pointer; }
main { max-width: 1150px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 16px 0 8px; font-size: 15px; }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; }
.grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 7px; background: #fff; color: var(--text); min-width: 0; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; }
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0e6; border-color: var(--primary-2); }
button, .btn { font: inherit; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: var(--primary-2); }
button.secondary, .btn.secondary { background: #fff; color: var(--primary); }
button.secondary:hover { background: #eef4fa; }
button.danger { background: #fff; color: var(--danger); border-color: #f1b9b3; }
button.small { padding: 3px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.badge.submitted { background: #fff4e0; color: var(--warn); }
.badge.approved { background: #e5f5ec; color: var(--ok); }
.badge.invoiced { background: #e7eefa; color: var(--primary); }
.acc-cust { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.acc-proj { margin: 6px 0 2px 26px; display: grid; gap: 4px; }
.acc-plist { margin-left: 26px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.inline-check { align-self: end; padding-bottom: 8px; }
.warn-card { border-color: #f1c27d; background: #fffbf3; }
.diary-box { border: 2px solid #e3d9c6; background: #fffdf8; border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.diary-pass { padding: 4px 0 8px; }
.diary-pass + .diary-pass { border-top: 1px dashed var(--line); padding-top: 8px; }
.flag-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; }
.badge.danger-badge { background: #fdecea; color: var(--danger); }
tr.flagged td { background: #fffaf0; }
.diary-text { white-space: pre-wrap; max-width: 560px; }
.flag-text { margin-top: 6px; padding: 6px 8px; border-radius: 6px; white-space: pre-wrap; }
.flag-text.incident { background: #fdecea; }
.flag-text.deviation { background: #fef3c7; }
.inv-group { border-top: 2px solid var(--line); padding-top: 4px; margin-top: 18px; }
.inv-title { font-size: 16px !important; }
.inv-group .table-wrap { margin-bottom: 10px; }
tr.sel td { background: #eef4fa; }
.print-only { display: none; }
@media print { .print-only { display: block; } details { display: block; } details > * { display: block; } }
.badge.pd { background: #fef3c7; color: #92400e; }
.pd-box { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
details summary { cursor: pointer; margin: 8px 0; }
.badge.company { background: #f3e8ff; color: #6b21a8; }
.badge.customer { background: #e0f2fe; color: #075985; }
.warn { color: var(--warn); }
.warn-box { border: 1px solid #f1c27d; background: #fffbf3; border-radius: 10px; padding: 10px 14px; margin: 10px 0; line-height: 1.8; }
.seg { font-size: 12px; color: var(--muted); }
.weeknav { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.weeknav h2 { margin: 0; flex: 1; }
.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.split > * { min-width: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; }
.list li:hover { background: #f0f4f9; }
.list li.active { background: #e2ecf7; font-weight: 600; }
.price-grid input { width: 90px; text-align: right; }
.price-grid .wt-cell { display: flex; align-items: center; gap: 4px; min-width: 190px; }
.price-grid input.wt-name { width: 160px; text-align: left; font-weight: 600; }
.price-grid .fallback-row td { background: #f6f8fb; }
.price-grid .extra-first { border-left: 2px solid var(--line); padding-left: 12px; }
.price-grid th.grp { text-align: center; font-size: 11px; border-bottom: 0; padding-bottom: 0; color: var(--primary); }
.price-grid td.num input[data-svc], .price-grid .fallback-row input[name] { width: 80px; }
.icon-x { background: none; border: 0; color: var(--muted); padding: 2px 6px; font-size: 14px; }
.icon-x:hover { background: #fdecea; color: var(--danger); }
.price-grid th, .price-grid td { white-space: nowrap; }
.price-grid th.col-head { white-space: nowrap; }
.price-grid input.col-name { width: 100px; text-align: right; font-weight: 600; font-size: 12px; background: transparent; border-color: transparent; padding: 4px; }
.price-grid input.col-name:hover, .price-grid input.col-name:focus { border-color: var(--line); background: #fff; }
.price-grid th.col-head .icon-x { padding: 0 4px; font-size: 12px; }
.price-grid .col-hidden { opacity: .35; text-decoration: line-through; }
.price-grid th.col-hidden .icon-x { opacity: 1; color: var(--primary); }
tr.edit-row > td { background: #f6f8fb; }
.nowrap { white-space: nowrap; }
.pl { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.pl.current { border-color: #9cc0e6; box-shadow: 0 0 0 2px #e2ecf7; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { flex-direction: row; align-items: center; gap: 3px; color: var(--text); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.stat { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 130px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.login { max-width: 380px; margin: 10vh auto; }
.login .grid { grid-template-columns: 1fr; }
.login a { font-size: .9em; }
.qr { background: #fff; padding: 8px; border-radius: 8px; width: 200px; max-width: 100%; margin: 8px auto; }
.qr svg { display: block; width: 100%; height: auto; }
.mono, pre.codes { font-family: ui-monospace, Consolas, monospace; }
pre.codes { font-size: 1.15em; line-height: 1.7; background: #f4f6f8; border-radius: 8px; padding: 10px 16px; columns: 2; text-align: center; }
.error-box { margin: 0; padding: 8px 12px; border-radius: 7px; background: #fdecea; color: var(--danger); border: 1px solid #f1b9b3; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2430; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }
.thumb { color: var(--primary-2); }
dialog { border: 0; border-radius: 12px; padding: 0; max-width: 92vw; }
dialog img { display: block; max-width: 88vw; max-height: 80vh; }
dialog .row { padding: 8px; }
dialog.ask { padding: 20px; width: 420px; }
dialog.ask .row { padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
@media (max-width: 820px) {
  .icon-btn { display: block; }
  header { flex-wrap: wrap; }
  nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: 8px; }
  nav.open { display: flex; }
  nav .spacer { display: none; }
  .split { grid-template-columns: 1fr; }
  main { padding: 10px; }
  .hide-sm { display: none; }
}
@media print {
  header, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
  main { max-width: none; padding: 0; }
}

/* ---- Min tid: kalender ---- */
.time-top { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; margin-bottom: 14px; }
@media (max-width: 760px) { .time-top { grid-template-columns: 1fr; } }
.cal { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-head b { flex: 1; text-align: center; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: 30px repeat(7, 1fr); gap: 3px; }
.cal-dn { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-wk { font-size: 11px; color: var(--muted); text-align: center; align-self: stretch; display: flex; align-items: center; justify-content: center; background: #f3f5f8; border: 0; border-radius: 6px; padding: 0; min-height: 0; font-weight: 600; }
button.cal-wk:hover { background: #e3e9f1; color: var(--text); }
.cal-wk.cur { background: var(--primary); color: #fff; }
.cal-day { position: relative; border: 1px solid transparent; background: #fff; color: var(--text); border-radius: 8px; padding: 4px 0; min-height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 500; line-height: 1.1; }
.cal-day small { font-size: 10px; opacity: .9; }
.cal-day:hover { border-color: var(--primary); background: #f3f6fb; }
.cal-day.other { color: #b3bac4; }
.cal-day.today span { text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.cal-day.reported { background: #dbeafe; color: #1e40af; }
.cal-day.approved { background: #d1fae5; color: #065f46; }
.cal-day.selected { outline: 3px solid #f59e0b; outline-offset: -1px; font-weight: 800; box-shadow: 0 0 0 2px #fff inset; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.cal-legend .lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.cal-legend .lg.reported { background: #dbeafe; border: 1px solid #93c5fd; }
.cal-legend .lg.approved { background: #d1fae5; border: 1px solid #6ee7b7; }
.cal-legend .lg.selected { outline: 3px solid #f59e0b; outline-offset: -2px; }
.sel-date { border: 2px solid #f59e0b; background: #fffbeb; border-radius: 12px; padding: 14px 16px; }
.sel-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #92400e; font-weight: 700; }
.sel-big { font-size: 22px; font-weight: 800; margin: 4px 0 6px; }
.sel-big::first-letter { text-transform: uppercase; }
.copy-note { margin-top: 10px; padding: 8px 10px; background: #fff; border: 1px dashed #f59e0b; border-radius: 8px; font-size: 13px; }
tr.sel-row td { background: #fffbeb; }
.seg-toggle { display: inline-flex; gap: 0; margin-left: auto; }
.seg-toggle button { border-radius: 0; }
.seg-toggle button:first-child { border-radius: 8px 0 0 8px; }
.seg-toggle button:last-child { border-radius: 0 8px 8px 0; }

/* Aktiv-knapp vid kundnamnet */
.active-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #f3f4f6; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.active-toggle.on { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.active-toggle input { margin: 0; }

/* Låst tid, intern kommentar, artiklar */
.locked { font-size: 12px; color: var(--muted); white-space: nowrap; }
.internal-note { margin-top: 4px; padding: 3px 8px; border-radius: 6px; background: #f3e8ff; color: #5b21b6; font-size: 12px; display: inline-block; }
.internal-box { background: #faf5ff; border: 1px solid #e9d5ff; border-radius: 10px; padding: 10px 12px; }
.art-row { margin: 6px 0; flex-wrap: nowrap; }
.art-row select { min-width: 180px; }
.art-table input { width: 100%; }
.art-table td.num input { width: 100px; text-align: right; }

/* Min tid: arbetstid/frånvaro, flera dagar, knappval */
[hidden] { display: none !important; }
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 4px 0 14px; }
.mode-switch button { border: 0; border-radius: 0; background: #fff; color: var(--text); padding: 9px 18px; font-weight: 600; }
.mode-switch button.on { background: var(--primary); color: #fff; }
.mode-switch button:disabled { opacity: .45; }
.multi-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.multi-bar button { background: #fff; color: var(--primary); border: 2px dashed var(--primary); font-weight: 700; }
.multi-bar button.on { background: #f59e0b; border: 2px solid #d97706; color: #fff; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600; user-select: none; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { border-color: var(--primary); background: #e8f0f8; color: var(--primary); }
.pill:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.cal-day.absence { background: #ede9fe; color: #5b21b6; }
.cal-legend .lg.absence { background: #ede9fe; border: 1px solid #c4b5fd; }
.badge.absence { background: #ede9fe; color: #5b21b6; }

.car-pick { grid-column: span 2; }
.car-pick .pill-group { flex-wrap: nowrap; }
@media (max-width: 600px) { .car-pick { grid-column: 1 / -1; } }

/* Restid och ta bort flera */
.badge.travel { background: #e0f2fe; color: #075985; }
th.cb, td.cb { width: 28px; padding-right: 0; }
.bulk-bar { position: sticky; top: 56px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; font-weight: 600; }
