:root {
    --bg: #f8f6f1;
    --card: #ffffff;
    --text: #2d2a26;
    --text-muted: #6b6660;
    --accent: #c45d3a;
    --accent-hover: #a84d30;
    --border: #e8e4de;
    --success: #4a7c59;
    --warning: #d4a029;
    --danger: #c62828;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.hidden { display: none !important; }

/* Auth */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg) 0%, #ebe7df 100%);
}

.auth-box {
    background: var(--card);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(45, 42, 38, 0.12);
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    font-family: 'Fraunces', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: block;
    text-align: center;
    margin-bottom: 2rem;
}

.auth-tabs, .setup-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.auth-tab, .setup-tab {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    font-family: inherit;
}

.auth-tab.active, .setup-tab.active { color: var(--accent); }

.auth-tab.active::after, .setup-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.setup-welcome {
    text-align: center;
    margin-bottom: 2rem;
}

.setup-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.setup-welcome h1 {
    font-family: 'Fraunces', serif;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

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

/* Forms */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: white;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-block { width: 100%; }

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-secondary:hover { background: var(--border); }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem;
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
    font-family: inherit;
}

.btn-link:hover { text-decoration: underline; }

.auth-message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.auth-message.error { background: #fce8e8; color: var(--danger); }
.auth-message.success { background: #e8f5e9; color: var(--success); }

/* App */
.app { min-height: 100vh; }

header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    font-family: 'Fraunces', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.house-selector select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    min-width: 180px;
    cursor: pointer;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { background: var(--border); }

.btn-logout {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.btn-logout:hover { background: var(--border); }

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tab {
    padding: 0.75rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    font-family: inherit;
}

.tab:hover { border-color: var(--accent); }

.tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.tab-count {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.tab:not(.active) .tab-count {
    background: var(--bg);
    color: var(--text-muted);
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title { font-family: 'Fraunces', serif; font-size: 1.5rem; }

.section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-export {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.btn-export:hover {
    background: var(--border);
}

.btn-add {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-add:hover { background: var(--accent-hover); }

/* Cards */
.cards { display: grid; gap: 1rem; }

.card {
    background: var(--card);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(45, 42, 38, 0.08);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.card-title { font-weight: 600; font-size: 1.1rem; }

.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-body {
    color: var(--text-muted);
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.card-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.card-btn:hover { background: var(--border); }

.card-btn.danger:hover {
    background: #fce8e8;
    border-color: #e57373;
    color: var(--danger);
}

/* Members */
.member-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.member-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.member-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.member-name { font-weight: 500; }

.member-email {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.member-role {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: var(--bg);
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.member-role.owner {
    background: #e3f2fd;
    color: #1565c0;
}

/* Status */
.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-unpaid { background: #fef3e2; color: #b8860b; }
.status-paid { background: #e8f5e9; color: var(--success); }
.status-pending { background: #fff3e0; color: #e65100; }
.status-in-progress { background: #e3f2fd; color: #1565c0; }
.status-complete { background: #e8f5e9; color: var(--success); }

.due-date { font-size: 0.85rem; color: var(--text-muted); }
.due-date.overdue { color: var(--danger); font-weight: 500; }
.due-date.soon { color: var(--warning); font-weight: 500; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.filter-tab:hover {
    background: var(--border);
}

.filter-tab.active {
    background: var(--text);
    color: white;
    border-color: var(--text);
}

/* File displays */
.current-file {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.current-file a {
    color: var(--accent);
    text-decoration: none;
}

.current-file a:hover {
    text-decoration: underline;
}

.current-images {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.current-images img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.file-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
}

.file-attachment a {
    color: var(--accent);
    text-decoration: none;
}

.file-attachment a:hover {
    text-decoration: underline;
}

.card-images {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.card-images img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border);
}

.card-images img:hover {
    opacity: 0.9;
}

/* Unread indicator */
.card.unread {
    border-left: 3px solid var(--accent);
}

.unread-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: 0.5rem;
}

.house-tag {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.filter-tab:hover {
    border-color: var(--accent);
}

.filter-tab.active {
    background: var(--text);
    color: white;
    border-color: var(--text);
}

/* File displays */
.current-file {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
}

.current-file a {
    color: var(--accent);
}

.current-images {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.current-images img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--accent);
    font-size: 0.85rem;
    text-decoration: none;
    margin-top: 0.5rem;
}

.file-link:hover {
    text-decoration: underline;
}

.image-thumbnails {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.image-thumbnails img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border);
}

.image-thumbnails img:hover {
    border-color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--card);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { font-family: 'Fraunces', serif; font-size: 1.25rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.house-code-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

.house-code-box code {
    flex: 1;
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    font-family: monospace;
    word-break: break-all;
    text-align: center;
}

.settings-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.settings-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-danger {
    border-color: #f5c6c6;
}

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

.btn-danger:hover {
    background: #a62020;
}

/* Responsive */
@media (max-width: 600px) {
    .header-inner { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .header-left { justify-content: space-between; }
    .header-right { justify-content: flex-end; }
    .user-name { display: none; }
    .tabs { gap: 0.375rem; }
    .tab { padding: 0.625rem 0.875rem; font-size: 0.85rem; }
    .auth-box { padding: 1.5rem; }
    .house-selector select { min-width: 140px; }
}
