:root {
    --sky: #3b82f6;
    --sky-lt: #dbeafe;
    --sky-dk: #1d4ed8;
    --sun: #f59e0b;
    --sun-lt: #fef3c7;
    --leaf: #10b981;
    --leaf-lt: #d1fae5;
    --rose: #ef4444;
    --rose-lt: #fee2e2;
    --violet: #8b5cf6;
    --ink: #1e293b;
    --ink-soft: #475569;
    --paper: #f8fafc;
    --white: #ffffff;
    --border: rgba(30, 41, 59, 0.1);
    --shadow-sm: 0 2px 10px rgba(59, 130, 246, 0.08);
    --shadow-md: 0 8px 30px rgba(59, 130, 246, 0.12);
    --radius: 20px;
    --radius-sm: 12px;
    --display: 'Fredoka', system-ui, sans-serif;
    --body: 'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.app-page {
    font-family: var(--body);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body.app-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 10% 15%, rgba(59, 130, 246, 0.07) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.06) 0%, transparent 35%);
    pointer-events: none;
    z-index: 0;
}

.app-page a { text-decoration: none; color: inherit; transition: 0.2s; }

/* ── Header ── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    border-bottom: 2px solid var(--sky-lt);
}

.app-nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.app-brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: contain;
    background: white;
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
}

.app-brand-text {
    font-family: var(--display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sky-dk);
    line-height: 1.1;
}

.app-brand-text span { color: var(--sun); }

.app-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--sky-dk);
    cursor: pointer;
    padding: 8px;
}

.app-nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.app-nav-links a:not(.app-btn) {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.app-nav-links a:not(.app-btn):hover { color: var(--sky-dk); }

.app-nav-links a.active { color: var(--sky-dk); }

.app-lang {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.app-lang a.active { color: var(--sky-dk); font-weight: 800; }

.app-logout-form { display: inline; margin: 0; }

/* ── Buttons ── */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    font-family: var(--body);
    font-size: 0.88rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.app-btn-primary {
    background: linear-gradient(135deg, var(--sky), var(--sky-dk));
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.app-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.app-btn-secondary {
    background: linear-gradient(135deg, var(--sun), #f97316);
    color: white;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.app-btn-outline {
    background: white;
    border: 2px solid var(--border);
    color: var(--ink-soft);
    font-weight: 700;
}

.app-btn-outline:hover {
    border-color: var(--sky);
    color: var(--sky-dk);
    background: var(--sky-lt);
}

.app-btn-sm {
    padding: 7px 14px;
    font-size: 0.78rem;
}

.app-btn-block { width: 100%; }

/* ── Layout ── */
.app-main {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

/* ── Alerts ── */
.app-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.9rem;
}

.app-alert-success {
    background: var(--leaf-lt);
    color: #064e3b;
    border-left: 4px solid var(--leaf);
}

.app-alert-error {
    background: var(--rose-lt);
    color: #991b1b;
    border-left: 4px solid var(--rose);
}

/* ── Dashboard welcome ── */
.app-welcome {
    background: linear-gradient(135deg, var(--sky-dk), var(--sky));
    border-radius: var(--radius);
    padding: 1.75rem 1.5rem;
    color: white;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.app-welcome::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -5%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.app-welcome h1 {
    font-family: var(--display);
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    margin-bottom: 6px;
    position: relative;
}

.app-welcome p {
    opacity: 0.9;
    font-size: 0.9rem;
    position: relative;
    margin: 0;
}

/* ── Quick actions ── */
.app-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 1.25rem;
}

.app-quick-card {
    background: white;
    border: 2px solid var(--sky-lt);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.app-quick-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--sky);
}

.app-quick-card i {
    font-size: 1.4rem;
    color: var(--sky);
    margin-bottom: 8px;
    display: block;
}

.app-quick-card.is-accent i { color: var(--sun); }
.app-quick-card.is-accent { border-color: var(--sun-lt); }

.app-quick-card span {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.3;
}

/* ── Stats ── */
.app-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 1.5rem;
}

.app-stat {
    background: white;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    padding: 1rem 0.75rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.app-stat strong {
    display: block;
    font-family: var(--display);
    font-size: 1.75rem;
    color: var(--sky-dk);
    line-height: 1;
    margin-bottom: 4px;
}

.app-stat span {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}

/* ── Section ── */
.app-section {
    margin-bottom: 1.5rem;
}

.app-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.app-section-header h2 {
    font-family: var(--display);
    font-size: 1.15rem;
    color: var(--sky-dk);
}

/* ── Cards ── */
.app-card {
    background: white;
    border: 2px solid var(--sky-lt);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.app-card h3 {
    font-family: var(--display);
    font-size: 1rem;
    color: var(--sky-dk);
    margin-bottom: 10px;
}

/* ── List items (mobile-friendly) ── */
.app-list { display: flex; flex-direction: column; gap: 10px; }

.app-list-item {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s;
}

.app-list-item:hover { border-color: var(--sky-lt); }

.app-list-main { min-width: 0; }

.app-list-title {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--ink);
    margin-bottom: 2px;
    word-break: break-all;
}

.app-list-meta {
    font-size: 0.78rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.app-list-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

/* ── Badges ── */
.app-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.app-badge-progress { background: var(--sun-lt); color: #b45309; }
.app-badge-done { background: var(--leaf-lt); color: #047857; }
.app-badge-paid { background: var(--sky-lt); color: var(--sky-dk); }
.app-badge-pending { background: #fef3c7; color: #92400e; }
.app-badge-wait { background: var(--violet-lt, #ede9fe); color: var(--violet); }
.app-badge-muted { background: #f1f5f9; color: #64748b; }

/* ── Empty state ── */
.app-empty {
    text-align: center;
    padding: 2rem 1rem;
    background: white;
    border: 2px dashed var(--sky-lt);
    border-radius: var(--radius);
    color: var(--ink-soft);
}

.app-empty i {
    font-size: 2rem;
    color: var(--sky-lt);
    margin-bottom: 10px;
    display: block;
}

.app-empty p {
    font-size: 0.9rem;
    margin-bottom: 14px;
}

/* ── Forms ── */
.app-form textarea,
.app-form input[type="text"],
.app-form input[type="email"],
.app-form input[type="file"],
.app-form select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--body);
    font-size: 0.9rem;
    background: var(--paper);
    margin-bottom: 10px;
}

.app-form textarea:focus,
.app-form select:focus {
    outline: none;
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Affiliate promo ── */
.app-affiliate-card {
    background: linear-gradient(to bottom right, #fffbeb, white);
    border: 2px solid #fbbf24;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.app-affiliate-card h3 {
    font-family: var(--display);
    color: #d97706;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-affiliate-card p {
    font-size: 0.88rem;
    color: var(--ink-soft);
    margin-bottom: 12px;
}

/* ── Legacy shared (checkout etc.) ── */
.card { background: white; border: 2px solid var(--sky-lt); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 50px; font-weight: 800; text-decoration: none; border: none; cursor: pointer; font-family: var(--body); font-size: 0.88rem; }
.btn-primary { background: linear-gradient(135deg, var(--sky), var(--sky-dk)); color: #fff; }
.btn-outline { background: #fff; border: 2px solid var(--border); color: var(--ink-soft); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; background: var(--sky-lt); color: var(--sky-dk); }

/* Hide table on mobile, show cards via app-list */
.app-table-wrap { overflow-x: auto; }
table.app-table { width: 100%; border-collapse: collapse; }
table.app-table th, table.app-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.85rem; }
table.app-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-nav-toggle { display: block; }

    .app-nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px 18px;
        gap: 10px;
        border-bottom: 2px solid var(--sky-lt);
        box-shadow: var(--shadow-md);
    }

    .app-nav-links.open { display: flex; }

    .app-nav-links .app-btn { text-align: center; justify-content: center; }

    .app-nav { position: relative; flex-wrap: wrap; }

    .app-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }

    .app-stat strong { font-size: 1.4rem; }

    .app-stat span { font-size: 0.6rem; }

    .app-list-item {
        grid-template-columns: 1fr;
    }

    .app-list-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
    }

    .app-table-wrap { display: none; }
}

@media (min-width: 769px) {
    .app-list.mobile-only { display: none; }
}

@media (max-width: 768px) {
    .app-list.desktop-only { display: none; }
}

@media (max-width: 400px) {
    .app-stats { grid-template-columns: 1fr 1fr 1fr; }
    .app-quick-actions { grid-template-columns: 1fr 1fr; }
}
