:root {
    --primary: #0f766e;
    --primary-dark: #0d5c56;
    --primary-light: #14b8a6;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.5;
    border: none;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { text-decoration: none; color: var(--text); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 2.25rem; padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-lg { min-height: 3rem; padding: 0.875rem 1.75rem; font-size: 1rem; }
.w-full { width: 100%; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5); padding: 1.5rem; box-shadow: var(--shadow);
}
.card-stat { text-align: center; }
.card-stat .value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.card-stat .label { font-size: 0.875rem; color: var(--text-muted); }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    min-height: 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.5;
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
.form-select {
    padding-right: 2.5rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 1rem;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}
.form-textarea { min-height: 120px; resize: vertical; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.form-error { color: var(--danger); font-size: 0.8125rem; margin-top: 0.25rem; }
.form-actions {
    margin-top: 1.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.stack-cards {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.profile-form header {
    margin-bottom: 1.25rem;
}
.profile-form header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}
.profile-form header p {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.profile-form header + .form-actions,
.profile-form form .form-actions {
    margin-top: 1.75rem;
}

.badge {
    display: inline-block; padding: 0.125rem 0.625rem; border-radius: 9999px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px; background: var(--text); color: #fff; padding: 1.5rem 0;
    flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { padding: 0 1.5rem 1.5rem; font-size: 1.25rem; font-weight: 700; }
.sidebar-brand span { color: var(--primary-light); }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem;
    color: #94a3b8; font-size: 0.875rem; transition: all .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.08); color: #fff; text-decoration: none;
}
.main-content { flex: 1; padding: 2rem; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header p { color: var(--text-muted); margin-top: 0.25rem; }

.quick-generate-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}
.quick-generate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 4rem;
    padding: 0.75rem 1rem;
    text-align: center;
    line-height: 1.35;
    font-size: 0.8125rem;
    white-space: normal;
    text-decoration: none;
}
.quick-generate-btn:hover {
    text-decoration: none;
}
.quick-generate-label {
    font-weight: 600;
    color: var(--text);
}
.quick-generate-cost {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}
.quick-generate-grid .quick-generate-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* Landing */
.landing-header {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
    z-index: 50;
}
.landing-header-inner { position: relative; }
.landing-brand { font-size: 1.25rem; }
.landing-nav { display: flex; gap: 0.75rem; align-items: center; }
.landing-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}
.landing-menu-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform .2s, opacity .2s;
}
.landing-menu-toggle.is-open .landing-menu-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.landing-menu-toggle.is-open .landing-menu-bar:nth-child(2) { opacity: 0; }
.landing-menu-toggle.is-open .landing-menu-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.hero { padding: 4rem 0; text-align: center; }
.hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.2; margin-bottom: 1rem; }
.hero h1 span { color: var(--primary); }
.hero p { font-size: 1.25rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 2rem; }
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}
.features { padding: 4rem 0; }
.feature-card { text-align: center; padding: 1.75rem 1.5rem; }
.feature-card-header {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    max-width: 100%;
    margin: 0 auto 0.75rem;
}
.feature-card-header h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}
.feature-icon-img {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: contain;
    flex-shrink: 0;
}
.pricing { padding: 4rem 0; background: var(--surface); text-align: center; }
#pricing .pricing-intro,
#pricing .pricing-title,
#pricing .pricing-subtitle {
    text-align: center;
}
.pricing-intro {
    margin-bottom: 3.5rem;
}
.pricing-grid { align-items: stretch; }
.pricing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    padding: 1.75rem 1.25rem;
    text-align: center;
}
.pricing-card-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
}
#pricing .pricing-plan-header {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    width: 100%;
    margin: 0 auto 1.5rem;
    text-align: center;
}
#pricing .pricing-plan-name {
    margin: 0 0 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    text-align: center;
    width: 100%;
}
.pricing-plan-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
#pricing .pricing-plan-icon {
    display: block;
    width: 60px;
    height: 60px;
    margin: 0 auto;
    object-fit: contain;
}
#pricing .pricing-credits,
#pricing .price {
    text-align: center;
    width: 100%;
}
.pricing-credits {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.pricing-features {
    list-style: none;
    width: 100%;
    max-width: 15rem;
    margin: 2rem auto 0;
    padding: 1.5rem 0 0;
    border-top: 1px solid var(--border);
    flex: 1;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-muted);
    align-self: center;
}
.pricing-features li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.35rem 0;
}
.pricing-check {
    color: var(--success);
    font-weight: 700;
    line-height: 1.4;
    flex-shrink: 0;
}
.pricing-card-btn { margin-top: 1.25rem; }
.pricing-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 1rem;
    text-align: center;
}
.pricing-subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
}
.price {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    text-align: center;
    width: 100%;
}
.price small { font-size: 1rem; color: var(--text-muted); font-weight: 400; }
.landing-footer {
    padding: 2rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
    .sidebar { display: none; }

    .landing-header .container {
        flex-direction: row;
        text-align: left;
    }
    .landing-menu-toggle { display: flex; }
    .landing-nav {
        display: none;
        position: absolute;
        top: calc(100% + 0.75rem);
        right: 0;
        left: 0;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: calc(var(--radius) * 1.5);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    }
    .landing-nav.is-open { display: flex; }
    .landing-nav .btn { width: 100%; }

    .hero { padding: 2.5rem 0; }
    .hero h1 { font-size: 1.875rem; }
    .hero p { font-size: 1rem; margin-bottom: 1.5rem; }
    .hero-actions {
        flex-direction: column;
        width: 100%;
        max-width: 360px;
        margin: 0 auto;
    }
    .hero-actions .btn { width: 100%; }

    .features { padding: 2.5rem 0; }
    .feature-card { padding: 1.25rem 1rem; }
    .feature-card-header h3 { font-size: 0.9375rem; }

    .quick-generate-grid {
        grid-template-columns: 1fr;
    }
    .quick-generate-grid .quick-generate-btn:last-child:nth-child(odd) {
        grid-column: auto;
    }

    .pricing { padding: 2.5rem 0; }
    .pricing-intro { margin-bottom: 2.5rem; }
    .pricing-title { font-size: 1.5rem; margin-bottom: 0.875rem; }
    .pricing-subtitle { font-size: 0.9375rem; }
    .pricing-card { padding: 1.5rem 1rem; }
    .pricing-plan-header { margin-bottom: 1.25rem; }
    .pricing-plan-icon { width: 52px; height: 52px; }
    .pricing-features { margin-top: 1.75rem; padding-top: 1.25rem; max-width: 100%; }
    .price { font-size: 2rem; }
}

/* Output panel */
.output-panel {
    background: #f1f5f9; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; min-height: 200px; white-space: pre-wrap; font-size: 0.875rem;
    line-height: 1.7;
}
.spinner {
    display: inline-block; width: 1.25rem; height: 1.25rem;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.table th { font-weight: 600; color: var(--text-muted); background: #f8fafc; }

/* Alert */
.alert { padding: 0.875rem 1rem; border-radius: var(--radius); font-size: 0.875rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* Auth */
.auth-container { max-width: 420px; margin: 4rem auto; padding: 0 1rem; }
.auth-card { padding: 2rem; }
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; }
.auth-divider { text-align: center; margin: 1.5rem 0; color: var(--text-muted); font-size: 0.875rem; }
.guest-form .form-input,
.guest-form .form-select {
    margin-top: 0.375rem;
}
.guest-form .btn,
.guest-form button[type="submit"] {
    min-height: 2.75rem;
}
.social-btns { display: flex; gap: 0.75rem; }
.social-btns .btn { flex: 1; }
.social-icon { width: 0.875rem; height: 0.875rem; flex-shrink: 0; }

/* Admin */
.admin-layout .sidebar { background: #1e1b4b; }
.admin-layout .sidebar-brand span { color: #a78bfa; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }

.billing-plan-card {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.billing-plan-card:hover {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.billing-plan-card-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}

.billing-plan-features {
    margin: 0;
    padding-left: 1rem;
    flex: 1;
}
