:root {
    --primary: #FF6B35;
    --primary-dark: #E85A2A;
    --secondary: #8BC34A;
    --bg-color: #F8F9FA;
    --surface: #FFFFFF;
    --text-main: #2D3748;
    --text-muted: #718096;
    --border: #E2E8F0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
}
body.menu-open { overflow: hidden; }

/* Utilities */
.hidden { display: none !important; }

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn.small { padding: 6px 12px; font-size: 13px; }

.primary-btn {
    background-color: var(--primary);
    color: white;
}
.primary-btn:hover { background-color: var(--primary-dark); transform: translateY(-1px); }

.outline-btn {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}
.outline-btn:hover { background-color: #edf2f7; }

.danger-btn {
    background-color: #fee2e2;
    color: #ef4444;
}
.danger-btn:hover { background-color: #fecaca; }

/* Login Screen */
.screen {
    min-height: 100vh;
    width: 100%;
}
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff0eb 0%, #f4fbef 100%);
}
.login-container {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.logo-area {
    margin-bottom: 30px;
}
.logo-area i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 10px;
}
.logo-area h2 {
    color: var(--text-main);
    font-weight: 700;
}
.form-group {
    margin-bottom: 20px;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
#loginBtn { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }
.login-error {
    margin-top: 12px;
    color: #dc2626;
    font-size: 13px;
    line-height: 1.4;
}
.login-help {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Dashboard Layout */
.layout {
    display: flex;
}
.sidebar {
    width: 260px;
    background: var(--surface);
    height: 100vh;
    position: fixed;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1200;
    transition: transform 0.25s ease;
}
.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header i { font-size: 24px; color: var(--primary); }
.sidebar-nav {
    padding: 24px 12px;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-item:hover {
    background: #f1f5f9;
    color: var(--text-main);
}
.nav-item.active {
    background: #fff0eb;
    color: var(--primary);
}
.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
}
.sidebar-footer .btn { width: 100%; justify-content: center; }

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}
.top-header {
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.mobile-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}
.sidebar-close { margin-left: auto; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.48);
    z-index: 1100;
}

/* Views */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}
.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.recipe-icon { background: #fff0eb; color: var(--primary); }
.cat-icon { background: #f4fbef; color: var(--secondary); }
.stat-details h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.stat-details p { font-size: 28px; font-weight: 700; color: var(--text-main); }

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
}
.data-table td { font-size: 14px; vertical-align: middle; }
.recipe-img-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

/* Categories List */
.inline-form { display: flex; gap: 12px; }
.list-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.full-width { grid-column: 1 / -1; }
.form-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.form-section h3 { margin-bottom: 16px; font-size: 16px; color: var(--text-main); }

.dynamic-list { margin-bottom: 12px; }
.dynamic-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}
.dynamic-row input { flex: 1; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: var(--text-main);
}
.checkbox-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
}

.image-preview {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}
.image-preview img {
    width: 96px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.modal-footer {
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.save-status {
    margin-right: auto;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.35;
}
.save-status.error { color: #dc2626; }
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #334155;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    z-index: 2000;
    transition: opacity 0.3s;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 12px 0 30px rgba(15, 23, 42, 0.18);
    }
    body.menu-open .sidebar { transform: translateX(0); }
    body.menu-open .sidebar-overlay { display: block; }
    .mobile-menu-btn { display: inline-flex; }
    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 24px;
    }
    .top-header { margin-bottom: 24px; }
    .top-header h1 { font-size: 26px; }
    .view-header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }
    .inline-form {
        width: 100%;
    }
    .inline-form input {
        flex: 1;
        min-width: 0;
    }
    .view-header > .btn { align-self: flex-start; }
}

@media (max-width: 600px) {
    .login-container {
        max-width: none;
        margin: 16px;
        padding: 28px 20px;
    }
    .main-content { padding: 16px; }
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .stat-card { padding: 18px; }
    .inline-form {
        flex-direction: column;
    }
    .inline-form .btn,
    .view-header > .btn {
        width: 100%;
        justify-content: center;
    }
    .list-item { padding: 14px 16px; }
    .modal {
        padding: 0;
        align-items: stretch;
    }
    .modal-content {
        max-width: none;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
    }
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 16px;
        background: var(--surface);
    }
    .modal-body { padding: 16px; }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .full-width { grid-column: auto; }
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 46px;
        font-size: 16px;
    }
    .dynamic-row { gap: 8px; }
    .dynamic-row .danger-btn { padding: 10px 13px; }
    .modal-footer {
        position: sticky;
        bottom: -16px;
        z-index: 2;
        margin-inline: -16px;
        padding: 14px 16px;
        background: var(--surface);
        box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.08);
        flex-wrap: wrap;
    }
    .save-status {
        width: 100%;
        margin: 0;
        text-align: center;
    }
    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        text-align: center;
    }
}
