:root {
    color-scheme: light;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --bg: #f7f8fa;
    --card: #ffffff;
    --text: #18181b;
    --muted: #71717a;
    --border: #e4e4e7;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 10px rgba(16, 24, 40, .06), 0 2px 4px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.site-header { background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--primary); text-decoration: none; letter-spacing: -.01em; }
.site-header nav { display: flex; align-items: center; gap: 14px; }
.site-header nav a { text-decoration: none; color: var(--text); font-size: .95rem; font-weight: 500; }
.site-header nav a:hover { color: var(--primary); }

main.container { padding: 28px 16px 64px; }

.hero { text-align: center; padding: 52px 0 32px; }
.hero h1 { font-size: 1.85rem; margin-bottom: 12px; line-height: 1.3; letter-spacing: -.01em; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 22px; font-size: .98rem; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 24px; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: box-shadow .15s ease, transform .15s ease; }
.feature:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feature h3 { margin: 0 0 6px; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.01em; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
    background: none; border: none; cursor: pointer; padding: 10px 16px; font-size: .92rem; font-weight: 600;
    color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
    transition: color .15s ease, border-color .15s ease; text-decoration: none; display: inline-block;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-save-bar { margin-top: 4px; }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-label input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; border: none;
    padding: 11px 20px; border-radius: 9px; font-size: .95rem; text-decoration: none;
    cursor: pointer; min-height: 42px; font-weight: 600; box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
    transition: background .15s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { background: #d4d4d8; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-success { background: var(--success); box-shadow: 0 1px 2px rgba(22, 163, 74, .25); }
.btn-success:hover { background: #15803d; }
.download-link { color: var(--success); font-weight: 600; text-decoration: none; }
.download-link:hover { text-decoration: underline; }
.btn-small { padding: 8px 14px; font-size: .85rem; min-height: 34px; }
.btn-google { background: #fff; color: #18181b; border: 1px solid var(--border); display: flex; width: 100%; text-align: center; margin-bottom: 12px; box-shadow: none; }
.btn-google:hover { background: #f4f4f5; }

.link-button { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 4px 0; font-size: .9rem; }
.link-button.danger { color: var(--danger); }
.inline-form { display: inline; }

.auth-card { max-width: 400px; margin: 32px auto; }
.auth-card h1 { font-size: 1.4rem; margin-top: 0; }
.divider { text-align: center; color: var(--muted); margin: 12px 0; font-size: .82rem; position: relative; }

form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
form label .muted { font-weight: 400; }
form input[type=text], form input[type=email], form input[type=password], form input[type=url], form select {
    display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 1rem; font-weight: 400; background: #fff; color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
form input:focus, form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
form input[type=color] { width: 56px; height: 42px; padding: 2px; margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
form input[type=file] { margin-top: 6px; font-weight: 400; width: 100%; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.icon-preview { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; margin-bottom: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.app-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--text); display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.app-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.app-icon { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.2rem; flex-shrink: 0; overflow: hidden; box-shadow: 0 2px 5px rgba(0, 0, 0, .15); }
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-info { min-width: 0; }
.app-info h3 { margin: 0 0 4px; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-info p { font-size: .8rem; margin: 0 0 6px; }

.status { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: #f4f4f5; color: #52525b; letter-spacing: .01em; }
.status-ready { background: #dcfce7; color: var(--success); }
.status-failed { background: #fee2e2; color: var(--danger); }
.status-building, .status-queued { background: #fef3c7; color: #92400e; }
.status-draft { background: #f4f4f5; color: #52525b; }

.table { width: 100%; border-collapse: collapse; margin-top: 10px; display: block; overflow-x: auto; white-space: nowrap; }
.table th { text-align: left; padding: 8px 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }
.table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: .88rem; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; border: 1px solid transparent; }
.alert-error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }

.muted { color: var(--muted); font-size: .85em; }
.delete-form { margin-top: 16px; text-align: right; }

.site-footer { text-align: center; color: var(--muted); padding: 24px 0; font-size: .8rem; border-top: 1px solid var(--border); margin-top: 28px; }

@media (max-width: 480px) {
    .hero h1 { font-size: 1.5rem; }
    .card { padding: 16px; }
    .btn { width: 100%; }
    .app-form .btn { width: auto; }
}

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 220px; padding-top: 22px; overflow-x: auto; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1 0 26px; min-width: 26px; height: 100%; }
.bar-value { font-size: .7rem; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.bar { width: 100%; max-width: 28px; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 4px; transition: height .2s ease; }
.bar-usage { background: var(--success); }
.bar-label { font-size: .68rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; margin: 4px 0; }
.stat-card .stat-label { color: var(--muted); font-size: .85rem; }

.admin-badge { background: #18181b; color: #fff; padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; margin-left: 6px; }

/* ---------------------------------------------------------------- Hero polish */
.hero {
    position: relative;
    background:
        radial-gradient(480px 240px at 15% 0%, rgba(37, 99, 235, .12), transparent 70%),
        radial-gradient(480px 240px at 85% 20%, rgba(37, 99, 235, .08), transparent 70%);
    border-radius: var(--radius);
}

/* ---------------------------------------------------------------- App shell (sidebar layout, shown when logged in) */
.sidebar {
    width: 252px; flex-shrink: 0; background: #111827; color: #cbd5e1;
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 40; transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; color: #fff;
    font-weight: 800; font-size: 1.05rem; text-decoration: none; letter-spacing: -.01em;
}
.sidebar-brand-mark {
    width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: .95rem; font-weight: 800; flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: #cbd5e1; text-decoration: none; font-size: .92rem; font-weight: 500; margin-bottom: 2px;
    transition: background .15s ease, color .15s ease; width: 100%; background: none; border: none;
    cursor: pointer; text-align: left; font-family: inherit;
}
.sidebar-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-cta { padding: 6px 16px 4px; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-width: 0; }
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: .75rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { padding-left: 12px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; }

.app-main { margin-left: 252px; display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar {
    display: none; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.menu-toggle {
    background: none; border: 1px solid var(--border); border-radius: 8px; width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); flex-shrink: 0;
}
.menu-toggle svg { width: 20px; height: 20px; }
.app-content { flex: 1; padding: 28px 24px 56px; max-width: 1080px; width: 100%; margin: 0 auto; box-sizing: border-box; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-topbar { display: flex; }
    .sidebar-overlay.open { display: block; }
    .app-content { padding: 20px 16px 48px; }
}
