/* GenesisBot — dark + green theme (matches reference UI) */
:root {
    --bg: #0a1118;
    --bg-elev: #0f1922;
    --bg-card: #132130;
    --border: #1f3142;
    --text: #e8eef2;
    --text-dim: #95a3ad;
    --accent: #6fe6a3;
    --accent-strong: #3acf81;
    --danger: #ff7a7a;
    --radius: 14px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 20% -10%, #16344a 0%, var(--bg) 55%) no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 18px 32px;
    background: #f6f7f9;
    border-bottom: 1px solid #e6e8eb;
    box-shadow: 0 1px 0 rgba(15, 23, 32, 0.04);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #15233a;
    font-weight: 600;
    justify-self: start;
}

.brand-logo {
    height: 48px;
    width: auto;
    max-height: 48px;
    max-width: 220px;
    display: block;
    object-fit: contain;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-size: 20px; font-weight: 700; color: #0b1220; letter-spacing: -0.01em; }
.brand-tag { font-size: 12px; color: #5d6c7c; font-weight: 500; }
.brand-sub { font-size: 11px; color: #8a96a3; font-weight: 500; }

.topbar nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e6e8eb;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(15, 23, 32, 0.04);
    justify-self: center;
}

.topbar nav .nav-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 999px;
    color: #45525f;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.topbar nav .nav-link:hover { color: #0b1220; background: #f3f5f7; }
.topbar nav .nav-link.is-active {
    background: #0b1220;
    color: #ffffff;
}

.topbar .nav-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-self: end;
}

.user-pill {
    color: #5d6c7c;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #e6e8eb;
}

.btn-cta {
    background: #0b1220;
    color: #ffffff;
    border-color: #0b1220;
    padding: 12px 22px;
    font-weight: 600;
    gap: 8px;
}
.btn-cta:hover { background: #1a2740; color: #ffffff; }
.btn-cta .arrow { display: inline-block; transition: transform 0.15s ease; }
.btn-cta:hover .arrow { transform: translateX(3px); }

@media (max-width: 900px) {
    .topbar { grid-template-columns: 1fr auto; }
    .topbar nav { grid-column: 1 / -1; order: 3; overflow-x: auto; max-width: 100%; }
}

.inline-form { display: inline; margin: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.06s ease, background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    color: #0a1a12;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); color: #051208; }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-block { width: 100%; }

.main {
    max-width: 980px;
    margin: 0 auto;
    padding: 48px 24px 80px;
}

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.message {
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(111, 230, 163, 0.08);
    border: 1px solid rgba(111, 230, 163, 0.2);
    margin-bottom: 8px;
}

/* Auth pages */
.auth-shell {
    display: flex;
    justify-content: center;
    padding: 32px 0;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 32px 28px;
}

.auth-title {
    margin: 0 0 6px;
    font-size: 26px;
    letter-spacing: -0.2px;
}

.auth-sub {
    margin: 0 0 26px;
    color: var(--text-dim);
}

.field {
    display: block;
    margin-bottom: 16px;
}

.field-label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.input,
input[type="email"],
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(111, 230, 163, 0.15);
}

.field-error {
    display: block;
    margin-top: 6px;
    color: var(--danger);
    font-size: 12px;
}

.field-help {
    display: block;
    margin-top: 6px;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.45;
}

.form-error {
    background: rgba(255, 122, 122, 0.08);
    border: 1px solid rgba(255, 122, 122, 0.3);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}

.auth-foot {
    margin-top: 18px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* Authenticated home */
.hero {
    text-align: center;
    padding: 64px 16px 24px;
}
.eyebrow {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(111, 230, 163, 0.1);
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 14px;
}
.hero h1 {
    margin: 0 0 8px;
    font-size: 32px;
    letter-spacing: -0.4px;
}
.hero-sub {
    color: var(--text-dim);
    margin: 0 auto;
    max-width: 480px;
}

.hero-actions {
    margin-top: 22px;
}

/* Topbar nav link */
.nav-link {
    color: #2c3a52;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}
.nav-link:hover { color: var(--accent-strong); background: rgba(58, 207, 129, 0.08); }

/* Topbar buttons override (sit on white) */
.topbar .btn-ghost {
    color: #2c3a52;
    border-color: #d8dde2;
    background: transparent;
}
.topbar .btn-ghost:hover {
    border-color: var(--accent-strong);
    color: var(--accent-strong);
}

/* Page head */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.page-head > div:first-child { min-width: 0; }

.page-title {
    margin: 0 0 6px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.page-sub {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}

.page-head .btn { flex-shrink: 0; }

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 13px;
}
.back-link:hover { color: var(--accent); }

/* Bot list */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.bot-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-card) 0%, rgba(15, 25, 34, 0.6) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px 22px 18px;
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    min-height: 200px;
}
.bot-card:hover {
    border-color: var(--accent);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 14px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(111, 230, 163, 0.15);
}

.bot-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.bot-card-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
    line-height: 1.3;
}

.status-pill {
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.status-on {
    color: var(--accent);
    background: rgba(111, 230, 163, 0.1);
    border-color: rgba(111, 230, 163, 0.3);
}
.status-off {
    color: var(--text-dim);
    background: rgba(149, 163, 173, 0.06);
}

.bot-desc {
    margin: 4px 0 16px;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.55;
    flex: 1;
}

.bot-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-size: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.bot-meta .dot { opacity: 0.4; }

.empty {
    text-align: center;
    padding: 64px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.01);
}
.empty h2 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 0 18px; color: var(--text-dim); }

/* Bot form */
.bot-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px 18px;
}

.section-title {
    margin: 0 0 16px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
}

textarea.input,
textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 64px;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(111, 230, 163, 0.15);
}

select.input,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                      linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

input[type="number"].input,
input[type="number"] {
    -moz-appearance: textfield;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}
.checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.muted { color: var(--text-dim); font-size: 13px; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn-danger {
    background: rgba(255, 122, 122, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 122, 122, 0.4);
}
.btn-danger:hover {
    background: rgba(255, 122, 122, 0.2);
    color: #ffb0b0;
}

.danger-zone {
    margin-top: 32px;
    padding: 18px 22px;
    border: 1px solid rgba(255, 122, 122, 0.25);
    border-radius: var(--radius);
    background: rgba(255, 122, 122, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.danger-zone h3 {
    margin: 0 0 4px;
    font-size: 15px;
    color: #ffc7c7;
}
.danger-zone p { margin: 0; }

/* Bot tabs */
.bot-tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
}
.tab {
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.tab-active {
    background: var(--accent);
    color: #051208;
}
.tab-active:hover { background: var(--accent); color: #051208; }

/* Upload card */
.upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
}
.upload-card h3 { margin: 0 0 4px; font-size: 15px; }
.upload-row {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}
.upload-row input[type="file"] {
    color: var(--text-dim);
    font-size: 13px;
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.data-table th {
    background: var(--bg-elev);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: var(--text); }
.data-table a:hover { color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.status-fail {
    color: var(--danger);
    background: rgba(255, 122, 122, 0.1);
    border-color: rgba(255, 122, 122, 0.3);
}

.row-error {
    margin-top: 4px;
    color: var(--danger);
    font-size: 12px;
}

/* Chat */
.chat-shell {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 65vh;
    min-height: 460px;
    overflow: hidden;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-log.static { height: auto; min-height: auto; padding: 0; background: transparent; border: none; }

.bubble {
    max-width: 75%;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    border: 1px solid var(--border);
}
.bubble-role {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.bubble-text { color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.bubble-meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-dim);
}

.bubble-user {
    align-self: flex-end;
    background: rgba(111, 230, 163, 0.1);
    border-color: rgba(111, 230, 163, 0.3);
}
.bubble-bot {
    align-self: flex-start;
    background: var(--bg-elev);
}
.bubble-error .bubble-text { color: var(--danger); }

.chat-log.static .bubble { max-width: 100%; }

.chat-input {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
}
.chat-input textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    resize: none;
}

/* API key reveal */
.key-reveal {
    background: rgba(111, 230, 163, 0.06);
    border: 1px solid rgba(111, 230, 163, 0.3);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 24px;
}
.key-reveal h3 { margin: 0 0 4px; font-size: 15px; color: var(--accent); }
.key-reveal p { margin: 0 0 12px; }

.key-code {
    display: block;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    word-break: break-all;
    user-select: all;
    flex: 1;
    margin: 0;
}

.key-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.key-copy-btn {
    flex-shrink: 0;
    min-width: 86px;
    padding: 0 16px;
}

.code-block {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    color: var(--text);
    font-size: 13px;
    overflow-x: auto;
    white-space: pre;
    margin: 0 0 12px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

/* Billing */
.info-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 200, 100, 0.08);
    border: 1px solid rgba(255, 200, 100, 0.25);
    color: #f0d9b1;
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.info-card code { font-size: 13px; }

.usage-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.usage-row:last-child { border-bottom: none; }

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.plan-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
}
.plan-card .muted { flex-shrink: 0; }
.plan-card form { margin-top: auto; }

.plan-current {
    border-color: var(--accent);
    background: rgba(111, 230, 163, 0.04);
}

.plan-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.plan-head h3 { margin: 0; font-size: 18px; }
.plan-price {
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 14px 0;
    flex-grow: 1;
}
.plan-features li {
    padding: 5px 0;
    font-size: 13px;
    color: var(--text-dim);
    border-bottom: 1px dashed var(--border);
}
.plan-features li:last-child { border-bottom: none; }
