:root {
  /* RU Blond – färger från logotypen */
  --bg: #fbf0ea;            /* ljus persika */
  --card: #ffffff;
  --ink: #1c2a30;           /* nästan svart petrol */
  --muted: #8c7b75;
  --line: #f1dfd7;
  --accent: #2c6273;        /* petroleumblått från banden */
  --accent-soft: #fde4d8;   /* krämrosa från cirkeln */
  --blush: #efb3a6;         /* rosa bakgrund */
  --ink-btn: #1c2a30;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok: #2e7d64;
  --ok-soft: #e3f2ec;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --tabbar-h: 64px;
  --font: "Avenir Next", "Avenir Next LT Pro", "Avenir", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --serif: "Didot", "Bodoni 72", "Bodoni MT", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1d; --card: #1e262a; --ink: #f3e9e4; --muted: #a2948f; --line: #2f393d;
    --accent: #7fb8c6; --accent-soft: #3a2e2a; --blush: #c98d81; --ink-btn: #f3e9e4;
    --danger: #ff8a80; --danger-soft: #3d201d; --ok: #7fd3b4; --ok-soft: #1c3029; --warn-soft: #3a3220;
  }
}

/* Logotypens stil: versaler i serif med stort teckenavstånd */
.brandmark { font-family: var(--serif); font-weight: 700; text-transform: uppercase; letter-spacing: .32em; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: inherit; }
h2 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------- topp ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--serif); letter-spacing: .02em; font-size: 21px; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 30px; line-height: 1; text-decoration: none; padding: 0 8px 4px 0; }
.topbar-actions { display: flex; gap: 6px; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px; outline: none; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------- flikrad ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500;
}
.tabbar .ico { font-size: 22px; line-height: 1; }
.tabbar a.active { color: var(--ink); }
.tabbar a.active .ico { color: var(--accent); }
.tabbar .tab-new .ico {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--ink-btn); color: var(--card) !important; font-size: 22px;
}
.logged-out .tabbar, .logged-out #topActions { display: none; }

/* ---------- kort & listor ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 10px 0; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card.error { background: var(--danger-soft); color: var(--danger); }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin: 10px 0; }
.list > a, .list > div.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  text-decoration: none; border-bottom: 1px solid var(--line);
}
.list > :last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .chev { color: var(--muted); }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 15px;
}
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.alert {
  background: var(--danger-soft); color: var(--danger); border-radius: var(--radius);
  padding: 12px 14px; margin: 10px 0; font-weight: 500; white-space: pre-wrap;
}
.alert b { display: block; margin-bottom: 2px; }
.badge-alert { color: var(--danger); font-weight: 700; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--line); color: var(--ink); margin: 2px 4px 2px 0; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.no { background: var(--danger-soft); color: var(--danger); }
.pill.gold { background: var(--accent-soft); color: var(--accent); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 14px; }
dl.facts dd { margin: 0; white-space: pre-wrap; }

.formula {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px;
  background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; margin: 6px 0;
}

/* ---------- formulär ---------- */
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 5px; }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=number],
input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > div > label { margin-top: 14px; }
.check { display: flex; align-items: flex-start; gap: 10px; color: var(--ink); font-size: 15px; margin: 12px 0; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: 4px 2px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
}
.btn.primary { background: var(--ink-btn); color: var(--card); border-color: var(--ink-btn); }
.btn.gold { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.blush { background: var(--blush); color: var(--ink); border-color: var(--blush); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btns .btn { flex: 1 1 auto; }
.icon-btn { font: inherit; background: none; border: 0; color: var(--ink); font-size: 15px; font-weight: 600; padding: 6px 8px; cursor: pointer; text-decoration: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 14px; padding: 8px 13px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.chip.on { background: var(--ink-btn); color: var(--card); border-color: var(--ink-btn); }
.chip-add { border-style: dashed; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.svc-new { background: var(--accent-soft); margin-top: 10px; }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; font: inherit; font-size: 14px; font-weight: 600; border: 0; background: none; padding: 7px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.searchbar { position: sticky; top: calc(env(safe-area-inset-top) + 56px); z-index: 10; background: var(--bg); padding: 8px 0 4px; }
.picker-results { margin-top: 6px; }

/* ---------- tidbok ---------- */
.daynav { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; }
.daynav .label { flex: 1; text-align: center; font-weight: 600; }
.daynav .label small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.daynav .btn { min-height: 40px; padding: 6px 14px; }

.timeline { position: relative; background: var(--card); border-radius: var(--radius); margin: 10px 0; overflow: hidden; }
.timeline .hour { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); padding: 2px 0 0 8px; pointer-events: none; }
.timeline .half { position: absolute; left: 52px; right: 0; border-top: 1px dashed var(--line); opacity: .6; pointer-events: none; }
.timeline .now { position: absolute; left: 48px; right: 0; border-top: 2px solid var(--danger); z-index: 3; pointer-events: none; }
.timeline .now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.timeline .slots { position: absolute; left: 52px; right: 6px; top: 0; bottom: 0; }
.appt {
  position: absolute; border-radius: 9px; padding: 5px 8px; overflow: hidden; text-decoration: none;
  background: var(--accent-soft); border-left: 4px solid var(--accent); font-size: 13px; line-height: 1.3; z-index: 2;
}
.appt b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt b .badge-alert { display: inline; color: var(--danger); }
.appt > span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.done { background: var(--ok-soft); border-left-color: var(--ok); }
.appt.noshow, .appt.cancelled { background: var(--line); border-left-color: var(--muted); opacity: .7; }
.appt.cancelled b { text-decoration: line-through; }

.status-done { color: var(--ok); }
.status-noshow, .status-cancelled { color: var(--muted); }
.time-col { width: 52px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- foton ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin: 8px 0; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photos .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 13px; }
#lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: grid; place-items: center; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
#lightbox button { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; font-size: 22px; color: #fff; background: rgba(255,255,255,.15); border: 0; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; }

.visit { border-top: 1px solid var(--line); padding: 14px 0; }
.visit:first-child { border-top: 0; padding-top: 0; }
.visit-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px);
  background: var(--ink-btn); color: var(--card); padding: 11px 18px; border-radius: 12px; font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 90; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

/* ---------- inloggning ---------- */
.login { max-width: 400px; margin: 8vh auto 0; }
.login .brand { text-align: center; margin-bottom: 18px; }
.login .brand .logo { width: 180px; height: 180px; margin: 0 auto 6px; display: block; filter: drop-shadow(0 6px 18px rgba(176,110,95,.25)); }
body.logged-out { min-height: 100vh; background: linear-gradient(180deg, var(--blush) 0%, var(--bg) 60%) fixed; padding-bottom: 0; }
.logged-out .topbar { display: none; }
.login .brand h2 { font-size: 15px; color: var(--ink); margin: 6px 0 0; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }

table.log { width: 100%; border-collapse: collapse; font-size: 13px; }
table.log td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---------- utskrift ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 12pt; }
  .topbar, .tabbar, #toast, .no-print, .btns { display: none !important; }
  main { max-width: none; padding: 0; }
  .card, .list { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .print-only { display: block; }
  .formula { background: #f3f3f3; }
  .alert { border: 2px solid #b3261e; background: #fff; }
  a { text-decoration: none; }
}
