:root {
  --bg: #eef1ee;
  --card: #ffffff;
  --card-2: #f6f8f6;
  --text: #17201d;
  --muted: #5f6b67;
  --line: #e1e6e2;
  --accent: #1f7a5a;
  --accent-soft: #dcefe6;
  --accent-text: #ffffff;
  --amber: #e2a231;
  --danger: #b3261e;
  --ok: #1f7a5a;
  --warn: #9a6700;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(16 24 20 / 0.04), 0 4px 16px rgb(16 24 20 / 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1312;
    --card: #181e1c;
    --card-2: #1f2724;
    --text: #e6ebe9;
    --muted: #9aa6a2;
    --line: #29322f;
    --accent: #3fb68b;
    --accent-soft: #1c3a2f;
    --accent-text: #0b1210;
    --amber: #f2b84b;
    --danger: #f2827a;
    --ok: #3fb68b;
    --warn: #e3b341;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 0.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.error { color: var(--danger); }
.error:empty { display: none; }
.ellipsis { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.brand img { border-radius: 7px; }

/* forms */
label { display: block; margin: 0.75rem 0; font-weight: 500; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { resize: vertical; min-height: 6rem; line-height: 1.45; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  flex: none;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: "";
  width: 0.32rem;
  height: 0.6rem;
  margin-top: -0.12rem;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
button {
  font: inherit;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--card-2); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.75rem 0; }
.row input { margin: 0; flex: 1 1 10rem; }
label .row { margin: 0.3rem 0 0; flex-wrap: nowrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); column-gap: 1rem; }

/* tiles: every card is a bento tile */
.card, .tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  min-width: 0;
}
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
.narrow { max-width: 28rem; margin: 3rem auto; }
#connect .brand { margin-bottom: 1rem; }
.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.bento > * { margin: 0; }
#overview-grid { align-items: stretch; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.tall { grid-row: span 2; }
@media (max-width: 1000px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tall { grid-row: auto; }
}
@media (max-width: 560px) {
  .bento { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
.tile { display: flex; flex-direction: column; gap: 0.35rem; }
.tile p { margin: 0; }
.tile-label {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.tile-link { margin-top: auto; padding-top: 0.5rem; font-weight: 500; text-decoration: none; }
.tile .row { margin: 0.5rem 0 0; }
.tile .row .tile-link { margin: 0 0 0 auto; padding: 0; }
.metric { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.metric .unit { font-size: 0.9rem; font-weight: 500; color: var(--muted); margin-left: 0.35rem; letter-spacing: 0; }
.status-line { display: flex; align-items: center; gap: 0.6rem; font-size: 1.35rem; font-weight: 650; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot[data-state="open"] { background: var(--ok); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot[data-state="reconnecting"], .dot[data-state="pairing"], .dot[data-state="connecting"], .dot[data-state="unpaired"] { background: var(--amber); }
.dot[data-state="logged_out"], .dot[data-state="stopped"], .dot[data-state="error"], .dot[data-state="unreachable"] { background: var(--danger); }

/* activity chart */
.chart { display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px; align-items: end; height: 7.5rem; padding-top: 0.25rem; }
.bar { display: flex; flex-direction: column-reverse; height: 100%; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.bar-in { background: var(--accent); }
.bar-out { background: var(--amber); }
.legend { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.4rem; }
.key { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; }
.key-in { background: var(--accent); }
.key-out { background: var(--amber); margin-left: 0.6rem; }

/* checklist */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.checks li { display: flex; align-items: center; gap: 0.6rem; }

/* message feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; max-height: 22rem; overflow-y: auto; }
.feed li { display: flex; flex-direction: column; padding: 0.5rem 0.7rem; border-radius: 12px; background: var(--card-2); }
.feed li.user { border-left: 3px solid var(--accent); }
.feed li.assistant { border-left: 3px solid var(--amber); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* layout: sidebar on wide screens, scrolling top nav on phones */
.shell { display: grid; grid-template-columns: 14rem 1fr; min-height: 100vh; }
.shell > * { min-width: 0; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; padding: 1.1rem 0.85rem; }
.side .brand { padding: 0 0.6rem 1.25rem; }
#nav { display: flex; flex-direction: column; gap: 0.2rem; }
#nav a { padding: 0.5rem 0.7rem; border-radius: 10px; color: var(--text); text-decoration: none; }
#nav a:hover { background: var(--card); }
#nav a.active { background: var(--card); box-shadow: var(--shadow); font-weight: 600; color: var(--accent); }
.nav-group { margin: 1.1rem 0.7rem 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
main { width: 100%; max-width: 72rem; padding: 1.6rem clamp(1rem, 3vw, 2.5rem) 3rem; }
main > section > .card { max-width: 46rem; }
#files > .card { max-width: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 0.7rem 1rem 0.4rem; }
  .side .brand { padding: 0 0 0.5rem; }
  #nav { flex-direction: row; overflow-x: auto; padding-bottom: 0.3rem; }
  #nav a { white-space: nowrap; }
  .nav-group { display: none; }
}

/* whatsapp / access */
.badge { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); font-size: 0.85rem; font-weight: 500; }
.badge[data-state="open"] { color: var(--ok); border-color: var(--ok); }
.badge[data-state="logged_out"], .badge[data-state="stopped"], .badge[data-state="error"] { color: var(--danger); border-color: var(--danger); }
.badge[data-state="reconnecting"], .badge[data-state="pairing"], .badge[data-state="unpaired"] { color: var(--warn); border-color: var(--warn); }
.code {
  font: 600 2rem/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.list { list-style: none; padding: 0; margin: 0.75rem 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.preview {
  white-space: pre-wrap;
  font: 0.85rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  max-height: 22rem;
  overflow: auto;
}

/* chats */
.chat-layout { display: grid; grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-list { list-style: none; margin: 0; padding: 0.5rem; max-height: 72vh; overflow-y: auto; }
.chat-list button { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; width: 100%; text-align: left; border-color: transparent; background: transparent; }
.chat-list button.active { background: var(--card-2); border-color: var(--line); }
.chat-pane h2 { margin-top: 0; }
.bubbles { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; max-height: 65vh; overflow-y: auto; }
.bubble { max-width: 80%; padding: 0.5rem 0.75rem; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); display: flex; flex-direction: column; }
.bubble.user { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.bubble-time { font-size: 0.72rem; opacity: 0.75; align-self: flex-end; }

/* files */
.files { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.file { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 0.7rem 0.9rem; border-radius: 12px; background: var(--card-2); }
.file-main { display: flex; flex-direction: column; flex: 1 1 16rem; min-width: 0; }
.file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.snippet { font-style: italic; }
.check-label { display: flex; align-items: center; gap: 0.6rem; }
code { font: 0.9em ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--card-2); padding: 0.05em 0.35em; border-radius: 5px; }

/* schedule / finance */
.toolbar input { flex: 0 1 12rem; }
.bento.below { margin-top: 1rem; }
.status-pill { font-size: 0.75rem; padding: 0.05rem 0.5rem; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.hbar-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.9rem; }
.hbar { height: 0.55rem; border-radius: 999px; background: var(--card-2); overflow: hidden; margin-top: 0.2rem; }
.hbar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.hbar-fill.over { background: var(--danger); }
.chart.days { grid-template-columns: repeat(var(--cols, 31), 1fr); }
.amount-in { color: var(--ok); }
.amount-out { color: var(--text); }
.metric[data-state="neg"] { color: var(--danger); }
.demo-banner { margin: 0 0 1rem; padding: 0.6rem 0.9rem; border-radius: 12px; border: 1px dashed var(--accent); background: var(--accent-soft); font-weight: 500; }
