:root {
    --primary: #0FA3A3;
    --primary-dark: #0B7C7C;
    --primary-light: #6ED3CF;
    --action-blue: #3B82F6;
    --warning: #F97316;
    --error: #EF4444;
    --success: #10B981;
    --background: #F5F7FA;

    --white: #FFFFFF;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-900: #111827;

    --gradient: linear-gradient(135deg, #0FA3A3 0%, #3B82F6 100%);
    --shadow-card: 0 2px 8px rgba(17, 24, 39, 0.08);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--background);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--gray-900);
}

a { color: var(--action-blue); text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1:focus { outline: none; }

button, .btn {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    transition: opacity .15s ease, transform .1s ease;
}
button:active, .btn:active { transform: scale(0.98); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-blue { background: var(--action-blue); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-error { background: var(--error); color: white; }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; }

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    width: 100%;
    background: white;
    color: var(--gray-900);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 163, 163, .15);
}

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 16px;
}

.gradient-bg { background: var(--gradient); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-pending { background: #FFF1E6; color: var(--warning); }
.badge-progress { background: #FEF3C7; color: #B45309; }
.badge-approved, .badge-resolved { background: #DCFCE7; color: #15803D; }
.badge-rejected { background: #FEE2E2; color: #B91C1C; }
.badge-voting { background: #DBEAFE; color: #1D4ED8; }

.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.wide-container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
}
.alert-error { background: #FEF2F2; color: #B91C1C; border: 1px solid #FCA5A5; }
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #86EFAC; }

#blazor-error-ui {
    background: #EF4444;
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ── App shell (tab-bar layout) ─────────────────────────────────────────── */

.bare-layout { min-height: 100%; }

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 560px;
    margin: 0 auto;
    background: var(--background);
    box-shadow: 0 0 40px rgba(17,24,39,.06);
}

.shell-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.shell-header {
    background: white;
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    z-index: 20;
}
.shell-header-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}
.shell-logo { height: 28px; width: 28px; object-fit: contain; border-radius: 6px; }
.shell-community { display: flex; flex-direction: column; flex: 1; line-height: 1.25; font-size: 14px; }
.shell-avatar { width: 34px; height: 34px; font-size: 12px; }

.shell-content {
    flex: 1;
    padding-bottom: 76px;
}

.shell-tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 560px;
    background: white;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 30;
}
.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--gray-400);
    padding: 4px 8px;
    border-radius: 10px;
}
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-icon { font-size: 19px; }

/* ── Page headers within tabs ───────────────────────────────────────────── */

.page-header {
    background: white;
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
}
.page-header h2 { font-size: 20px; color: var(--gray-900); }
.page-header p { margin-top: 2px; }

.page-body { padding: 16px; }

.hero-banner {
    background: var(--gradient);
    color: white;
    padding: 20px 16px 40px;
}
.hero-banner h2 { color: white; font-size: 22px; }

.filter-pill {
    display: inline-flex;
    padding: 8px 14px;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.filter-pill.active { background: var(--primary); color: white; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 12px; background: white; }

.fab {
    width: 36px; height: 36px;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: none;
    cursor: pointer;
}

/* ── Landing page ────────────────────────────────────────────────────────── */

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    max-width: 1080px;
    margin: 0 auto;
}
.landing-nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.landing-nav img { height: 32px; width: 32px; object-fit: contain; border-radius: 8px; }

.landing-hero {
    background: var(--gradient);
    color: white;
    padding: 64px 24px 96px;
    text-align: center;
}
.landing-hero h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.15; color: white; }
.landing-hero p { font-size: 17px; opacity: .92; max-width: 560px; margin: 16px auto 28px; }
.landing-hero .cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.landing-hero .btn-ghost { background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.5); }

.landing-features {
    max-width: 1080px;
    margin: -56px auto 0;
    padding: 0 24px 64px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.landing-features .card { text-align: left; }
.landing-features .feature-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    background: var(--background);
    margin-bottom: 12px;
}
.landing-features h3 { font-size: 16px; margin-bottom: 6px; }
.landing-features p { color: var(--gray-500); font-size: 13.5px; }

.landing-footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
    font-size: 12.5px;
}

@media (max-width: 600px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .landing-hero { padding: 48px 20px 80px; }
}

/* ── Auth / onboarding pages ────────────────────────────────────────────── */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 32px 28px;
}
.auth-card img.auth-logo { height: 40px; width: 40px; border-radius: 10px; margin-bottom: 12px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--gray-500); font-size: 13.5px; margin-bottom: 22px; }
.auth-card label { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; display: block; }
.field { margin-bottom: 14px; }
.auth-links { margin-top: 18px; text-align: center; font-size: 13px; }
.auth-back { display: inline-block; margin-bottom: 16px; color: var(--gray-500); font-size: 13px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch::before {
    content: "";
    position: absolute; inset: 0;
    background: var(--gray-300);
    border-radius: 999px;
    transition: background .15s ease;
}
.switch::after {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 2px; top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform .15s ease;
}
.switch input:checked ~ .switch::before,
.switch:has(input:checked)::before { background: var(--primary); }
.switch:has(input:checked)::after { transform: translateX(18px); }

.invite-code-display {
    font-family: "Courier New", monospace;
    font-size: 22px;
    letter-spacing: 2px;
    text-align: center;
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 14px;
    font-weight: 700;
    color: var(--primary-dark);
}
