*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
}

a {
    color: #2563eb;
    text-decoration: none;
}

.is-hidden {
    display: none !important;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #111827;
    color: #e5e7eb;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar .logo {
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
}

.sidebar nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.25rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar nav a:hover {
    background: #1f2937;
}

.sidebar nav a.logout {
    margin-top: 1rem;
    color: #f97373;
}

.sidebar .user-info {
    margin-top: 2rem;
    font-size: 0.9rem;
    border-top: 1px solid rgba(249, 250, 251, 0.1);
    padding-top: 1rem;
}

.content {
    flex: 1;
    padding: 1.5rem 2rem;
}

.auth-card {
    max-width: 420px;
    margin: 3rem auto;
    background: #ffffff;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.auth-card form label {
    display: block;
    margin-bottom: 0.75rem;
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    margin-top: 0.25rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}
.btn.danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn.ghost {
    background: transparent;
    border-color: rgba(17, 24, 39, 0.2);
    color: #111827;
}

.btn.ghost {
    background: transparent;
    border-color: rgba(17, 24, 39, 0.2);
    color: #111827;
}

.btn:hover {
    filter: brightness(0.97);
}

.muted {
    color: #6b7280;
    font-size: 0.9rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
}

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

.card {
    background: #ffffff;
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.card h2 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.ocr-hint {
    margin-bottom: 1rem;
    background: linear-gradient(90deg, #eef2ff, #f8fafc);
}

.ocr-hint .status {
    margin-top: 0.25rem;
    color: #2563eb;
    font-size: 0.9rem;
}

.simple-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

.simple-list li {
    padding: 0.25rem 0;
    font-size: 0.95rem;
}

.simple-list li.done {
    text-decoration: line-through;
    color: #9ca3af;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.table thead {
    background: #f3f4f6;
}

.table th,
.table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #e5e7eb;
}

.row-open {
    background: #fff7ed;
}

.row-paid {
    background: #ecfdf3;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1rem;
    max-width: 800px;
}

.form-grid .full-row {
    grid-column: 1 / -1;
}

.form-grid label {
    font-size: 0.9rem;
}

.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="date"],
.form-grid select,
.form-grid input[type="file"] {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
}

.form-grid .checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.invoice-fields {
    display: grid;
    grid-template-columns: inherit;
    gap: inherit;
    grid-column: 1 / -1;
    background: #fff;
    border-radius: 0.75rem;
    padding: 0.75rem 0.75rem 0.5rem;
    box-shadow: inset 0 0 0 1px #e5e7eb;
}

.invoice-fields.is-hidden {
    display: none;
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.form-inline input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
}

.shopping-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.shopping-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.95rem;
}

.shopping-list li:last-child {
    border-bottom: none;
}

.shopping-list li.done span {
    text-decoration: line-through;
    color: #9ca3af;
}

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.mobile-username {
    font-weight: 600;
}

.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
}

.item-photo {
    margin-left: auto;
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        transform: translateY(-110%);
        transition: transform 0.3s ease;
        z-index: 10;
    }
    .sidebar.open {
        transform: translateY(0);
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    }
    .sidebar nav {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    .sidebar nav a {
        display: block;
    }
    .content {
        padding: 1rem;
        margin-top: 3.5rem;
    }
    .mobile-topbar {
        display: flex;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}
