:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #18201d;
  --muted: #66706b;
  --line: #e4e1d8;
  --brand: #0f6b5c;
  --brand-2: #0b5448;
  --brand-ink: #ffffff;
  --brand-soft: #e2f0eb;
  --accent: #c2410c;
  --accent-soft: #fbe8dd;
  --warn: #a16207;
  --warn-soft: #fbf1d6;
  --ok: #15803d;
  --ok-soft: #dcf2e3;
  --fb: #1877f2;
  --ig: #c13584;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 14px rgba(20, 30, 25, .06);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1312; --surface: #171d1b; --surface-2: #1c2321; --ink: #e9eeec; --muted: #98a39e; --line: #29322f;
    --brand: #3db394; --brand-2: #57c7a9; --brand-ink: #06231c; --brand-soft: #15302a;
    --accent: #f0895c; --accent-soft: #3a2218; --warn: #e8b64a; --warn-soft: #362c14; --ok: #5bd18a; --ok-soft: #15301f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1312; --surface: #171d1b; --surface-2: #1c2321; --ink: #e9eeec; --muted: #98a39e; --line: #29322f;
  --brand: #3db394; --brand-2: #57c7a9; --brand-ink: #06231c; --brand-soft: #15302a;
  --accent: #f0895c; --accent-soft: #3a2218; --warn: #e8b64a; --warn-soft: #362c14; --ok: #5bd18a; --ok-soft: #15301f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; flex: none; }
.brand h1 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:active { background: var(--line); }
.dot { position: absolute; top: 9px; left: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); border: 2px solid var(--bg); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--accent); }
.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px 0; outline: none; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--brand); font-weight: 700; }
.tabbar a.active svg { stroke-width: 2.2; }
.badge {
  position: absolute; top: 7px; inset-inline-start: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed; z-index: 25;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  inset-inline-start: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 20px 0 18px; border: 0; border-radius: 26px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 40%, transparent);
  cursor: pointer;
}
.fab:active { transform: scale(.97); }

/* ---------- Sections & cards ---------- */
.hello { margin: 4px 2px 16px; }
.hello h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.hello p { margin: 2px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.hot b { color: var(--accent); }

.section { margin: 20px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section h3 { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.section a, .linkbtn { font-size: 14px; font-weight: 600; color: var(--brand); text-decoration: none; background: none; border: 0; cursor: pointer; padding: 4px 2px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card.muted { opacity: .62; }
.card-top { display: flex; align-items: flex-start; gap: 12px; }
.when {
  flex: none; width: 62px; text-align: center; padding: 6px 0; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-2);
}
.when b { display: block; font-size: 19px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.when small { display: block; font-size: 11.5px; font-weight: 600; }
.when.none { background: var(--surface-2); color: var(--muted); }
.when.late { background: var(--accent-soft); color: var(--accent); }
.card-main { min-width: 0; flex: 1; }
.card-title { font-size: 16.5px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.card-sub { margin-top: 2px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.facts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.facts li { display: flex; gap: 7px; align-items: flex-start; font-size: 14px; overflow-wrap: anywhere; }
.facts svg { flex: none; width: 16px; height: 16px; margin-top: 3px; fill: none; stroke: var(--muted); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.facts .k { color: var(--muted); }
.quote {
  margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
  border-inline-start: 3px solid var(--line); font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere;
}
.quote.ctx div + div { margin-top: 3px; }
.note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; background: var(--warn-soft); color: var(--warn); display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.ai { background: var(--brand-soft); color: var(--brand-2); border-color: transparent; }
.chip.fb { background: color-mix(in srgb, var(--fb) 14%, transparent); color: var(--fb); border-color: transparent; }
.chip.ig { background: color-mix(in srgb, var(--ig) 14%, transparent); color: var(--ig); border-color: transparent; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.btn.danger { color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.block { width: 100%; min-height: 48px; font-size: 15.5px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button .n { font-size: 12px; color: var(--muted); margin-inline-start: 3px; }

.day-h { margin: 18px 2px 8px; font-size: 14px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.day-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-h.today { color: var(--brand); }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.empty p { margin: 0 0 14px; }

.howto { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.howto h3 { font-size: 17px; margin-bottom: 4px; }
.howto ol { margin: 10px 0 4px; padding-inline-start: 22px; }
.howto li { margin-bottom: 6px; }
.howto .os { display: flex; gap: 6px; margin: 12px 0 2px; }
.kbd { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 46px; height: 28px; accent-color: var(--brand); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel h3 { font-size: 16.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.panel > p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.panel .status { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0 12px; }
.panel .status i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.panel .status.on i { background: var(--ok); }
.panel .status.off i { background: var(--accent); }
.copy { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.copy code { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; direction: ltr; text-align: left; overflow-x: auto; white-space: nowrap; }
.small { font-size: 13px; color: var(--muted); }
.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }

/* ---------- Connections ---------- */
.conn h3 { font-size: 17.5px; }
.conn-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; font-weight: 800; font-size: 17px; flex: none; }
.conn-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.conn-ic.wa { background: #1fa855; }
.conn-ic.fb { background: linear-gradient(135deg, #1877f2, #c13584); font-family: Arial, sans-serif; }
.steps { list-style: none; counter-reset: st; margin: 6px 0 12px; padding: 0; display: grid; gap: 12px; }
.steps > li { counter-increment: st; position: relative; padding-inline-start: 38px; font-size: 14.5px; }
.steps > li::before {
  content: counter(st); position: absolute; inset-inline-start: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-2); font-weight: 800; font-size: 14px;
}
.fb-btn { background: #1877f2; border-color: #1877f2; color: #fff; min-height: 50px; font-size: 16px; }
.status span b { font-weight: 700; }

/* ---------- Social ---------- */
.lead-head { display: flex; align-items: center; gap: 10px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--brand); }
.avatar.fb { background: var(--fb); }
.avatar.ig { background: linear-gradient(135deg, #f58529, #dd2a7b 55%, #8134af); }
.lead-text { margin: 10px 0 0; font-size: 15.5px; overflow-wrap: anywhere; }
.reply-box { margin-top: 10px; display: grid; gap: 8px; }
.post { display: flex; gap: 12px; align-items: flex-start; }
.post img { flex: none; width: 74px; height: 74px; object-fit: cover; border-radius: 12px; background: var(--surface-2); }
.post .ph { flex: none; width: 74px; height: 74px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.post-text { font-size: 14.5px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .who { font-weight: 700; font-size: 14px; }
.comment.lead { background: var(--accent-soft); margin: 0 -10px; padding: 10px; border-radius: 10px; border-bottom: 0; margin-bottom: 4px; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 13, .45); animation: fade .18s ease; }
.sheet {
  position: fixed; z-index: 41; inset-inline: 0; bottom: 0; max-height: 92vh; overflow: auto;
  max-width: 720px; margin: 0 auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 6px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: up .22s cubic-bezier(.2,.9,.3,1);
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: -6px; background: var(--surface); padding: 6px 0; z-index: 1; }
.sheet-head h2 { font-size: 19px; font-weight: 800; }
.sheet-body { padding-top: 6px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 80px);
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow);
  animation: up .2s ease;
}

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-2); font-size: 14px; }
.banner b { display: block; font-size: 15px; }
.banner .btn { margin-inline-start: auto; flex: none; }

.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 16px 0; }
.progress::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }

@media (min-width: 760px) {
  .stats { gap: 14px; }
  .fab { inset-inline-start: calc(50% - 360px + 16px); }
}
@media (max-width: 360px) {
  .when { width: 54px; }
  .stat b { font-size: 22px; }
}
