/* Repliq — styles.
   Palette and gradients are taken from thesandymedia.com:
   brand green #34a853, gradient 135deg green -> blue #4285f4, soft grey/green backgrounds, dark #111 / #1a1a1a. */

:root {
    --green: #34a853;
    --green-dark: #2e7d32;
    --green-soft: #edf6f0;
    --blue: #4285f4;
    --blue-strong: #1967d2;
    --red: #c0392b;
    --red-soft: #fdecea;
    --amber: #b26a00;
    --amber-soft: #fff4e0;

    --ink: #111111;
    --ink-2: #2d2d2d;
    --muted: #5d5d5d;
    --line: #dee2e6;
    --card: #ffffff;

    --gradient: linear-gradient(135deg, #34a853, #4285f4);
    --page: linear-gradient(135deg, #f2f2f2 0%, #f9f9f9 46%, #edf6f0 100%);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.14);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--page);
    background-attachment: fixed;
}

main { flex: 1; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 700; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
a { color: var(--blue-strong); }
a:hover { color: var(--green-dark); }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 460px; }
.page { padding: 32px 0 56px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- Navigation ---------- */
.nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--gradient); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; fill: #fff; }
.nav-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav-links a, .nav-links button.link { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: var(--radius-sm); font-size: .95rem; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav-links a:hover, .nav-links button.link:hover { background: var(--green-soft); color: var(--green-dark); }
.nav-links a.active { color: var(--green-dark); font-weight: 600; }
.nav-links form { margin: 0; }
.nav-links a.btn-primary { background: var(--gradient); color: #fff; padding: 9px 18px; }
.nav-links a.btn-primary:hover { background: var(--gradient); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 12px rgba(52, 168, 83, .28); }
.btn-primary:hover { color: #fff; box-shadow: 0 6px 16px rgba(66, 133, 244, .32); filter: brightness(1.04); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--green); color: var(--green-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: #efc3bd; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-light { background: #fff; color: var(--ink); }
.btn-light:hover { color: var(--green-dark); }
.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
/* Inside a grid the gap handles spacing, so the stacked-card margin must not apply. */
.grid-2 > .card, .grid-3 > .card, .grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; border: 1px solid; font-size: .95rem; }
.alert-success { background: var(--green-soft); border-color: #bfe0c8; color: var(--green-dark); }
.alert-error { background: var(--red-soft); border-color: #efc3bd; color: var(--red); }
.alert-warn { background: var(--amber-soft); border-color: #f1d8a6; color: var(--amber); }
.alert p:last-child { margin-bottom: 0; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-green { background: var(--green-soft); color: var(--green-dark); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-grey { background: #efefef; color: var(--muted); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
label.lbl { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.input, .textarea {
    width: 100%; padding: 11px 14px; border: 1px solid #c9ced3; border-radius: var(--radius-sm);
    font: inherit; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 130px; resize: vertical; }
.input:focus, .textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 168, 83, .18); }
.hint { display: block; margin-top: 6px; color: var(--muted); font-size: .85rem; }
.err { display: block; margin-top: 6px; color: var(--red); font-size: .85rem; }
.is-invalid { border-color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #c9ced3; border-radius: 999px; cursor: pointer; transition: background .2s; }
.slider::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(52, 168, 83, .3); }
.switch input:disabled + .slider { cursor: not-allowed; opacity: .5; }

/* Radio cards */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice label { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: #fff; height: 100%; }
.choice label strong { display: block; }
.choice label span { color: var(--muted); font-size: .85rem; }
.choice input:checked + label { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 2px rgba(52, 168, 83, .2); }
.choice input:focus-visible + label { box-shadow: 0 0 0 3px rgba(52, 168, 83, .3); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .lbl2 { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.stat-hero { background: var(--gradient); color: #fff; border: 0; }
.stat-hero .num { font-size: 3.2rem; }
.stat-hero .lbl2 { color: rgba(255, 255, 255, .88); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: .8rem; }
.pagination { display: flex; gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; }
.pagination li a, .pagination li span { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; background: #fff; font-size: .9rem; }
.pagination li.disabled span { color: #aaa; }

/* ---------- Key/value list ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
code, .code { background: #f0f2f4; padding: 2px 8px; border-radius: 6px; font-family: ui-monospace, Consolas, monospace; font-size: .9em; }

/* ---------- Chat preview ---------- */
.chat { background: #f4f6f8; border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble-out { background: var(--gradient); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-cap { font-size: .75rem; color: var(--muted); }

/* ---------- Landing page ---------- */
.hero { background: #1a1a1a; color: #fff; position: relative; overflow: hidden; }
.hero::before {
    content: ""; position: absolute; width: 620px; height: 620px; right: -160px; top: -220px; border-radius: 50%;
    background: radial-gradient(circle, rgba(52, 168, 83, .55) 0%, rgba(66, 133, 244, .28) 45%, rgba(66, 133, 244, 0) 72%);
}
.hero::after {
    content: ""; position: absolute; width: 420px; height: 420px; left: -140px; bottom: -220px; border-radius: 50%;
    background: radial-gradient(circle, rgba(66, 133, 244, .3) 0%, rgba(66, 133, 244, 0) 70%);
}
.hero .container { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; padding-top: 72px; padding-bottom: 72px; }
.hero h1 { font-size: 2.9rem; letter-spacing: -.02em; }
.hero h1 .accent { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 1.15rem; color: #d0d4d8; max-width: 520px; }
.eyebrow { display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8fd6a3; margin-bottom: 14px; }
.hero .chat { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); box-shadow: var(--shadow-lg); }
.hero .bubble-in { background: #2d2d2d; border-color: #3a3a3a; color: #f1f1f1; }
.hero .chat-cap { color: #9aa0a6; }

.section { padding: 64px 0; }
.section-alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2.big { font-size: 1.9rem; text-align: center; }
.section .sub-head { text-align: center; color: var(--muted); max-width: 560px; margin: 0 auto 36px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.step-no { width: 40px; height: 40px; border-radius: 50%; background: var(--gradient); color: #fff; font-weight: 700; display: grid; place-items: center; margin-bottom: 12px; }
.feature .icon { width: 42px; height: 42px; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; margin-bottom: 12px; font-size: 1.25rem; }
.cta-band { background: var(--gradient); color: #fff; border-radius: var(--radius); padding: 40px 28px; text-align: center; box-shadow: var(--shadow-lg); }
.cta-band h2 { font-size: 1.7rem; }
.cta-band p { color: rgba(255, 255, 255, .9); }

/* ---------- Auth ---------- */
.auth-wrap { display: grid; place-items: center; padding: 48px 20px; }
.auth-card { width: 100%; max-width: 440px; }

/* ---------- Footer ---------- */
.footer { background: #111; color: #b0b0b0; padding: 28px 0; font-size: .9rem; }
.footer a { color: #d6dcdf; text-decoration: none; margin-right: 16px; }
.footer a:hover { color: #fff; text-decoration: underline; }

/* ---------- Prose (legal pages) ---------- */
.prose { max-width: 760px; }
.prose h2 { margin-top: 2rem; font-size: 1.2rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .hero .container { grid-template-columns: minmax(0, 1fr); padding-top: 48px; padding-bottom: 48px; gap: 32px; }
    .hero .container > * { min-width: 0; }
    .hero h1 { font-size: 2.2rem; }
    .grid-3 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat-hero { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    h1 { font-size: 1.6rem; }
    .grid-2, .choices { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 10px; }
    .nav .container { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
    .card { padding: 18px; }
    .section { padding: 44px 0; }
}

/* =====================================================================
   Signed-in app: sidebar layout
   ===================================================================== */
body.app { display: block; }
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px; flex: none; background: #151515; color: #c9d0d5;
    display: flex; flex-direction: column; padding: 18px 14px;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; overflow-y: auto;
}
.sidebar .brand { color: #fff; padding: 6px 10px 20px; }
.sidebar .brand:hover { color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: #b4bcc2; text-decoration: none; font-size: .95rem; font-weight: 500; position: relative;
}
.side-link svg, .icon-btn svg, .btn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-link.active {
    color: #fff; background: linear-gradient(135deg, rgba(52, 168, 83, .30), rgba(66, 133, 244, .22));
}
.side-link.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--green); }
.btn svg { width: 16px; height: 16px; }

.side-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.side-account { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.side-account strong, .side-user strong { display: block; color: #fff; font-size: .9rem; line-height: 1.2; }
.side-account span, .side-user span { display: block; font-size: .76rem; color: #98a1a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-green { background: #3ddc6b; box-shadow: 0 0 0 4px rgba(61, 220, 107, .18); }
.dot-red { background: #ff6b5e; box-shadow: 0 0 0 4px rgba(255, 107, 94, .18); }
.dot-grey { background: #7b848a; }
.side-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.side-user .grow { min-width: 0; }
.side-user form { margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gradient); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 8px; border-radius: 8px; display: inline-grid; place-items: center; }
.sidebar .icon-btn { color: #98a1a8; }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.content { margin-left: 252px; flex: 1; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--page); background-attachment: fixed; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
    padding: 14px 28px; background: rgba(255, 255, 255, .88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.page-title { margin: 0; font-size: 1.35rem; flex: 1; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; color: var(--ink); }
.page-body { padding: 28px; max-width: 1180px; width: 100%; }
.lead-in { max-width: 720px; margin-bottom: 1.25rem; }
.scrim { display: none; }

/* Buttons, forms and layout helpers used inside the app */
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.card-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.card-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; border-color: #bfe0c8; background: linear-gradient(135deg, #f4faf6, #eef4fe); }
.card-cta h2 { margin-bottom: 4px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; margin-bottom: 20px; }
.split-form { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.split > .card, .split > div > .card { margin-bottom: 20px; }
.split > div > .card:last-child { margin-bottom: 0; }
.card + .card { margin-top: 0; }
.page-body > .card + .card { margin-top: 20px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .sub { color: var(--muted); font-size: .8rem; }
.num-sm { min-width: 34px; text-align: right; }
.rule-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 10px; }

/* Bar chart */
.bars { display: flex; align-items: stretch; gap: 10px; height: 170px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.bar { width: 100%; max-width: 46px; background: var(--gradient); border-radius: 8px 8px 3px 3px; opacity: .92; }
.bar-val { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.bar-lbl { font-size: .75rem; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: .9rem; font-weight: 500; }
.tab span { color: var(--muted); font-weight: 400; margin-left: 4px; }
.tab:hover { border-color: var(--green); color: var(--green-dark); }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.active span { color: #b9c0c5; }

/* Posts & Reels grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 18px; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.media-thumb { position: relative; aspect-ratio: 4 / 5; background: linear-gradient(135deg, #e6efe9, #e4ecfb); overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb.small { width: 92px; aspect-ratio: 4 / 5; border-radius: 10px; flex: none; }
.type-pill, .state-pill { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: rgba(17, 17, 17, .72); color: #fff; }
.type-pill { left: 10px; }
.state-pill { right: 10px; }
.state-on { background: rgba(46, 125, 50, .92); }
.state-off { background: rgba(93, 93, 93, .92); }
.media-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.media-caption { margin: 0 0 4px; font-size: .9rem; line-height: 1.4; }
.media-body .sub { color: var(--muted); font-size: .8rem; }
.media-body .sub svg { width: 12px; height: 12px; vertical-align: -1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.media-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.media-actions form { margin: 0; }
.media-preview { display: flex; gap: 14px; align-items: flex-start; }
.mini-thumb { width: 44px; height: 54px; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, #e6efe9, #e4ecfb); flex: none; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Responsive ---- */
@media (max-width: 980px) {
    .split, .split-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; width: 280px; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; }
    .content { margin-left: 0; }
    .menu-btn { display: inline-grid; }
    .topbar { padding: 10px 16px; }
    .page-body { padding: 18px 16px; }
    .top-actions .btn { padding: 8px 12px; }
}
@media (max-width: 560px) {
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .page-title { font-size: 1.15rem; }
    .top-actions .btn { font-size: .82rem; }
}

/* =====================================================================
   v3: search toolbar, toasts, empty states, admin, dark theme
   ===================================================================== */

/* Sidebar section labels, page subtitle, theme button */
.side-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: #6f7880; padding: 16px 12px 6px; }
.page-sub { color: var(--muted); font-size: .85rem; margin-top: -2px; }
.theme-btn { color: var(--ink); border: 1px solid var(--line); background: var(--card); }
.theme-btn:hover { border-color: var(--green); color: var(--green-dark); }
.theme-btn .only-dark { display: none; }

/* Search toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search {
    flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px; background: #fff;
    border: 1px solid #c9ced3; border-radius: var(--radius-sm); padding: 0 12px; transition: border-color .15s, box-shadow .15s;
}
.search svg { width: 18px; height: 18px; flex: none; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); padding: 11px 0; -webkit-appearance: none; appearance: none; }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 168, 83, .18); }
.select {
    padding: 11px 34px 11px 12px; border: 1px solid #c9ced3; border-radius: var(--radius-sm); font: inherit; color: var(--ink);
    -webkit-appearance: none; appearance: none; cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23777' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 168, 83, .18); }
.result-note { color: var(--muted); margin: -4px 0 14px; font-size: .9rem; }

/* Toasts (flash messages) */
.toasts { position: fixed; top: 76px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
    display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card);
    border: 1px solid var(--line); border-left: 4px solid var(--green); box-shadow: var(--shadow-lg); animation: toast-in .25s ease;
    transition: opacity .25s, transform .25s;
}
.toast-error { border-left-color: var(--red); }
.toast span { flex: 1; font-size: .92rem; }
.toast-x { background: none; border: 0; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-x:hover { color: var(--ink); }
.toast.out { opacity: 0; transform: translateX(14px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

/* Empty states */
.empty { text-align: center; padding: 38px 20px; }
.empty h2, .empty h3 { margin-bottom: 6px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Stats extras */
.trend { font-size: .78rem; margin-top: 6px; font-weight: 600; }
.trend-up { color: var(--green-dark); }
.trend-down { color: var(--red); }
.stat-warn .num { color: var(--red); }
.stats-6 { grid-template-columns: repeat(6, 1fr); }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-6 .num, .stats-3 .num { font-size: 1.7rem; }
.stats-6 .stat-hero .num, .stats-3 .stat-hero .num { font-size: 2.2rem; }
.stat, .media-card { transition: transform .15s ease, box-shadow .15s ease; }
.media-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* Admin */
.alert-info { background: #eaf1fe; border-color: #c7d9fb; color: #1a4fa3; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack form { margin: 0; }
.card-danger { border-color: #efc3bd; }
.list-row h3, .card-title h3 { display: flex; align-items: center; gap: 8px; }
.card-title h3 svg { width: 18px; height: 18px; stroke: var(--amber); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 1180px) { .stats-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) { .stats-6, .stats-3 { grid-template-columns: repeat(2, 1fr); } .stats-3 .stat-hero { grid-column: 1 / -1; } }
@media (max-width: 560px) {
    .toolbar .search { min-width: 100%; }
    .toasts { left: 16px; right: 16px; top: 70px; max-width: none; }
}

/* ---------------------------------------------------------------------
   Dark theme (signed-in app). Switched with the moon/sun button; saved in localStorage.
   Most colours already come from variables, so this overrides those plus the few hard-coded whites.
   --------------------------------------------------------------------- */
html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #eef1f3; --ink-2: #d6dbdf; --muted: #9aa3aa; --line: #2b3137; --card: #1a1e22;
    --page: linear-gradient(135deg, #0e1012 0%, #121518 50%, #0e1712 100%);
    --green-soft: #13291b; --green-dark: #6fdc90; --blue-strong: #8ab4ff;
    --red-soft: #2d1715; --red: #ff8a7d; --amber-soft: #2b2211; --amber: #f0b45a;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35); --shadow-lg: 0 10px 28px rgba(0, 0, 0, .5);
}
html[data-theme="dark"] .theme-btn .only-light { display: none; }
html[data-theme="dark"] .theme-btn .only-dark { display: inline; }
html[data-theme="dark"] .sidebar { border-right: 1px solid #22272c; }
html[data-theme="dark"] .topbar { background: rgba(20, 23, 26, .86); }
html[data-theme="dark"] .btn-outline, html[data-theme="dark"] .btn-danger { background: var(--card); }
html[data-theme="dark"] .btn-outline { color: var(--ink); border-color: #343b42; }
html[data-theme="dark"] .btn-danger { border-color: #5a2a26; }
html[data-theme="dark"] .btn-danger:hover { background: var(--red-soft); }
html[data-theme="dark"] .input, html[data-theme="dark"] .textarea, html[data-theme="dark"] .search { background: #12161a; border-color: #343b42; color: var(--ink); }
html[data-theme="dark"] .select { background-color: #12161a; border-color: #343b42; }
html[data-theme="dark"] .stat:not(.stat-hero), html[data-theme="dark"] .media-card, html[data-theme="dark"] .tab,
html[data-theme="dark"] .pagination li a, html[data-theme="dark"] .pagination li span, html[data-theme="dark"] .choice label { background: var(--card); }
html[data-theme="dark"] .tab { border-color: #343b42; }
html[data-theme="dark"] .tab.active { background: #eef1f3; border-color: #eef1f3; color: #111; }
html[data-theme="dark"] .tab.active span { color: #444; }
html[data-theme="dark"] .choice input:checked + label { background: var(--green-soft); }
html[data-theme="dark"] .chat { background: #14181b; }
html[data-theme="dark"] .bubble-in { background: #262c32; border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] code, html[data-theme="dark"] .badge-grey { background: #262c32; }
html[data-theme="dark"] .badge-grey { color: var(--muted); }
html[data-theme="dark"] .slider { background: #3a424a; }
html[data-theme="dark"] .media-thumb, html[data-theme="dark"] .mini-thumb { background: linear-gradient(135deg, #1c2a22, #1b2436); }
html[data-theme="dark"] .card-cta { background: linear-gradient(135deg, #14261b, #14202f); border-color: #234a31; }
html[data-theme="dark"] .alert-success { border-color: #235a34; }
html[data-theme="dark"] .alert-error { border-color: #5a2a26; }
html[data-theme="dark"] .alert-warn { border-color: #5a4720; }
html[data-theme="dark"] .alert-info { background: #14213a; border-color: #27406b; color: #9cc0ff; }
html[data-theme="dark"] .card-danger { border-color: #5a2a26; }
html[data-theme="dark"] .empty-icon { background: var(--green-soft); }
html[data-theme="dark"] .side-label { color: #59626a; }

/* =====================================================================
   v4: light sidebar — green to white gradient (dark mode gets a deep-green one)
   ===================================================================== */
.sidebar {
    background: linear-gradient(180deg, #b9e6c6 0%, #dcf2e3 34%, #f1faf4 66%, #ffffff 100%);
    color: #3d5246; border-right: 1px solid #cfe6d6;
}
.sidebar .brand, .sidebar .brand:hover { color: #103823; }
.brand-sub { display: block; font-size: .68rem; font-weight: 500; letter-spacing: .01em; color: #5f8570; margin-top: 1px; }
.side-link { color: #34503f; }
.side-link:hover { background: rgba(52, 168, 83, .16); color: #0f3320; }
.side-link.active { background: var(--gradient); color: #fff; box-shadow: 0 6px 14px rgba(52, 168, 83, .32); }
.side-link.active::before { display: none; }
.side-label { color: #5f8570; }
.side-account { background: rgba(255, 255, 255, .78); border: 1px solid #cfe6d6; }
.side-account strong, .side-user strong { color: #103823; }
.side-account span, .side-user span { color: #5a7566; }
.sidebar .icon-btn { color: #5a7566; }
.sidebar .icon-btn:hover { background: rgba(52, 168, 83, .16); color: #103823; }
.dot-grey { background: #9aa9a0; }

html[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #14402a 0%, #10261a 38%, #0e1512 70%, #0e1113 100%);
    color: #c9d0d5; border-right: 1px solid #1c2c23;
}
html[data-theme="dark"] .sidebar .brand, html[data-theme="dark"] .sidebar .brand:hover { color: #fff; }
html[data-theme="dark"] .brand-sub { color: #6f857a; }
html[data-theme="dark"] .side-link { color: #b4c2ba; }
html[data-theme="dark"] .side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
html[data-theme="dark"] .side-label { color: #6f857a; }
html[data-theme="dark"] .side-account { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .side-account strong, html[data-theme="dark"] .side-user strong { color: #fff; }
html[data-theme="dark"] .side-account span, html[data-theme="dark"] .side-user span { color: #98a8a0; }
html[data-theme="dark"] .sidebar .icon-btn { color: #98a8a0; }
html[data-theme="dark"] .sidebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
html[data-theme="dark"] .dot-grey { background: #7b848a; }

.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats-4 .num { font-size: 1.7rem; }
@media (max-width: 860px) { .stats-4 { grid-template-columns: repeat(2, 1fr); } }

/* Lead-capture fields inside the automation form */
.lead-fields { border-left: 3px solid var(--green); padding-left: 16px; margin: 0 0 18px 2px; }

/* =====================================================================
   Automation form v2: sectioned layout + step-by-step conversation builder
   ===================================================================== */
.form-section { padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.form-section:first-of-type { padding-top: 0; margin-top: 0; border-top: 0; }
.section-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.section-head .sh-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; flex: none; }
.section-head .sh-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.section-head h3 { margin: 0 0 2px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.section-head p { margin: 0; color: var(--muted); font-size: .85rem; }
.opt-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #eef1f3; border-radius: 999px; padding: 2px 8px; }

/* Reveal/collapse for the fields under a toggle */
.reveal { max-height: 0; overflow: hidden; opacity: 0; transition: max-height .25s ease, opacity .2s ease, margin-top .25s ease; }
.reveal.open { max-height: 900px; opacity: 1; margin-top: 16px; }

/* Step-by-step conversation flow */
.flow { position: relative; padding-left: 40px; }
.flow-step { position: relative; padding-bottom: 22px; }
.flow-step:last-child { padding-bottom: 4px; }
.flow-step::after {
    content: ""; position: absolute; left: -28px; top: 30px; bottom: -6px; width: 2px; background: #c9ced3;
}
.flow-step:last-child::after { display: none; }
.flow-dot {
    position: absolute; left: -40px; top: 0; width: 28px; height: 28px; border-radius: 50%;
    background: var(--gradient); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 4px var(--card);
}
.flow-dot svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.flow-dot.muted { background: #e4e8eb; color: var(--muted); }
.flow-title { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.flow-add {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px 14px;
    border: 1.5px dashed #c9ced3; border-radius: var(--radius-sm); background: none; color: var(--muted);
    font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.flow-add svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.flow-add:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }
.flow-remove {
    display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--red);
    font-size: .78rem; cursor: pointer; padding: 6px 0 0; font: inherit;
}
.flow-remove svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; }
.flow-remove:hover { text-decoration: underline; }

@media (max-width: 560px) {
    .flow { padding-left: 34px; }
    .flow-dot { left: -34px; width: 24px; height: 24px; }
    .flow-step::after { left: -23px; }
}

html[data-theme="dark"] .opt-tag { background: #262c32; color: var(--muted); }
html[data-theme="dark"] .flow-dot { box-shadow: 0 0 0 4px var(--card); }
html[data-theme="dark"] .flow-dot.muted { background: #2b3238; }
html[data-theme="dark"] .flow-add { border-color: #343b42; }
