:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #64748b;
  --border: #dde3ea;
  --primary: #1f6feb;
  --primary-dark: #175ac2;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: #14213d;
  color: #fff;
  padding: 0 1.5rem;
  height: 52px;
}
.topnav a { color: #cbd5e1; text-decoration: none; font-weight: 500; }
.topnav a:hover, .topnav a.active { color: #fff; }
.topnav .brand { color: #fff; font-weight: 700; font-size: 1.05rem; margin-right: .5rem; display: flex; align-items: center; gap: .55rem; }
.brand-logo { height: 30px; display: block; background: #fff; border-radius: 6px; padding: 2px 7px; }
.topnav .spacer { flex: 1; }
.topnav .whoami { color: #94a3b8; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); font-size: .9rem; }
.page-head .actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.form label { display: block; margin-bottom: .8rem; font-weight: 600; font-size: .85rem; }
.form input, .form select, .form textarea,
.inline-form input, .inline-form select {
  display: block; width: 100%; margin-top: .3rem;
  padding: .5rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; background: #fff;
}
.form textarea { resize: vertical; }
.form .row { display: flex; gap: .8rem; flex-wrap: wrap; }
.form .row label { flex: 1 1 180px; }
.form .check { font-weight: 400; }
.form .check input { display: inline; width: auto; margin-right: .35rem; }
.form.narrow { max-width: 560px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { margin-top: 0; width: auto; flex: 0 1 auto; }
.inline-form.spaced { margin-bottom: .5rem; }
.inline-label { font-weight: 600; font-size: .85rem; }
.inline-label input { margin-top: 0; display: inline-block; width: auto; }
.inline { display: inline; }

.btn {
  display: inline-block; padding: .5rem .9rem; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.linklike { background: none; border: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }
.topnav .linklike { color: #cbd5e1; text-decoration: none; }
.topnav .linklike:hover { color: #fff; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.table td a { color: var(--primary); text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }
.table.compact th, .table.compact td { padding: .45rem .6rem; font-size: .88rem; }
.empty { color: var(--muted); font-style: italic; }

.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 700; vertical-align: middle; }
.badge.tiny { font-size: .68rem; padding: .06rem .4rem; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; margin-right: .25rem; }

.filters { display: flex; gap: .7rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filters select, .filters input { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
.searchbox input[type="search"] { padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; min-width: 260px; }

.suggest-wrap { position: relative; }
.item-suggest {
  position: absolute; top: 100%; left: 0; min-width: 100%; max-width: 460px;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 100; max-height: 240px; overflow: auto;
}
.item-suggest-row { padding: .45rem .6rem; cursor: pointer; font-size: .85rem; }
.item-suggest-row:hover { background: #f1f5f9; }

.hint { color: var(--muted); font-size: .85rem; margin: .6rem 0 0; }
.req { color: #dc2626; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; gap: .5rem; }
.card-head h2 { margin: 0; }
.card-head .sub { color: var(--muted); font-size: .85rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.auth-card { max-width: 380px; margin: 8vh auto 0; }
.auth-card h1 { margin-bottom: .75rem; }
.auth-card p { color: var(--muted); margin-top: 0; }
.auth-logo { max-height: 60px; max-width: 240px; display: block; margin-bottom: 1rem; }
.logo-preview img { max-height: 60px; max-width: 220px; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .5rem; background: #fff; }

.photo-grid { display: flex; gap: .6rem; flex-wrap: wrap; }
.photo-grid img { height: 110px; width: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.notes { list-style: none; padding: 0; margin: 0; }
.notes li { padding: .6rem 0; border-top: 1px solid var(--border); }
.notes li.system .note-body { color: var(--muted); font-style: italic; }
.notes .meta { font-size: .78rem; color: var(--muted); margin-bottom: .15rem; }
.note-body { white-space: pre-wrap; }

details summary { cursor: pointer; font-weight: 600; }

/* --- Ruteplanlægning --- */
.plan-toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.plan-toolbar .spacer { flex: 1; }

.plan-board { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: 1.25rem; }
.plan-col { flex: 0 0 250px; background: #eef2f6; border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; }
.plan-col-head { padding: .55rem .7rem; font-size: .9rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .4rem; }
.plan-col-head .count { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; color: var(--muted); }
.plan-col-head .mini { margin-left: auto; font-size: .72rem; color: var(--primary); text-decoration: none; }
.plan-drop { padding: .5rem; min-height: 80px; flex: 1; }
.plan-drop.over { background: #dbeafe; }

.plan-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .5rem; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.plan-card.dragging { opacity: .5; }
.plan-card .pc-top { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.plan-card .seq { background: #14213d; color: #fff; border-radius: 999px; min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; padding: 0 .3rem; }
.plan-card .eta { margin-left: auto; font-weight: 700; font-size: .8rem; color: #15803d; }
.plan-card .eta.late { color: #b91c1c; }
.plan-card .pc-move { margin-left: auto; display: inline-flex; gap: 2px; }
.plan-card .pc-move .mv { border: 1px solid var(--border); background: #fff; border-radius: 5px; width: 22px; height: 22px; line-height: 1; padding: 0; cursor: pointer; color: var(--muted); font-size: .8rem; }
.plan-card .pc-move .mv:hover { background: #f1f5f9; color: var(--primary); border-color: var(--primary); }
.plan-card .pc-top .eta + .pc-move { margin-left: .4rem; }
.plan-col-sum { padding: .3rem .7rem; font-size: .76rem; color: var(--muted); border-bottom: 1px solid var(--border); background: #f8fafc; }
.plan-card .pc-title { display: block; font-weight: 600; color: var(--text); text-decoration: none; font-size: .88rem; }
.plan-card .pc-title:hover { color: var(--primary); }
.plan-card .pc-sub { font-size: .8rem; color: var(--text); }
.plan-card .pc-addr { font-size: .76rem; color: var(--muted); }
.plan-card .pc-win { font-size: .72rem; color: #b45309; margin-top: .15rem; }
.plan-card .pc-warn { font-size: .72rem; color: var(--danger); margin-top: .15rem; }

.plan-map { height: 460px; border-radius: 8px; overflow: hidden; }
.route-pin div {
  color: #fff; border-radius: 50%; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* --- Indstillinger --- */
.settings-nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.settings-nav a { padding: .35rem .8rem; background: #fff; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .82rem; }
.settings-nav a:hover { border-color: var(--primary); color: var(--primary); }
.car-edit { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; background: #f8fafc; }
.car-edit summary { padding: .2rem 0; }
.car-edit form { margin-top: .8rem; }

/* --- Teknikervisning --- */
.tech-list { display: flex; flex-direction: column; gap: .8rem; }
.tech-stop { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; }
.tech-stop.done { opacity: .6; }
.ts-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem; flex-wrap: wrap; }
.ts-head .seq.big { background: #14213d; color: #fff; border-radius: 999px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.ts-title { font-size: 1.05rem; font-weight: 600; }
.ts-title a { color: var(--text); text-decoration: none; }
.ts-cust { color: var(--text); }
.ts-addr { color: var(--muted); margin-bottom: .3rem; }
.ts-desc { background: #f8fafc; border-radius: 6px; padding: .4rem .6rem; margin: .4rem 0; font-size: .9rem; }
.ts-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }

/* --- Mobil --- */
@media (max-width: 740px) {
  .container { padding: .9rem .7rem; }
  .topnav { flex-wrap: wrap; height: auto; min-height: 52px; padding: .55rem .8rem; gap: .35rem .9rem; row-gap: .3rem; }
  .topnav .whoami { display: none; }
  h1 { font-size: 1.25rem; }
  .card { padding: .85rem .8rem; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { white-space: nowrap; }
  input, select, textarea, button { font-size: 16px; }
  .searchbox input[type="search"] { min-width: 0; flex: 1; }
  .plan-col { flex-basis: 82vw; }
  .ts-actions .btn { flex: 1; text-align: center; }
}
