:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1c1b18;
  --muted: #6b6860;
  --line: #e2e0d8;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --priv: #9a5b00;
  --priv-soft: #fdf1dc;
  --err: #b42318;
  --err-soft: #fdeceb;
  --ok-soft: #e7f4ec;
  --wa: #1fa855;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311; --surface: #1b1c1a; --surface-2: #242522; --text: #ecebe6; --muted: #a09e96;
    --line: #2f302c; --accent: #2bb3a5; --accent-ink: #06201d; --accent-soft: #123430;
    --priv: #f0b350; --priv-soft: #3a2a10; --err: #ff8a80; --err-soft: #3b1714; --ok-soft: #13301f;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311; --surface: #1b1c1a; --surface-2: #242522; --text: #ecebe6; --muted: #a09e96;
  --line: #2f302c; --accent: #2bb3a5; --accent-ink: #06201d; --accent-soft: #123430;
  --priv: #f0b350; --priv-soft: #3a2a10; --err: #ff8a80; --err-soft: #3b1714; --ok-soft: #13301f;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
code { font: .9em ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .03em; }
.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* layout */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .75rem 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: .35rem; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand .ic { color: var(--accent); }
.brand span { color: var(--muted); font-weight: 500; margin-left: .2rem; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.nav a, .linkbtn {
  padding: .35rem .6rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .92rem;
}
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.linkbtn { background: none; border: 0; cursor: pointer; font: inherit; font-size: .92rem; }

/* app bar: ☰ left, ⋮ right on phones; inline nav on wide screens */
.top { flex-wrap: nowrap; position: sticky; top: 0; z-index: 20; padding: .5rem 8px; gap: .25rem; }
.top .brand { margin-right: auto; }
.iconbtn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn .ic { width: 24px; height: 24px; }
.iconbtn:focus-visible { outline: 2px solid var(--accent); }
.more { position: relative; }
.more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: grid;
}
.more-menu form { margin: 0; }
.more-menu a, .more-menu button {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .65rem .7rem; border-radius: 8px;
  color: var(--text); text-decoration: none; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; text-align: left;
}
.more-menu a:hover, .more-menu button:hover { background: var(--surface-2); }
.more-menu .ic { color: var(--muted); }
.drawer-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 30; }
.drawer {
  position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 31; overflow-y: auto;
  background: var(--surface); box-shadow: var(--shadow); padding: 8px 12px 24px;
  transform: translateX(-100%); transition: transform .2s ease;
}
.drawer.is-open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px 6px; }
.drawer-user { margin: 4px 6px 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.drawer-nav { display: grid; gap: 2px; }
.drawer-nav a { display: flex; align-items: center; gap: .8rem; padding: .8rem .7rem; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
.drawer-nav a .ic { color: var(--muted); width: 22px; height: 22px; }
.drawer-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.drawer-nav a[aria-current="page"] .ic { color: var(--accent); }
@media (max-width: 759px) {
  .top .nav { display: none; }
}
@media (min-width: 760px) {
  .menu-btn { display: none; }
  .top { padding: .6rem 16px; gap: 1rem; }
  .top .brand { margin-right: 0; }
  .top .nav { margin-right: auto; }
}
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; }
.is-profile .wrap { max-width: 480px; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 14px 0; box-shadow: var(--shadow);
}
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.center-text { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.two, .three { display: grid; gap: 0 14px; }
@media (min-width: 680px) {
  .two { grid-template-columns: 1fr 1fr; }
  .three { grid-template-columns: repeat(3, 1fr); }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.panel.danger { border-color: var(--err-soft); }
.foot a { color: var(--muted); }
.legal h2 { margin-top: 1.4rem; }
.legal p, .legal li { color: var(--text); }
.legal .placeholder { color: var(--err); font-weight: 600; }
.btn-sm { padding: .35rem .7rem; min-height: 36px; font-size: .9rem; }
.btn-block { width: 100%; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.row-actions.center { justify-content: center; }

/* forms */
.form { display: grid; gap: .75rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="file"] { padding: .45rem; }
input[type="radio"], input[type="checkbox"] { width: auto; min-height: 0; }
.err { color: var(--err); font-size: .88rem; margin: .25rem 0 0; font-weight: 500; }
.hint { color: var(--muted); font-size: .82rem; margin: .3rem 0 0; }
.hp { position: absolute; left: -9999px; }
.check { display: flex !important; align-items: center; gap: .4rem; font-weight: 400 !important; margin-top: .4rem; }
.prefix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.prefix span { padding: .6rem 0 .6rem .7rem; color: var(--muted); font-weight: 400; white-space: nowrap; font-size: .92rem; align-self: center; }
.prefix input { border: 0; border-radius: 0; padding-left: .15rem; min-width: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input { flex: 1 1 200px; width: auto; }
.inline-form select { width: auto; }

.edit { gap: 0; }
.frow { border: 0; border-bottom: 1px solid var(--line); padding: 14px 0; margin: 0; display: grid; gap: .35rem; }
.frow > label, .frow legend { font-weight: 600; font-size: .92rem; padding: 0; }
.frow.has-err input, .frow.has-err textarea { border-color: var(--err); }
.vis { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; width: max-content; background: var(--surface-2); }
.vis label { position: relative; cursor: pointer; }
.vis input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.vis span { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .75rem; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.vis input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.vis input[value="private"]:checked + span { background: var(--priv-soft); color: var(--priv); }
.vis input:focus-visible + span { outline: 2px solid var(--accent); }
.photo-edit { display: flex; gap: 14px; align-items: center; }
.sticky-save { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.sticky-save .btn { width: 100%; }

/* notices */
.flash, .notice { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
.flash p { margin: 0; }
.flash-ok { background: var(--ok-soft); }
.flash-err { background: var(--err-soft); color: var(--err); }
.notice { background: var(--accent-soft); font-size: .92rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.notice-priv { background: var(--priv-soft); color: var(--priv); }
.notice-link { text-decoration: none; color: var(--priv); background: var(--priv-soft); font-weight: 600; }
.copybox { display: flex; gap: .4rem; margin: .5rem 0 0; }
.copybox input { font-size: .85rem; min-height: 36px; padding: .35rem .55rem; }

/* profile */
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px 18px 8px; box-shadow: var(--shadow); }
.pcard-head { text-align: center; }
.avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 12px; background: var(--surface-2); }
.avatar-sm { width: 72px; height: 72px; margin: 0; }
.avatar-empty { display: grid; place-items: center; font-size: 2.4rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.pcard h1 { font-size: 1.55rem; margin-bottom: .2rem; }
.headline { margin: 0; font-weight: 500; }
.company { margin: .1rem 0 0; color: var(--muted); }
.actions { display: flex; justify-content: center; gap: 10px; margin: 18px 0 12px; }
.act {
  display: grid; justify-items: center; gap: 4px; text-decoration: none; color: var(--text);
  font-size: .78rem; font-weight: 600; min-width: 76px; padding: 10px 6px; border-radius: 12px; background: var(--surface-2);
}
.act .ic { width: 22px; height: 22px; color: var(--accent); }
.bio { margin: 18px 0 4px; color: var(--text); }
.details { list-style: none; padding: 0; margin: 10px 0 0; }
.details li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.details li > .ic { color: var(--muted); margin-top: .2rem; }
.details li > div { display: grid; min-width: 0; }
.details a, .dval { overflow-wrap: anywhere; }
.dlabel { font-size: .78rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.tag-priv { display: inline-flex; align-items: center; gap: .2rem; font-size: .72rem; font-weight: 600; color: var(--priv); background: var(--priv-soft); border-radius: 999px; padding: 0 .45rem; }
.tag-priv .ic { width: .9em; height: .9em; }
.cta-own { text-align: center; font-size: .9rem; margin-top: 18px; }

/* app */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; font-size: .82rem; color: var(--muted); }
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: .5rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.tbl td:last-child { text-align: right; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill-ok { background: var(--ok-soft); color: var(--accent); }
.cardrow.is-off { opacity: .65; }
.cardrow-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.cardrow-head h2 { margin: 0; }
.cardrow-head p { margin: .2rem 0 0; font-size: .88rem; }
.kv { margin: 12px 0; }
.kv dt { font-size: .8rem; color: var(--muted); margin-top: .6rem; }
.kv dd { margin: 0; }
.kv .copybox { margin-top: .25rem; }
.howto { margin-top: 12px; font-size: .9rem; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.howto ol { padding-left: 1.2rem; display: grid; gap: .35rem; }
.req { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding: 12px 0; border-top: 1px solid var(--line); }
.req:first-of-type { border-top: 0; }
.req p { margin: .2rem 0 0; }
.quote { font-style: italic; color: var(--muted); }
.req-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.req-actions form { display: flex; gap: .4rem; align-items: center; margin: 0; }
.req-actions select { width: auto; min-height: 36px; padding: .3rem .5rem; }

/* admin */
:root { --chart: #0d9488; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart: #2bb3a5; } }
:root[data-theme="dark"] { --chart: #2bb3a5; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 6px 0 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.stats-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 680px) { .stats-4 { grid-template-columns: repeat(4, 1fr); } }
.chart { margin: 8px 0 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .mark { fill: var(--chart); }
.chart .hit { fill: transparent; }
.chart .bar:hover .hit { fill: var(--surface-2); }
.filterbar { margin-bottom: 6px; }
.filterbar select { width: auto; }
.kv-grid { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px 16px; }
.kv-grid dt { margin: 0; }
.row-actions.end { justify-content: flex-end; margin-top: 0; }
.row-actions form { margin: 0; }
.danger-zone { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.pill-err { background: var(--err-soft); color: var(--err); }
.log { max-height: 360px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pill { white-space: nowrap; }
.btn { white-space: nowrap; }
@media (max-width: 559px) {
  .hide-sm { display: none; }
  /* card list: one stacked block per card instead of four narrow columns */
  .tbl-cards thead { display: none; }
  .tbl-cards tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl-cards td { border: 0; padding: 0; }
  .tbl-cards td:nth-child(2) { grid-column: 1; }
  .tbl-cards td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; }
  .tbl-cards td:nth-child(4) { grid-column: 1 / -1; }
  .tbl-cards .row-actions.end { justify-content: flex-start; }
}

.qrbox { margin: 0 0 12px; }
.qrbox summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: .9rem; }
.qrbox img { display: block; margin: 10px 0 0; background: #fff; border-radius: 8px; }

/* print sheet */
.printgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.printcell { margin: 0; padding: 10px; background: #fff; color: #000; border: 1px dashed #bbb; border-radius: 8px; text-align: center; break-inside: avoid; }
.printcell svg { width: 100%; max-width: 140px; height: auto; display: block; margin: 0 auto; }
.printcell figcaption { display: grid; gap: 2px; font-size: .72rem; margin-top: 6px; overflow-wrap: anywhere; }
@media print {
  .top, .foot, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; }
  .printgrid { grid-template-columns: repeat(4, 1fr); gap: 6mm; }
}

/* home */
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); max-width: 18ch; margin: 0 auto .6rem; }
.lead { color: var(--muted); max-width: 52ch; margin: 0 auto; font-size: 1.05rem; }
.hero-mark { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.hero-mark .ic { width: 34px; height: 34px; }
