:root {
  --ink: #111111;
  --muted: #5d625f;
  --paper: #fafaf2;
  --cream: #f2eed6;
  --lime: #bbff39;
  --green: #2dd66f;
  --cyan: #58d7ff;
  --charcoal: #141716;
  --line: rgba(17, 17, 17, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}
h1 { font-size: 1.7rem; margin: 0 0 4px; }
h2 { font-size: 1.2rem; margin: 0 0 14px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--charcoal); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(187,255,57,.25); }
.badge { font-size: .68rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.14); }
.badge.demo { background: #ffb020; color: #2a1a00; }
.badge.live { background: var(--green); color: #042; }
.nav-btn { background: transparent; border: 0; color: #fff; font-weight: 600; cursor: pointer; padding: 8px 12px; border-radius: 10px; }
.nav-btn.active { background: rgba(255,255,255,.12); }

/* Layout */
main { max-width: 960px; margin: 0 auto; padding: 28px; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }
.link-back { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; margin-bottom: 14px; font-size: .95rem; }
.link-back:hover { color: var(--ink); }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; cursor: pointer; font-size: .92rem; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--lime); border-color: var(--lime); }
.btn.primary:hover { filter: brightness(.96); }
.btn.danger { color: #b00020; border-color: rgba(176,0,32,.3); }
.btn.danger:hover { background: #b00020; color: #fff; border-color: #b00020; }
.btn.small { padding: 6px 12px; font-size: .82rem; }

/* Client grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 1.1rem; }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; background: var(--cream); padding: 3px 10px; border-radius: 999px; }
.card .upd { color: var(--muted); font-size: .76rem; margin-top: 10px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* Intake form */
.intake { display: grid; gap: 22px; }
.fieldset { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.fieldset > legend { font-weight: 700; padding: 0 8px; }
.fieldset .module-tag { font-size: .7rem; background: var(--cyan); padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .req { color: #b00020; }
.field input[type="text"], .field input[type="number"], .field input[type="url"], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--paper);
}
.field textarea { min-height: 70px; resize: vertical; }
.field .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.field .opts label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; background: var(--paper); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; margin: 0; }
.field .opts input { accent-color: var(--green); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Panel + daily */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; }
.daily { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.daily label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .85rem; }
.daily label.wide { grid-column: 1 / -1; }
.daily input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: var(--paper); }
.gen-primary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.gen-primary .hint { font-weight: 400; opacity: .7; font-size: .8rem; }
.gen-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.gen-buttons .btn { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.gen-buttons .btn:hover { background: #000; }

/* Result */
.result { background: var(--charcoal); border-radius: var(--radius); padding: 20px; color: #f4f4ef; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.result-head h3 { margin: 0; color: #fff; }
.result .meta { font-size: .74rem; color: #b9c0bb; }
.result-block { margin-bottom: 16px; }
.result-block:last-child { margin-bottom: 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.block-head strong { color: var(--lime); }
.result pre { white-space: pre-wrap; word-wrap: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; background: #0d0f0e; padding: 16px; border-radius: 12px; overflow-x: auto; margin: 0; }

/* Toast + loader */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow); z-index: 50; }
.loader { position: fixed; inset: 0; background: rgba(250,250,242,.8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 40; font-weight: 600; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--cream); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  main { padding: 18px; }
  .daily { grid-template-columns: 1fr; }
  .view-head { flex-direction: column; }
}
