:root {
    --primary: #FF6B6B;
    --primary-hover: #fa5050;
    --secondary: #4ECDC4;
    --secondary-hover: #3bbfb6;
    --dark: #292F36;
    --light: #F7FFF7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-main: #333;
    --text-muted: #666;
    --danger: #ff4757;
    --success: #2ed573;
    --warning: #feca57;
}

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

body {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-card {
    width: 90%;
    max-width: 400px;
    padding: 40px;
    text-align: center;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 15px;
    font-weight: 600;
}

/* Header */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    color: var(--dark);
}

.logo i {
    color: var(--primary);
    font-size: 2rem;
}

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

.subtitle {
    color: var(--text-muted);
    font-weight: 500;
}

/* Dashboard */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .dashboard { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .dashboard { grid-template-columns: 1fr; }
}

.panel {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 85vh;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0,0,0,0.05);
    padding-bottom: 10px;
}

.badge {
    background: var(--dark);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Forms */
.input-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255,255,255,0.4);
    padding: 15px;
    border-radius: 15px;
}

.form-row { display: flex; gap: 10px; }
.align-bottom { align-items: flex-end; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }

input, select {
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    background: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
    width: 100%;
}

input:focus, select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
}

/* Buttons */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3); }
.secondary-btn { background: var(--secondary); color: white; box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3); }
.success-btn { background: var(--success); color: white; box-shadow: 0 4px 15px rgba(46, 213, 115, 0.3); }
.outline-btn { background: transparent; border: 1px solid var(--text-muted); color: var(--text-muted); }

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    padding: 5px;
    border-radius: 5px;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.edit { opacity: 0; }
.ing-card:hover .icon-btn.edit { opacity: 1; }
.icon-btn.edit:hover { color: var(--secondary); }

/* Item Cards */
.list-container { display: flex; flex-direction: column; gap: 15px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box input { width: 100%; padding-left: 40px; background: white; }

.items-list, .products-list { display: flex; flex-direction: column; gap: 10px; }

.ing-card {
    background: white;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary);
}
.ing-card.inter-card { border-left-color: var(--secondary); }

.ing-unit-price { font-weight: 700; color: var(--primary); font-size: 0.85rem; }
.inter-card .ing-unit-price { color: var(--secondary); }

/* Product Details */
.prod-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.prod-header {
    background: var(--dark);
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.prod-cost {
    background: var(--success);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
}
.inter-card .prod-cost { background: var(--secondary); }

.financial-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.edit-trigger {
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}
.edit-trigger i {
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.8rem;
    margin-left: 4px;
}
.financial-meta:hover .edit-trigger, .comp-item:hover .edit-trigger {
    color: var(--primary);
}
.financial-meta:hover .edit-trigger i, .comp-item:hover .edit-trigger i {
    opacity: 1;
}

.margin-pill {
    padding: 3px 8px;
    border-radius: 20px;
    color: white;
    font-size: 0.75rem;
}
.margin-safe { background: var(--success); }
.margin-warning { background: var(--warning); color: #333; }
.margin-danger { background: var(--danger); }

.components-list { padding: 10px 15px; }
.comp-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(0,0,0,0.05);
}
.comp-item:last-child { border-bottom: none; }

.comp-info { display: flex; align-items: center; gap: 8px; flex: 1; }
.comp-name { font-weight: 500; font-size: 0.85rem; }
.comp-price-box { display: flex; align-items: center; gap: 12px; }
.comp-cost-val { 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--text-muted); 
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 6px;
}

.comp-type-icon {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}
.is-inter .comp-type-icon { color: var(--secondary); }
.is-inter .comp-name { color: var(--secondary); font-weight: 600; }

.prod-actions {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Modals */
.hidden { display: none !important; }
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 50px;
    backdrop-filter: blur(5px);
}
.modal-content { width: 90%; max-width: 500px; }
.modal-header, .modal-footer { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(0,0,0,0.05); }
.modal-footer { border-bottom: none; border-top: 1px solid rgba(0,0,0,0.05); justify-content: flex-end; gap: 10px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

/* Undo Toast */
.undo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #292F36;
    color: white;
    border-radius: 14px;
    overflow: hidden;
    min-width: 280px;
    max-width: 90vw;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: opacity 0.3s, transform 0.3s;
}
.toast-hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(20px); }
.toast-visible { opacity: 1; pointer-events: all; transform: translateX(-50%) translateY(0); }

.undo-toast-bar {
    height: 3px;
    background: var(--secondary);
    width: 100%;
}
.undo-toast-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    gap: 16px;
}
.undo-toast-undo-btn {
    background: var(--secondary);
    border: none;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.undo-toast-undo-btn:hover { background: var(--secondary-hover); }
