/* ==========================================================================
   AI SaaS Platform - Application styles
   ========================================================================== */

:root {
    --brand: #111111;
    --brand-2: #3f3f46;
    --brand-3: #000000;
    --radius: 14px;
    --radius-sm: 9px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #525252;

    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #efefef;
    --border: #e1e1e3;
    --text: #0a0a0a;
    --muted: #6b6b70;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    --glow: rgba(0, 0, 0, 0.045);
    --cta-bg: #0a0a0a;
    --cta-text: #ffffff;
    --cta-muted: rgba(255, 255, 255, 0.72);
}

[data-theme="dark"] {
    --brand: #ffffff;
    --brand-2: #d4d4d8;
    --brand-3: #a1a1aa;
    --bg: #0a0a0a;
    --surface: #131315;
    --surface-2: #1c1c1f;
    --border: #29292d;
    --text: #f4f4f5;
    --muted: #a1a1a6;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
    --glow: rgba(255, 255, 255, 0.05);
    --cta-bg: #f4f4f5;
    --cta-text: #0a0a0a;
    --cta-muted: rgba(10, 10, 10, 0.68);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
pre { font-family: var(--mono); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 780px; }
.container-fluid { width: 100%; padding: 18px 22px 60px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: .85em; }
.gradient-text { background: linear-gradient(120deg, var(--text), var(--muted)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Hero accent word - premium red shimmer + underline sweep */
.accent-word {
    position: relative;
    display: inline-block;
    color: #dc2626;
    background-image: linear-gradient(100deg, #b91c1c 0%, #dc2626 22%, #ff5252 50%, #dc2626 78%, #b91c1c 100%);
    background-size: 220% 100%;
    background-position: 0% 50%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 14px rgba(220, 38, 38, .30));
    animation: accent-shimmer 6s ease-in-out infinite;
}
.accent-word::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -.08em;
    height: .085em;
    min-height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(220,38,38,0), #ef4444 18%, #ff5252 50%, #ef4444 82%, rgba(220,38,38,0));
    box-shadow: 0 0 12px rgba(220, 38, 38, .45);
    transform: scaleX(0);
    transform-origin: left center;
    animation: accent-underline 1.05s cubic-bezier(.16, 1, .3, 1) .45s forwards;
}
@keyframes accent-shimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}
@keyframes accent-underline {
    to { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
    .accent-word {
        animation: none;
        background-position: 50% 50%;
        filter: none;
    }
    .accent-word::after { animation: none; transform: scaleX(1); }
}
.grid { display: grid; gap: 20px; }
.two-col { grid-template-columns: 1fr 1fr; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: 10px 18px; border-radius: var(--radius-sm);
    border: 1px solid transparent; transition: .16s ease; text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--brand-3), var(--brand-2)); color: #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); }
.btn-primary:hover { filter: brightness(1.07); color: #fff; }
[data-theme="dark"] .btn-primary { color: #0a0a0a; }
[data-theme="dark"] .btn-primary:hover { color: #0a0a0a; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: none; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.as-button { display: flex; width: 100%; text-align: left; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin: 14px 0; font-size: .93rem; border: 1px solid transparent; }
.alert-success { background: rgba(22, 163, 74, .1); color: #15803d; border-color: rgba(22, 163, 74, .25); }
.alert-error { background: rgba(220, 38, 38, .1); color: #b91c1c; border-color: rgba(220, 38, 38, .25); }
.alert-warning { background: rgba(217, 119, 6, .1); color: #b45309; border-color: rgba(217, 119, 6, .25); }
.alert-info { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
[data-theme="dark"] .alert-success { color: #4ade80; }
[data-theme="dark"] .alert-error { color: #f87171; }
[data-theme="dark"] .alert-warning { color: #fbbf24; }
[data-theme="dark"] .alert-info { color: #d4d4d8; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-active, .badge-successful { background: rgba(22,163,74,.14); color: #16a34a; }
.badge-pending { background: rgba(217,119,6,.14); color: #d97706; }
.badge-failed, .badge-disabled, .badge-cancelled, .badge-expired { background: rgba(220,38,38,.14); color: #dc2626; }
.badge-past_due { background: rgba(217,119,6,.16); color: #d97706; }
.badge-refunded { background: rgba(107,114,128,.16); color: #6b7280; }
.status-active, .status-successful { color: var(--success); font-weight: 600; }
.status-disabled, .status-expired, .status-cancelled { color: var(--danger); font-weight: 600; }
.status-past_due, .status-pending { color: var(--warning); font-weight: 600; }
.status-free { color: var(--muted); font-weight: 600; }

/* ---- Brand ---- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; overflow: hidden; background: transparent; color: #fff; font-size: .85rem; font-weight: 800; }
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 1.05rem; }

/* Keep readable text on light-gradient marks in the dark theme */
[data-theme="dark"] .step-num,
[data-theme="dark"] .ribbon,
[data-theme="dark"] .avatar,
[data-theme="dark"] .pagination a.active,
[data-theme="dark"] .message-assistant .message-avatar { color: #0a0a0a; }

/* ==========================================================================
   Marketing
   ========================================================================== */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 18px; }
.main-nav { display: flex; gap: 24px; }
.main-nav a { color: var(--muted); font-weight: 500; }
.main-nav a:hover { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 9px; width: 40px; height: 40px; font-size: 1.15rem; cursor: pointer; }

.hero { padding: 80px 0 60px; background: radial-gradient(1000px 500px at 80% -10%, var(--glow), transparent 60%); }
.hero-inner { display: grid; grid-template-columns: 1.05fr .95fr; gap: 50px; align-items: center; }
.hero h1 { font-size: 3rem; letter-spacing: -.02em; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 540px; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--brand); font-size: .82rem; font-weight: 600; margin-bottom: 18px; }
.hero-actions { display: flex; gap: 12px; margin: 26px 0 22px; flex-wrap: wrap; }
.hero-points { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: .92rem; }

.chat-mock { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 16px; }
.mock-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.mock-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mock-msg { padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; font-size: .9rem; }
.mock-msg.user { background: var(--surface-2); }
.mock-msg.ai { background: linear-gradient(135deg, var(--glow), transparent); border: 1px solid var(--border); }
.mock-code { background: #0d1117; color: #c9d1d9; padding: 10px 12px; border-radius: 8px; margin: 10px 0 0; font-size: .78rem; overflow: auto; }
.mock-input { margin-top: 10px; padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--border); color: var(--muted); font-size: .88rem; }

.logos-strip { padding: 14px 0 0; }
.logos-strip p { text-align: center; color: var(--muted); font-size: .87rem; text-transform: uppercase; letter-spacing: .12em; }

.section { padding: 70px 0; }
.section-alt { background: var(--surface); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 42px; }
.section-head p { color: var(--muted); }
.page-head { padding: 50px 0 10px; }

.features-grid { grid-template-columns: repeat(4, 1fr); }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; transition: .18s; }
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.feature-icon { font-size: 1.6rem; margin-bottom: 10px; }
.feature-card h3 { margin-bottom: 6px; font-size: 1.03rem; }
.feature-card p { color: var(--muted); font-size: .9rem; margin: 0; }

.steps-grid { grid-template-columns: repeat(3, 1fr); }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }
.step-num { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-3), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 800; margin-bottom: 14px; }

/* ---- Photo cards ---- */
.media-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.media-card { position: relative; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); transition: .18s; }
.media-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.media-card img { display: block; width: 100%; height: 210px; object-fit: cover; filter: grayscale(1) contrast(1.04); transition: transform .45s ease; }
.media-card:hover img { transform: scale(1.035); }
.media-card-body { padding: 20px; }
.media-tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.media-card-body h3 { margin-bottom: 6px; font-size: 1.05rem; }
.media-card-body p { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---- Full-bleed photo band ---- */
.photo-band { position: relative; min-height: 360px; display: grid; place-items: center; text-align: center; color: #fff; background-color: #0a0a0a; background-size: cover; background-position: center; }
.photo-band::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(9,9,11,.74), rgba(9,9,11,.88)); }
.photo-band-inner { position: relative; z-index: 1; max-width: 720px; padding: 64px 20px; }
.photo-band h2 { color: #fff; margin-bottom: 8px; }
.photo-band p { color: rgba(255,255,255,.78); margin: 0; }

/* ---- Pricing section with photo background ---- */
.pricing-photo { position: relative; background-color: #0a0a0a; background-size: cover; background-position: center; }
.pricing-photo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(9,9,11,.78), rgba(9,9,11,.9)); }
.pricing-photo > .container { position: relative; z-index: 1; }
.pricing-photo .section-head h2 { color: #fff; }
.pricing-photo .section-head p { color: rgba(255,255,255,.75); }
.pricing-photo .center { color: rgba(255,255,255,.82); }
.pricing-photo .center a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.pricing-grid { grid-template-columns: repeat(4, 1fr); align-items: stretch; }
.price-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 22px; display: flex; flex-direction: column; }
.price-card.featured { border-color: var(--brand); box-shadow: 0 12px 40px rgba(0, 0, 0, .20); transform: translateY(-6px); }
.price-card.current { border-color: var(--success); }
.ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--brand-3), var(--brand-2)); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ribbon-muted { background: var(--success); }
.price { font-size: 2.1rem; font-weight: 800; }
.price span { font-size: .95rem; font-weight: 500; color: var(--muted); }
.price-desc { color: var(--muted); font-size: .88rem; min-height: 40px; }
.credits-badge { display: inline-block; background: var(--surface-2); border-radius: 8px; padding: 5px 10px; font-size: .82rem; font-weight: 600; margin-bottom: 14px; }
.price-list { list-style: none; padding: 0; margin: 0 0 20px; font-size: .88rem; color: var(--muted); }
.price-list li { margin-bottom: 7px; }
.price-card .btn { margin-top: auto; }

.pricing-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 40px; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; font-size: .88rem; color: var(--muted); }

.faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq[open] summary { color: var(--brand); }
.faq p { color: var(--muted); margin: 0 0 14px; }

.cta-band { background: var(--cta-bg); color: var(--cta-text); padding: 56px 0; }
.cta-band h2 { color: var(--cta-text); margin-bottom: 6px; }
.cta-band p { color: var(--cta-muted); margin: 0; }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap; }
.cta-band .btn-primary { background: var(--cta-text); color: var(--cta-bg); box-shadow: none; }
.cta-band .btn-primary:hover { filter: none; opacity: .9; color: var(--cta-bg); }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 50px 0 20px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.footer-grid a { display: block; color: var(--muted); padding: 4px 0; font-size: .9rem; }
.footer-grid a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 30px; padding-top: 18px; color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.footer-credit { display: inline-flex; align-items: center; gap: 8px; }
.whatsapp-link { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--text); color: var(--surface); flex-shrink: 0; }
.whatsapp-link:hover { color: var(--surface); opacity: .82; }
.whatsapp-link svg { width: 15px; height: 15px; display: block; }

.prose h2 { margin-top: 1.6em; }

/* ==========================================================================
   Auth
   ========================================================================== */
.auth-page { background: var(--bg); }
.auth-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-brand { background: #0a0a0a; background-size: cover; background-position: center; color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand .brand { color: #fff; }
.auth-brand .brand-mark { background: transparent; }
.auth-brand-copy h2 { font-size: 2.4rem; line-height: 1.2; }
.auth-brand-copy p { color: rgba(255,255,255,.82); font-size: 1.05rem; }
.auth-form-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-size: 1.7rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 24px; }
.auth-alt { text-align: center; color: var(--muted); margin-top: 20px; font-size: .92rem; }
.muted-small { font-size: .82rem; opacity: .85; }
.auth-footer-links { display: flex; gap: 16px; justify-content: center; margin-top: 26px; font-size: .85rem; color: var(--muted); }
.auth-footer-inline { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; color: var(--muted); }
.verify-illustration { font-size: 3.4rem; text-align: center; margin: 10px 0 18px; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .86rem; font-weight: 600; }
.field input, .field select, .field textarea, .filter-bar input, .filter-bar select, .form-inline input, .form-inline select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font: inherit; font-size: .95rem;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filter-bar input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
.field-error { color: var(--danger); font-size: .82rem; font-style: normal; }
.field-hint { color: var(--muted); font-size: .8rem; font-style: normal; }
.field-hint.warn { color: var(--warning); }
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 60px; }
.password-toggle {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    background: none; border: none; color: var(--brand); font: inherit;
    font-size: .78rem; font-weight: 700; cursor: pointer; padding: 5px 8px;
    border-radius: 6px; line-height: 1;
}
.password-toggle:hover { background: var(--surface-2); }
.form-row-between { display: flex; align-items: center; justify-content: space-between; font-size: .88rem; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; }
.form-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form { display: inline; }
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; max-width: 620px; }
.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 150px; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 250px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; }
.sidebar-head { padding: 18px 18px 12px; }
.sidebar-nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; margin-bottom: 3px; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); font-weight: 600; }
.side-icon { width: 20px; text-align: center; }
.side-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 16px 12px 6px; }
.sidebar-credits { padding: 14px; border-top: 1px solid var(--border); }
.credits-pill { display: flex; align-items: baseline; gap: 7px; }
.credits-count { font-size: 1.6rem; font-weight: 800; color: var(--brand); }
.credits-label { color: var(--muted); font-size: .8rem; }
.plan-tag { font-size: .78rem; color: var(--muted); margin: 4px 0 10px; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.verify-banner { background: rgba(217,119,6,.14); color: #b45309; padding: 7px 10px; border-radius: 8px; font-size: .8rem; text-align: center; font-weight: 600; }
.app-main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.app-topbar { height: 62px; display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
.topbar-title { font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.credit-chip { background: var(--surface-2); border-radius: 999px; padding: 5px 14px; font-size: .87rem; font-weight: 700; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-3), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 700; }
.app-content { flex: 1; }
.sidebar-backdrop, .chat-backdrop { display: none; }

/* ---- Dashboard ---- */
.dashboard-head, .page-head-inline { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 22px; flex-wrap: wrap; }
.dashboard-head h1, .page-head-inline h1 { margin-bottom: 2px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 5px; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-meta { color: var(--muted); font-size: .8rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 1.12rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-title { display: block; font-weight: 600; }
.list-meta { color: var(--muted); font-size: .82rem; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.info-grid > div { display: flex; flex-direction: column; }
.info-label { color: var(--muted); font-size: .78rem; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-3), var(--brand-2)); }
.big-stat { display: flex; align-items: baseline; gap: 8px; }
.big-num { font-size: 2.4rem; font-weight: 800; color: var(--brand); }
.big-label { color: var(--muted); font-size: .85rem; }
.danger-panel { border-color: rgba(220,38,38,.4); }
.plan-mini-grid { grid-template-columns: repeat(4, 1fr); }
.plan-mini { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.plan-mini.current { border-color: var(--brand); }
.plan-mini-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.plan-mini-credits { color: var(--muted); font-size: .82rem; margin-bottom: 10px; }
.gateway-options { display: flex; gap: 8px; margin-bottom: 10px; }
.gateway-option { flex: 1; text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 8px; cursor: pointer; font-size: .85rem; }
.gateway-option input { display: none; }
.gateway-option:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: 600; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a { padding: 6px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; color: var(--muted); }
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 26px; background: linear-gradient(180deg, var(--brand-2), var(--brand-3)); border-radius: 5px 5px 0 0; min-height: 3px; }
.bar-label { font-size: .6rem; color: var(--muted); margin-top: 6px; transform: rotate(-45deg); white-space: nowrap; }
.log-view { background: #0d1117; color: #c9d1d9; padding: 16px; border-radius: var(--radius-sm); font-size: .78rem; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 22px; flex-wrap: wrap; }
.tab { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--brand); border-color: var(--brand); }

/* ==========================================================================
   Chat
   ========================================================================== */
.page-chat .app-content { display: flex; min-height: 0; }
.chat-layout { display: flex; width: 100%; height: calc(100vh - 62px); }
.chat-sidebar { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.conv-search input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; }
.conv-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.conv-item { position: relative; border-radius: 9px; margin-bottom: 3px; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.conv-link { display: block; padding: 10px 12px; color: var(--text); }
.conv-title { display: block; font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { font-size: .72rem; color: var(--muted); }
.conv-actions { position: absolute; top: 8px; right: 8px; display: none; gap: 2px; }
.conv-item:hover .conv-actions { display: flex; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .75rem; padding: 2px 6px; color: var(--muted); }
.icon-btn:hover { color: var(--brand); }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.model-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; max-width: 320px; }
.chat-header-actions { margin-left: auto; }
.messages { flex: 1; overflow-y: auto; padding: 26px 18px; scroll-behavior: smooth; }
.empty-chat { max-width: 680px; margin: 40px auto; text-align: center; }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.suggestion { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; font: inherit; font-size: .88rem; color: var(--text); }
.suggestion:hover { border-color: var(--brand); color: var(--brand); }
.message { display: flex; gap: 14px; max-width: 860px; margin: 0 auto 22px; }
.message-avatar { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; font-size: .75rem; font-weight: 800; }
.message-user .message-avatar { background: var(--surface-2); color: var(--muted); }
.message-assistant .message-avatar { background: linear-gradient(135deg, var(--brand-3), var(--brand-2)); color: #fff; }
.message-body { min-width: 0; flex: 1; }
.message-content { font-size: .96rem; line-height: 1.72; overflow-wrap: anywhere; }
.message-user .message-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.message-content p { margin: 0 0 .8em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre { background: #0d1117; color: #e6edf3; padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 12px 0; font-size: .84rem; line-height: 1.55; }
.message-content pre code { background: none; padding: 0; font-size: inherit; }
.message-content ul, .message-content ol { padding-left: 22px; margin: 0 0 .8em; }
.message-content blockquote { border-left: 3px solid var(--brand); margin: 12px 0; padding: 4px 14px; color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.message-content table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .86rem; }
.message-content th, .message-content td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.message-content h1, .message-content h2, .message-content h3 { margin: 1em 0 .4em; }
.message-tools { display: flex; gap: 8px; margin-top: 8px; }
.tool-btn { background: none; border: 1px solid var(--border); border-radius: 7px; padding: 4px 10px; font-size: .76rem; color: var(--muted); cursor: pointer; }
.tool-btn:hover { color: var(--brand); border-color: var(--brand); }
.cursor-blink::after { content: "▋"; animation: blink 1s steps(1) infinite; color: var(--brand); }
@keyframes blink { 50% { opacity: 0; } }
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 14px 18px 12px; }
.composer-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 8px 8px 8px 16px; }
.composer-inner:focus-within { border-color: var(--brand); }
#messageInput, #adminMessageInput { flex: 1; border: none; background: none; resize: none; font: inherit; font-size: .96rem; color: var(--text); max-height: 180px; padding: 8px 0; outline: none; }
.composer-actions { display: flex; gap: 6px; align-items: center; }
.btn-send { width: 40px; height: 40px; padding: 0; border-radius: 10px; font-size: 1.05rem; }
.composer-hint { max-width: 860px; margin: 8px auto 0; text-align: center; color: var(--muted); font-size: .74rem; }

/* ---- Attached photos ---- */
.message-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.message-image { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); line-height: 0; }
.message-image img { display: block; max-width: 260px; max-height: 260px; width: auto; height: auto; }
.composer-attachments { max-width: 860px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.attach-item { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.attach-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.attach-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: none; border-radius: 50%; background: rgba(0, 0, 0, .62); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.attach-remove:hover { background: rgba(0, 0, 0, .85); }
.attach-btn { padding: 6px 9px; font-size: 1.05rem; line-height: 1; flex-shrink: 0; }
.code-lang { position: relative; }
.copy-code { position: absolute; top: 8px; right: 8px; font-size: .7rem; }

/* ---- Code blocks & syntax tokens ---- */
.code-block { position: relative; margin: 12px 0; border-radius: 10px; overflow: hidden; background: #0d1117; border: 1px solid #1f2937; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: #161b22; border-bottom: 1px solid #1f2937; }
.code-label { font-size: .72rem; color: #8b949e; text-transform: lowercase; font-family: var(--mono); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block pre code { background: none; padding: 0; color: #e6edf3; font-family: var(--mono); font-size: .84rem; line-height: 1.6; }
.code-block .copy-code { position: static; background: #21262d; border: 1px solid #30363d; color: #c9d1d9; border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: .7rem; }
.code-block .copy-code:hover { background: #30363d; }
.code-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tok-keyword { color: #ff7b72; }
.tok-string { color: #a5d6ff; }
.tok-comment { color: #8b949e; font-style: italic; }
.tok-number { color: #79c0ff; }
.message-content code { background: #0d1117; color: #e6edf3; padding: 1px 6px; border-radius: 5px; font-size: .85em; }

/* ==========================================================================
   Error page
   ========================================================================== */
.error-page { display: grid; place-items: center; min-height: 100vh; }
.error-card { text-align: center; max-width: 460px; padding: 40px; }
.error-code { font-size: 5rem; font-weight: 900; background: linear-gradient(135deg, var(--text), var(--muted)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.error-trace { text-align: left; background: var(--surface-2); padding: 10px; border-radius: 8px; font-size: .8rem; }

/* ==========================================================================
   Installer
   ========================================================================== */
.installer-body { background: radial-gradient(900px 500px at 50% -10%, var(--glow), transparent 60%), var(--bg); padding: 40px 16px; }
.installer-wrap { max-width: 720px; margin: 0 auto; }
.installer-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 34px; box-shadow: var(--shadow); }
.installer-head { text-align: center; margin-bottom: 22px; }
.installer-head .brand { justify-content: center; margin-bottom: 14px; }
.installer-head h1 { font-size: 1.7rem; }
.installer-head p { color: var(--muted); }
.installer-section { margin-bottom: 24px; }
.installer-section h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.installer-body label { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; margin-bottom: 12px; }
.installer-body input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.check-icon { font-weight: 900; }
.checklist .ok .check-icon { color: var(--success); }
.checklist .fail .check-icon { color: var(--danger); }
.check-note { margin-left: auto; color: var(--muted); font-size: .78rem; }
.hint { color: var(--muted); font-size: .8rem; }
.installer-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 18px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .features-grid { grid-template-columns: repeat(2, 1fr); }
    .pricing-grid { grid-template-columns: repeat(2, 1fr); }
    .plan-mini-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-inner { grid-template-columns: 1fr; }
    .hero-visual { order: -1; }
    .hero h1 { font-size: 2.4rem; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .main-nav { display: none; position: absolute; top: 66px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: 14px 20px; gap: 12px; }
    .main-nav.open { display: flex; }
    .nav-toggle { display: inline-block; }
    .two-col, .info-grid, .pricing-notes, .steps-grid { grid-template-columns: 1fr; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .app-sidebar { transform: translateX(-100%); transition: transform .22s; }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-backdrop.open, .chat-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
    .chat-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 45; transform: translateX(-100%); transition: transform .22s; }
    .chat-sidebar.open { transform: translateX(0); }
    .chat-backdrop { z-index: 44; }
    .grid-2 { grid-template-columns: 1fr; }
    .dashboard-head { align-items: flex-start; }
}
@media (max-width: 560px) {
    .features-grid, .pricing-grid, .plan-mini-grid, .stat-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2rem; }
    .suggestions { grid-template-columns: 1fr; }
    .header-actions .btn { display: none; }
    .header-actions .btn-primary { display: inline-flex; }
    .container-fluid { padding: 14px 14px 50px; }
    .installer-card { padding: 22px; }
}

/* ==========================================================================
   Mobile / touch refinements (phones such as the Oppo A54, ~360px wide)
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; }

/* Touch devices have no hover - keep conversation actions reachable */
@media (hover: none), (pointer: coarse) {
    .conv-actions { display: flex; }
    .conv-link { padding-right: 70px; }
}

/* Use the dynamic viewport so the composer isn't hidden behind browser chrome */
@supports (height: 100dvh) {
    .app-shell, .auth-shell { min-height: 100dvh; }
    .chat-layout { height: calc(100dvh - 62px); }
}

/* Respect gesture bars / notches */
.composer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.sidebar-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 560px) {
    /* 16px inputs stop mobile browsers zooming when a field is focused */
    .field input, .field select, .field textarea,
    .filter-bar input, .filter-bar select,
    .form-inline input, .form-inline select,
    #messageInput, #adminMessageInput, .conv-search input, .model-select {
        font-size: 16px;
    }

    /* Comfortable tap targets */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 36px; }
    .icon-btn { min-width: 34px; min-height: 34px; font-size: .95rem; }
    .tool-btn { min-height: 34px; }

    .container { padding: 0 14px; }
    .container-fluid { padding: 12px 12px 44px; }
    .app-topbar { padding: 0 12px; gap: 8px; }
    .topbar-title { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-actions { gap: 8px; }
    .credit-chip { padding: 4px 10px; font-size: .8rem; }
    .avatar { width: 32px; height: 32px; }
    .side-link { padding: 12px; }

    /* Chat */
    .page-chat .app-content { display: flex; }
    .chat-header { padding: 0 10px; gap: 8px; height: 56px; }
    .model-select { flex: 1; min-width: 0; max-width: none; }
    .chat-header-actions .credit-chip { display: none; }
    .messages { padding: 16px 12px; }
    .message { gap: 10px; margin-bottom: 18px; }
    .message-avatar { width: 30px; height: 30px; }
    .message-content { font-size: .95rem; }
    .message-content pre { font-size: .78rem; padding: 12px; }
    .composer { padding: 10px 12px 10px; }
    .composer-inner { padding: 6px 6px 6px 12px; border-radius: 12px; }
    .composer-hint { font-size: .7rem; }
    .empty-chat { margin: 18px auto; }
    .empty-chat h2 { font-size: 1.25rem; }

    /* Marketing */
    .hero { padding: 46px 0 34px; }
    .hero h1 { font-size: 1.8rem; }
    .lead { font-size: 1rem; }
    .hero-actions .btn { width: 100%; }
    .section { padding: 46px 0; }
    .footer-grid { grid-template-columns: 1fr; gap: 22px; }
    .cta-inner { flex-direction: column; align-items: flex-start; }

    /* Auth / installer */
    .auth-form-side { padding: 26px 16px; }
    .auth-title { font-size: 1.5rem; }
    .dashboard-head h1, .page-head-inline h1 { font-size: 1.5rem; }
    .installer-body { padding: 22px 12px; }
    .installer-card { padding: 18px; }
    .installer-head h1 { font-size: 1.35rem; }
    .check-note { display: none; }
}

/* ==========================================================================
   Admin AI chat console
   ========================================================================== */
.page-admin-chat .app-content { display: flex; min-height: 0; }
.page-admin-chat .chat-sidebar { width: 260px; }
.page-admin-chat .composer-hint { color: var(--muted); }

