/* ============================================
   CozyColoc' — Design System (Mobile-First)
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ── */
:root {
    /* Brand colors */
    --primary: #6C63FF;
    --primary-light: #8B83FF;
    --primary-dark: #5A52D9;
    --primary-glow: rgba(108, 99, 255, 0.3);

    /* Accent */
    --accent: #FF6584;
    --accent-light: #FF8FA3;
    --accent-dark: #E04E6B;

    /* Success / Warning / Error */
    --success: #43AA8B;
    --success-bg: rgba(67, 170, 139, 0.15);
    --warning: #F9C74F;
    --warning-bg: rgba(249, 199, 79, 0.15);
    --error: #F94144;
    --error-bg: rgba(249, 65, 68, 0.15);
    --info: #577590;
    --info-bg: rgba(87, 117, 144, 0.15);

    /* Light theme (default) */
    --bg-primary: #F4F4FB;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0F0FA;
    --bg-input: #F4F4FB;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-overlay: rgba(244, 244, 251, 0.85);

    --text-primary: #1A1A2E;
    --text-secondary: #5A5A72;
    --text-muted: #9A9AB0;
    --text-link: #6C63FF;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.04);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-base: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
    --font-3xl: 2rem;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --nav-height: 60px;
    --bottom-nav-height: 64px;
    --sidebar-width: 260px;
    --max-content-width: 800px;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

input,
select,
textarea,
button {
    font-family: inherit;
}

/* ── Layout ── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: var(--space-md);
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-xl));
    max-width: var(--max-content-width);
    margin: 0 auto;
    width: 100%;
}

/* ── Top Header ── */
.top-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
}

.top-header .logo {
    font-size: var(--font-xl);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.top-header .header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--font-xl);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background: var(--bg-card);
    color: var(--primary);
}

/* ── Avatar ── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-sm);
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.avatar:hover {
    transform: scale(1.1);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: var(--font-xs);
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: var(--font-lg);
}

.avatar-xl {
    width: 72px;
    height: 72px;
    font-size: var(--font-2xl);
}

/* ── Bottom Navigation (Mobile) ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--bottom-nav-height);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-muted);
    font-size: var(--font-xs);
    font-weight: 500;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    min-width: 60px;
    text-decoration: none;
    position: relative;
}

.bottom-nav a .nav-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform var(--transition-fast);
}

.bottom-nav a.active {
    color: var(--primary);
}

.bottom-nav a.active .nav-icon {
    transform: scale(1.15);
}

.bottom-nav a.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

.bottom-nav a:hover {
    color: var(--primary-light);
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--primary-glow);
    box-shadow: var(--shadow-md);
}

.card-compact {
    padding: var(--space-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stat-card.stat-primary::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-card.stat-accent::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.stat-card.stat-success::before {
    background: linear-gradient(90deg, var(--success), #6DD5B4);
}

.stat-card.stat-warning::before {
    background: linear-gradient(90deg, var(--warning), #FBD97C);
}

.stat-value {
    font-size: var(--font-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: var(--space-xs);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: var(--accent-dark);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-sm);
    border-radius: var(--radius-sm);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--space-md));
    right: var(--space-md);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    padding: 0;
    font-size: 24px;
    z-index: 50;
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
}

/* ── Forms ── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-base);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6B80' d='M1.41.59L6 5.17 10.59.59 12 2l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-hint {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.form-file-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.form-file-input:hover {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.05);
}

/* Checkbox / Toggle */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-sm);
}

.checkbox-label:hover {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.05);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.checkbox-label.checked {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
}

/* ── Flash Messages ── */
.flash-container {
    position: fixed;
    top: calc(var(--nav-height) + var(--space-sm));
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    width: calc(100% - var(--space-xl));
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.flash {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    animation: flashSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.flash-icon {
    font-size: var(--font-lg);
    flex-shrink: 0;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(67, 170, 139, 0.3);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(249, 65, 68, 0.3);
}

.flash-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(249, 199, 79, 0.3);
}

.flash-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(87, 117, 144, 0.3);
}

@keyframes flashSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Page Headers ── */
.page-header {
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: var(--font-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-subtitle {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.page-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ── News Feed ── */
.news-feed {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.news-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.news-card:hover {
    border-color: rgba(108, 99, 255, 0.2);
    box-shadow: var(--shadow-md);
}

.news-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-md) 0;
}

.news-author {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.news-author-name {
    font-weight: 600;
    font-size: var(--font-sm);
}

.news-date {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.news-card-body {
    padding: var(--space-md);
}

.news-title {
    font-size: var(--font-lg);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.news-content {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
    text-align: center;
}

.news-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-top: var(--space-md);
}

.news-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-md);
    padding: 8px 14px;
    background: rgba(108, 99, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--primary);
    transition: all var(--transition-fast);
}

.news-link:hover {
    background: rgba(108, 99, 255, 0.2);
    color: var(--primary-light);
}

.news-card-footer {
    padding: var(--space-sm) var(--space-md) var(--space-md);
    display: flex;
    justify-content: flex-end;
}

/* ── Finance ── */
.expense-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.expense-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.expense-item:hover {
    border-color: rgba(108, 99, 255, 0.2);
}

.expense-info {
    flex: 1;
    min-width: 0;
}

.expense-title {
    font-weight: 600;
    font-size: var(--font-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: 2px;
}

.expense-amount {
    font-size: var(--font-lg);
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

.expense-participants-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: var(--space-xs);
}

.participant-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(108, 99, 255, 0.1);
    border-radius: var(--radius-xl);
    font-size: 11px;
    color: var(--text-secondary);
}

/* Balance cards */
.balance-section {
    margin-bottom: var(--space-xl);
}

.balance-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.balance-arrow {
    font-size: var(--font-xl);
    color: var(--accent);
    flex-shrink: 0;
}

.balance-amount {
    font-size: var(--font-lg);
    font-weight: 800;
    color: var(--warning);
    white-space: nowrap;
    margin-left: auto;
}

.balance-settled {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--success);
    font-size: var(--font-lg);
    font-weight: 600;
}

/* ── Rules ── */
.rules-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    line-height: 1.8;
    font-size: var(--font-sm);
}

.rules-content h1,
.rules-content h2,
.rules-content h3 {
    color: var(--text-primary);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.rules-content h1 {
    font-size: var(--font-2xl);
}

.rules-content h2 {
    font-size: var(--font-xl);
    color: var(--primary);
}

.rules-content h3 {
    font-size: var(--font-lg);
}

.rules-content ul,
.rules-content ol {
    padding-left: var(--space-lg);
}

.rules-content li {
    margin-bottom: var(--space-xs);
}

.rules-content em {
    color: var(--text-muted);
}

.rules-content p {
    margin-bottom: var(--space-sm);
}

/* ── Auth Pages ── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(108, 99, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(255, 101, 132, 0.05) 0%, transparent 40%);
    animation: authBgFloat 20s ease-in-out infinite alternate;
}

@keyframes authBgFloat {
    from {
        transform: translate(0, 0) rotate(0deg);
    }

    to {
        transform: translate(2%, 2%) rotate(3deg);
    }
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-logo h1 {
    font-size: var(--font-3xl);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: var(--font-sm);
    margin-top: var(--space-xs);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    color: var(--text-muted);
    font-size: var(--font-sm);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ── Section ── */
.section-title {
    font-size: var(--font-lg);
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-title .icon {
    font-size: var(--font-xl);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-xl);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-admin {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.badge-member {
    background: rgba(67, 170, 139, 0.15);
    color: var(--success);
}

.badge-guest {
    background: rgba(158, 158, 158, 0.15);
    color: var(--text-muted);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.empty-state-text {
    font-size: var(--font-sm);
    margin-bottom: var(--space-lg);
}

/* ── Legal pages ── */
.legal-page {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.legal-page h1 {
    font-size: var(--font-2xl);
    margin-bottom: var(--space-lg);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.legal-page h2 {
    font-size: var(--font-xl);
    color: var(--primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
}

.legal-page p,
.legal-page li {
    font-size: var(--font-sm);
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.legal-page ul {
    padding-left: var(--space-lg);
}

/* ── User list (admin) ── */
.user-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.user-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: var(--font-sm);
}

.user-email {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ── Profile ── */
.profile-header {
    text-align: center;
    padding: var(--space-xl) 0;
}

/* ── Utilities ── */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.text-sm {
    font-size: var(--font-sm);
}

.text-xs {
    font-size: var(--font-xs);
}

.font-bold {
    font-weight: 700;
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mt-xl {
    margin-top: var(--space-xl);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.hidden {
    display: none !important;
}

/* ── Accept rules page ── */
.accept-rules-container {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: var(--space-lg);
    padding-right: var(--space-sm);
}

.accept-rules-container::-webkit-scrollbar {
    width: 6px;
}

.accept-rules-container::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}

.accept-rules-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

/* ── Delete confirm ── */
.delete-form {
    display: inline;
}

/* ── Guest banner ── */
.guest-banner {
    background: linear-gradient(135deg, rgba(249, 199, 79, 0.1), rgba(249, 199, 79, 0.05));
    border: 1px solid rgba(249, 199, 79, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    font-size: var(--font-sm);
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ── Select All ── */
.select-all-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-xs);
    font-weight: 600;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.select-all-btn:hover {
    background: rgba(108, 99, 255, 0.1);
}

/* ── 404 page ── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: var(--space-xl);
}

.error-code {
    font-size: 120px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.error-message {
    font-size: var(--font-xl);
    color: var(--text-secondary);
    margin: var(--space-md) 0 var(--space-xl);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Animations ── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.animate-delay-1 {
    animation-delay: 0.05s;
}

.animate-delay-2 {
    animation-delay: 0.1s;
}

.animate-delay-3 {
    animation-delay: 0.15s;
}

.animate-delay-4 {
    animation-delay: 0.2s;
}

.animate-delay-5 {
    animation-delay: 0.25s;
}

/* ── Desktop Layout (≥ 768px) ── */
@media (min-width: 768px) {
    :root {
        --bottom-nav-height: 0px;
    }

    .bottom-nav {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        flex-direction: column;
        justify-content: flex-start;
        padding: var(--space-lg) var(--space-md);
        gap: var(--space-xs);
        border-top: none;
        border-right: 1px solid var(--border-color);
        height: auto;
    }

    .bottom-nav a {
        flex-direction: row;
        justify-content: flex-start;
        font-size: var(--font-sm);
        padding: 12px var(--space-md);
        width: 100%;
        min-width: auto;
        border-radius: var(--radius-md);
    }

    .bottom-nav a .nav-icon {
        font-size: 20px;
        width: 24px;
        text-align: center;
    }

    .bottom-nav a.active::after {
        top: 50%;
        left: 0;
        right: auto;
        transform: translateY(-50%);
        width: 3px;
        height: 24px;
        border-radius: 0 4px 4px 0;
    }

    .main-content {
        margin-left: var(--sidebar-width);
        padding: var(--space-xl) var(--space-2xl);
        padding-bottom: var(--space-2xl);
    }

    .btn-fab {
        bottom: var(--space-xl);
        right: var(--space-xl);
    }

    .auth-card {
        padding: var(--space-2xl) 48px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ── Large screens ── */
@media (min-width: 1200px) {
    .main-content {
        max-width: 900px;
    }
}

/* ── Tab navigation (for finance) ── */
.tab-nav {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.tab-nav a {
    flex: 1;
    text-align: center;
    padding: 10px var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.tab-nav a.active {
    background: var(--primary);
    color: white;
}

.tab-nav a:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

/* ── Widget Mode (Homey Integration) ── */
body.widget-mode {
    --space-page-padding: 0.75rem;
    margin: 0;
    padding: 0;
}

.widget-mode .widget-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.widget-mode .widget-content {
    flex: 1;
    padding: var(--space-page-padding);
    padding-bottom: var(--space-lg);
    padding-top: var(--space-md);
}

/* Widget page header - compact */
.widget-mode .page-header {
    margin-bottom: var(--space-lg);
}

.widget-mode .page-header .page-title {
    font-size: var(--font-lg);
    margin-bottom: var(--space-xs);
}

.widget-mode .page-header-actions {
    margin-bottom: var(--space-lg);
}

.widget-mode .page-header-actions h1 {
    font-size: var(--font-xl);
    margin-bottom: var(--space-sm);
}

/* Widget cards - reduce padding and margins */
.widget-mode .card {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-md);
}

.widget-mode .card-title {
    font-size: var(--font-base);
    margin-bottom: var(--space-sm);
}

/* Widget expense items - compact */
.widget-mode .expense-item {
    padding: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.widget-mode .expense-title {
    font-size: var(--font-sm);
}

.widget-mode .expense-meta {
    font-size: var(--font-xs);
}

.widget-mode .expense-amount {
    font-size: var(--font-sm);
    font-weight: 600;
}

/* Widget button styles - smaller */
.widget-mode .btn-sm {
    padding: 6px 12px;
    font-size: var(--font-xs);
}

/* Responsive adjustments for very small screens */
@media (max-width: 360px) {
    body.widget-mode {
        --space-page-padding: 0.5rem;
    }

    .widget-mode .card {
        padding: var(--space-sm);
    }

    .widget-mode .page-title {
        font-size: var(--font-base);
    }
}