:root {
  --blue: #0070BA; --blue-dark: #005391; --blue-deep: #003A66; --blue-tint: #E8F1FA;
  --ink: #13202F; --ink-2: #34414F; --muted: #5B6878; --line: #DCE2E9; --line-soft: #EDF1F5;
  --ground: #F3F5F8; --card: #FFFFFF;
  --red: #B42318; --red-tint: #FDECEA; --amber: #8A5100; --amber-tint: #FFF4E0; --amber-dot: #D98A00;
  --green: #1F6B45; --green-tint: #E7F5EE;
  --radius: 12px;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--ground);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); font-size: 15px; line-height: 1.45; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: var(--blue-deep); }
h1 { font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -0.3px; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
h3.sub-head { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 0 6px; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #C5CFDA; border-radius: 10px; background: #fff;
}
textarea { resize: vertical; min-height: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--blue); flex-shrink: 0; margin: 2px 0 0; }
code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }

.muted { color: var(--muted); } .small { font-size: 13px; } .block { display: block; }
.danger { color: var(--red); } .warning-text { color: var(--amber); }
.grow { flex: 1 1 auto; min-width: 0; } .mt { margin-top: 12px; }
.pre { white-space: pre-wrap; margin: 0; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- logo ---------- */
.logo {
  border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Zilla Slab', Georgia, serif; font-weight: 700; letter-spacing: -1px; flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--blue);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid #C5CFDA; border-radius: 10px; background: #fff; color: var(--ink); font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #9AA6B3; color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-link { border: none; background: none; color: var(--blue-dark); padding: 0 4px; min-height: 36px; font-weight: 600; }
.btn-link:hover { color: var(--blue-deep); }
.btn-danger-link { border: none; background: none; color: var(--red); margin-top: 12px; padding: 0; min-height: 40px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 22px;
  color: var(--ink-2); flex-shrink: 0;
}
.icon-btn:hover { background: var(--line-soft); }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 22px 14px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-name { font-weight: 600; line-height: 1.2; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--ink-2); background: none; border: none; width: 100%; text-align: left; cursor: pointer; font-size: 14px;
}
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--blue-tint); color: var(--blue-dark); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.sidebar-foot .muted { padding: 0 12px; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; min-width: 0; }
.page { max-width: 1200px; margin: 0 auto; padding: 28px 36px 48px; display: flex; flex-direction: column; gap: 18px; }
.narrow-page { max-width: 760px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .muted { margin-top: 2px; }
.bottom-nav { display: none; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-width: 0; }
.card.narrow { max-width: 400px; width: 100%; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card.internal { background: #FBFCFE; border-style: dashed; border-color: #9AA6B3; }
.card.internal > p { margin: -6px 0 10px; }
.list-card { padding: 4px 0; }
.row-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 56px; border-bottom: 1px solid var(--line-soft);
  color: var(--ink); background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left; cursor: pointer;
}
.row-link:last-child { border-bottom: none; }
.row-link:hover { background: #F8FAFC; color: var(--ink); }
.row-link a { color: var(--ink); }
.item-title { font-weight: 500; }

.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { display: flex; flex-direction: column; gap: 14px; align-items: stretch; padding: 32px; }
.login .logo { align-self: center; margin-bottom: 4px; }
.login h1 { text-align: center; font-size: 22px; }
.login > p { text-align: center; margin: -8px 0 4px; }

/* ---------- toolbar / segments / search ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 280px; max-width: 460px; background: #fff;
  border: 1px solid #C5CFDA; border-radius: 10px; padding: 0 12px; color: var(--muted);
}
.search input { border: none; padding: 10px 0; min-height: 42px; outline: none; color: var(--ink); }
.search:focus-within { outline: 2px solid var(--blue); outline-offset: 1px; }
.seg { display: inline-flex; background: #E6EBF1; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: none; background: none; min-height: 38px; padding: 0 14px; border-radius: 8px; color: var(--ink-2); cursor: pointer; font-weight: 500; }
.seg button.on { background: #fff; color: var(--blue-dark); font-weight: 600; box-shadow: 0 1px 2px rgba(19,32,47,.12); }
.seg-wide { align-self: flex-start; }

/* ---------- chips / prio / dots ---------- */
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; white-space: nowrap; background: var(--line-soft); color: var(--ink-2); }
.chip-accent { background: var(--blue-tint); color: var(--blue-dark); }
.chip-success { background: var(--green-tint); color: var(--green); }
.chip-warning { background: var(--amber-tint); color: var(--amber); }
.chip-danger { background: var(--red-tint); color: var(--red); }
.prio { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.prio-A { background: var(--blue); color: #fff; } .prio-B { background: var(--blue-tint); color: var(--blue-dark); }
.prio-C { background: var(--line-soft); color: var(--ink-2); } .prio-none { color: #9AA6B3; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.dot-high { background: var(--red); } .dot-mid { background: var(--amber-dot); } .dot-low { background: var(--blue); }

/* ---------- lists ---------- */
.action-list, .radar-list, .plain-list, .timeline, .preview-list { list-style: none; margin: 0; padding: 0; }
.action-list li, .radar-list li, .plain-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.action-list li:last-child, .radar-list li:last-child, .plain-list li:last-child { border-bottom: none; }
.plain-list li { align-items: center; }
.plain-list a.grow, .radar-list a.grow { color: var(--ink); }
.date-col { width: 76px; flex-shrink: 0; font-weight: 600; color: var(--blue-dark); font-size: 14px; }
.timeline li { padding: 10px 0 10px 14px; border-left: 2px solid var(--line); margin-left: 4px; }
.timeline li + li { margin-top: 2px; }
.preview-list li { padding: 4px 0; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.empty.small { padding: 10px 0; text-align: left; font-size: 14px; }

.quick-action { display: grid; grid-template-columns: minmax(0, 1fr) 160px auto; gap: 8px; margin-top: 12px; }
.quick-action .field-hint { grid-column: 1 / -1; }
.note-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.log { margin-top: 14px; }
.log summary { cursor: pointer; color: var(--muted); font-size: 13px; min-height: 32px; }
.log ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wide { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-hint.danger { color: var(--red); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.error-box { background: var(--red-tint); color: var(--red); border-radius: 10px; padding: 10px 14px; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ok-box { background: var(--green-tint); color: var(--green); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 12px; }
.check { display: flex; gap: 8px; align-items: center; min-height: 40px; }

.picker { position: relative; }
.picker-list { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(19,32,47,.12); max-height: 300px; overflow-y: auto; }
.picker-list button { display: block; width: 100%; text-align: left; border: none; background: none; min-height: 44px; padding: 8px 14px; cursor: pointer; }
.picker-list button:hover { background: var(--line-soft); }
.picker-new { color: var(--blue-dark); font-weight: 600; display: flex !important; align-items: center; gap: 6px; border-top: 1px solid var(--line-soft) !important; }
.picker-current { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px 0 12px; border: 1px solid #C5CFDA; border-radius: 10px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fin-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.fin-grid dt { color: var(--muted); font-size: 14px; } .fin-grid dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- import ---------- */
.preview { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table select { min-width: 180px; min-height: 38px; padding: 6px 8px; }
.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; width: 100%; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; }
.map-src { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.map-src .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- kundnamn / adresser ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-removable { padding-right: 4px; gap: 4px; font-weight: 500; font-size: 13px; }
.chip-removable button { border: none; background: none; width: 24px; height: 24px; border-radius: 12px; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }
.chip-removable button:hover { background: #DCE2E9; color: var(--ink); }
.alias-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.btn-link.small, button.btn-link.small { display: inline-flex; align-items: center; font-size: 13px; min-height: 32px; padding: 0; font-weight: 600; background: none; border: none; color: var(--blue-dark); cursor: pointer; }
.btn-link.small.danger { color: var(--red); }
.row-warn td { background: #FFFAF0; }
.resolve { width: 100%; }
.resolve .table select { min-width: 220px; }

/* ---------- mobil ---------- */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .page { padding: 18px 16px 110px; gap: 14px; }
  h1 { font-size: 22px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > .radar-card { order: -1; }
  .form, .map-grid { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .row-link { padding: 12px 16px; }
  .quick-action { grid-template-columns: minmax(0, 1fr) auto; }
  .quick-action input[type=text], .quick-action input:first-child { grid-column: 1 / -1; }
  .search { max-width: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: #4A5868; min-height: 52px; justify-content: center; }
  .bottom-nav a.active { color: var(--blue-dark); font-weight: 600; }
  .page-head .btn-primary { min-height: 40px; padding: 0 12px; }
}
