:root {
  --bg: #f5f6f2; --surface: #ffffff; --surface-2: #eef1ea; --text: #1d2a22; --muted: #66756b; --line: #dde3d8;
  --accent: #2f6f4e; --accent-ink: #ffffff; --accent-soft: #e2efe7; --danger: #b3261e; --warn: #9a6a00; --ok: #1f7a43;
  --shadow: 0 6px 24px rgba(20, 40, 28, .18); --radius: 10px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714; --surface: #1b221e; --surface-2: #232c27; --text: #e6ece8; --muted: #9aa99f; --line: #2f3a34;
    --accent: #6fbf8f; --accent-ink: #0e1a13; --accent-soft: #23362b; --danger: #ff8a80; --warn: #e0b04a; --ok: #7fd49a;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: var(--safe-b); }
body.noscroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
a { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .mono { font-family: ui-monospace, Menlo, monospace; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* knappar och fält */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); } .btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); } .btn.small { min-height: 36px; padding: 5px 12px; font-size: .9rem; } .btn.block { width: 100%; }
.icon-btn { background: transparent; border: 0; color: var(--text); font-size: 1.25rem; width: 42px; height: 42px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); } .icon-btn.small { width: 34px; height: 34px; font-size: 1rem; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: 6px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 42px; width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--accent); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .row.item:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.secret-input { -webkit-text-security: disc; }
.frow { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; }
.flabel { font-size: .85rem; font-weight: 600; color: var(--muted); }
.hint { font-size: .82rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; } .btn-row.end { justify-content: flex-end; }
.form-error { color: var(--danger); margin: 8px 0; min-height: 1em; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: 6px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--danger); } .badge.warn { color: var(--warn); }

/* huvudvy */
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: calc(8px + var(--safe-t)) 14px 8px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; margin-right: 6px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.tab { border: 0; background: transparent; color: var(--text); font: inherit; padding: 7px 14px; border-radius: 8px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tab .count { font-size: .78rem; opacity: .85; }
.spacer { flex: 1; }
.search { width: 220px; max-width: 100%; }
.main { max-width: 1100px; margin: 0 auto; padding: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select { width: auto; min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.plant { grid-template-columns: 56px minmax(0, 1fr) 120px 150px 100px; }
.row.dahlia { grid-template-columns: 56px minmax(0, 1fr) 110px 70px 70px 140px 100px; }
.row.head { background: var(--surface-2); font-size: .8rem; color: var(--muted); padding-top: 6px; padding-bottom: 6px; }
.colhead { background: none; border: 0; padding: 4px 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.colhead.sorted { color: var(--accent); font-weight: 700; }
.row.item { cursor: pointer; } .row.item:hover { background: var(--surface-2); }
.c-thumb { width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.c-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } .noimg { font-size: 1.5rem; opacity: .6; }
.c-name { display: flex; flex-direction: column; min-width: 0; } .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .latin { font-style: italic; }
.row [class^="c-"]:not(.c-thumb):not(.c-name), .row [class*=" c-"]:not(.c-thumb):not(.c-name) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); }
.pill.s-active { background: var(--accent-soft); color: var(--ok); } .pill.s-dead { color: var(--danger); } .pill.s-wish { color: #7b4bb8; } .pill.s-rest { color: #2b6cb0; }
.empty { text-align: center; padding: 48px 16px; } .empty-icon { font-size: 3rem; } .list-foot { text-align: right; font-size: .85rem; padding: 8px 4px; }
.menu { position: absolute; z-index: 60; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.menu-item { background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: block; }
.menu-item:hover { background: var(--surface-2); } .menu-foot { font-size: .75rem; color: var(--muted); padding: 6px 12px; border-top: 1px solid var(--line); margin-top: 4px; }

/* modaler */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 20, 14, .55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: calc(24px + var(--safe-t)) 12px 24px; }
.modal { background: var(--surface); width: 100%; max-width: 520px; border-radius: 14px; box-shadow: var(--shadow); margin: auto 0; }
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); border-radius: 14px 14px 0 0; z-index: 2; }
.modal-head h2 { font-size: 1.1rem; } .modal-body { padding: 16px 20px 20px; }
.confirm-text { margin: 0 0 8px; }

/* växtkort: fält i en enda kolumn, ett per rad */
.card-title { margin: 14px 0 6px; } .plant-name { font-size: 1.5rem; margin: 0 0 2px; } .card-title .latin { color: var(--muted); margin-bottom: 6px; }
.kvgroup h4 { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 4px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv .k { color: var(--muted); font-size: .92rem; } .kv .v { overflow-wrap: anywhere; } .kv .v.long { white-space: pre-wrap; }
.photos { margin-bottom: 4px; } .big-photo { display: block; width: 100%; padding: 0; border: 0; background: var(--surface-2); border-radius: 12px; overflow: hidden; cursor: zoom-in; }
.big-photo img { display: block; width: 100%; max-height: 420px; object-fit: cover; } .caption { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0; } .thumb { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; width: 60px; height: 60px; flex: none; background: none; cursor: pointer; }
.thumb.sel { border-color: var(--accent); } .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.add-photo { cursor: pointer; } .lightbox { width: 100%; height: auto; border-radius: 8px; display: block; }
.logbox .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--accent-soft); color: var(--text); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.log { list-style: none; margin: 0 0 10px; padding: 0; } .log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log-head { display: flex; gap: 10px; align-items: center; } .log-date { color: var(--muted); font-variant-numeric: tabular-nums; } .log-actions { margin-left: auto; display: flex; }
.log-body { margin-top: 2px; white-space: pre-wrap; } .card-actions { margin-top: 20px; } .meta { margin-top: 12px; }

/* formulär: en kolumn */
.form-group { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 calc(4px + var(--safe-b)); margin-top: 16px; }
.lookup { margin: -4px 0 12px; } .lookup-card { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-top: 8px; } .lookup-card .summary { margin: 6px 0; font-size: .92rem; }
.identify .pend-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; } .pend { position: relative; width: 64px; height: 64px; }
.pend img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; } .pend .icon-btn { position: absolute; top: -8px; right: -8px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.cands { list-style: none; padding: 0; margin: 8px 0; } .cands li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cand-right { display: flex; align-items: center; gap: 8px; flex: none; } .score { font-variant-numeric: tabular-nums; color: var(--muted); }

/* inloggning */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); width: 100%; max-width: 400px; padding: 28px 24px; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.login-logo { font-size: 2.6rem; } .login-card h1 { font-size: 1.6rem; } .login-sub { color: var(--muted); margin: 6px 0 18px; }
.login-form { text-align: left; } .login-links { text-align: center; margin-top: 8px; }
.steps { padding-left: 20px; color: var(--muted); font-size: .9rem; } .qr { width: 220px; max-width: 100%; margin: 8px auto; background: #fff; padding: 6px; border-radius: 8px; } .qr svg { width: 100%; height: auto; display: block; }
.secret { text-align: center; font-size: .85rem; word-break: break-all; } .codes { background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: 1.05rem; line-height: 1.7; white-space: pre-wrap; }

/* tabeller och listor i dialoger */
.table-scroll { overflow-x: auto; } .table { width: 100%; border-collapse: collapse; font-size: .92rem; } .table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 6px 8px; }
.table td { padding: 8px; border-top: 1px solid var(--line); vertical-align: middle; } tr.off { opacity: .55; }
.key-state { margin: 4px 0 8px; color: var(--muted); } .key-state.ok { color: var(--ok); }
.settings section, .modal-body > section { margin-bottom: 18px; } .user-add { border-top: 1px solid var(--line); margin-top: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .inline-form input { flex: 1 1 160px; width: auto; }
.device-list { list-style: none; padding: 0; margin: 0 0 10px; } .device-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* aviseringar */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 24px); pointer-events: none; }
.toast { background: #243a2e; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 520px; pointer-events: auto; } .toast.err { background: var(--danger); }

@media (max-width: 720px) {
  .brand-name { display: none; } .search { width: 100%; flex: 1 1 100%; order: 10; } .tabs { flex: 1; } .tab { flex: 1; justify-content: center; }
  .main { padding: 10px; }
  .row.plant, .row.dahlia { grid-template-columns: 52px minmax(0, 1fr) auto; padding: 8px 10px; }
  .row [class^="c-"]:not(.c-thumb):not(.c-name):not(.c-status) { display: none; }
  .row.head { display: none; } .hide-s { display: none; }
  .overlay { padding: calc(8px + var(--safe-t)) 0 0; } .modal, .modal.wide { max-width: none; border-radius: 14px 14px 0 0; min-height: calc(100vh - 8px); margin: 0; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv .k { font-size: .8rem; }
  .filters select { max-width: none; }
}
@media print { .topbar, .filters, #toasts, .modal-head .icon-btn, .btn { display: none !important; } .overlay { position: static; background: none; } .modal { box-shadow: none; } }

/* 1.1.0: inställningshubb, statistik, önskemål, segment */
.scats { display: flex; flex-direction: column; gap: 8px; }
.cbtn { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font: inherit; cursor: pointer; }
.cbtn:hover { background: var(--surface-2); } .cbtn i { font-style: normal; font-size: 1.5rem; width: 32px; text-align: center; }
.cbtn .cst { flex: 1; display: flex; flex-direction: column; } .cbtn small { color: var(--muted); font-size: .85rem; } .cbtn .chev { color: var(--muted); font-size: 1.4rem; }
.sback { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 4px 0 10px; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.seg-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px; padding: 6px 16px; font: inherit; cursor: pointer; }
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; } .seg .btn { margin-left: auto; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 8px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; } .fact-n { font-size: 1.5rem; font-weight: 700; color: var(--accent); line-height: 1.1; } .fact-l { font-size: .8rem; color: var(--muted); }
.sgroup h3 { margin: 20px 0 8px; font-size: 1rem; }
.brow { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 8px; align-items: center; padding: 3px 0; font-size: .92rem; }
.brow.muted .bl, .brow.muted .bn { color: var(--muted); } .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bn { font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.bar { background: var(--accent-soft); border-radius: 4px; height: 10px; overflow: hidden; display: block; } .fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 120px; overflow-x: auto; padding-bottom: 2px; }
.vcol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 26px; flex: 1; } .vbar { width: 70%; background: var(--accent); border-radius: 3px 3px 0 0; display: block; }
.vn { font-size: .7rem; color: var(--muted); } .vl { font-size: .68rem; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.toplist { list-style: none; padding: 0; margin: 0; } .toplist li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.fri { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fri .frt { flex: 1; min-width: 0; line-height: 1.4; overflow-wrap: anywhere; } .fri .frt small { color: var(--muted); font-size: .78rem; } .fri.done .frtx { opacity: .55; text-decoration: line-through; }
.fra { display: flex; gap: 4px; flex: none; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 190px; }
.frs { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px; padding: 4px 12px; font: inherit; font-size: .8rem; cursor: pointer; }
.frs[data-s="ny"] { border-color: var(--accent); color: var(--accent); } .frs[data-s="pågår"] { border-color: #b7791f; color: #b7791f; } .frs[data-s="klar"] { border-color: var(--ok); color: var(--ok); }
.frimgs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; } .frimgw { position: relative; display: inline-block; }
.frimg { padding: 0; width: 84px; height: 84px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); cursor: zoom-in; } .frimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frimgx { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; cursor: pointer; }
.remote-list { margin-top: 8px; }
@media (max-width: 720px) { .fra { max-width: none; } .fri { flex-direction: column; } .brow { grid-template-columns: minmax(80px, 38%) 1fr auto; } }
@media print { .seg, .menu { display: none !important; } }

/* 1.2.0: önskelista */
.row.wish { grid-template-columns: 56px minmax(0, 1fr) 80px 130px 150px 96px; }
.c-act { text-align: right; }
.tabs { flex-wrap: nowrap; } .tab { white-space: nowrap; }
@media (max-width: 720px) {
  .row.wish { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .row [class^="c-"].c-act { display: block; } .tab { padding: 7px 8px; font-size: .9rem; } .tab .count { display: none; }
}

/* 1.2.1: visa/dölj lösenord */
.pwwrap { position: relative; display: block; }
.pwwrap input { padding-right: 48px; }
.eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.eye:hover, .eye[aria-pressed="true"] { color: var(--accent); background: var(--surface-2); }
.inline-form .pwwrap { flex: 1 1 160px; }

/* 1.3.0: artinfo med flera källor */
.offer { margin: 8px 0; } .offer-row { display: grid; grid-template-columns: auto 130px 1fr; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.offer-row .ol { color: var(--muted); font-size: .85rem; } .offer-row .ov { overflow-wrap: anywhere; font-size: .92rem; }
.src-line .ok { color: var(--ok); } .src-line .bad { color: var(--danger); cursor: help; } .form-warn { color: var(--warn); margin: 6px 0; font-size: .92rem; }
.lookup { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; } .lookup-out { flex: 1 1 100%; }
@media (max-width: 720px) { .offer-row { grid-template-columns: auto 1fr; } .offer-row .ol { grid-column: 2; } .offer-row .ov { grid-column: 2; } }

/* 1.4.0: val av källor */
.srcchips { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 2px; }
.chip-toggle { background: var(--surface); color: var(--muted); } .chip-toggle.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.src-opt { align-items: flex-start; margin: 12px 0; }
