:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --secondary: #10b981;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    padding: 1rem;
    line-height: 1.5;
}

@media (min-width: 768px) { body { padding: 2rem; } }

.container { max-width: 1200px; margin: 0 auto; }

/* Simple Clean Header */
.main-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1rem;
}

.title-area h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.title-area p { color: var(--text-muted); font-size: 0.9rem; }

.last-update-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Alert inside layout */
.alert-box {
    background: #fff1f2;
    color: var(--danger);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid #fecaca;
}

/* Toolbar Controls */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-container {
    width: 100%;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#searchInput:focus { border-color: var(--primary); }

.controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .controls-grid { grid-template-columns: 1fr 1fr auto; }
}

.control-card {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.control-label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

.date-display { font-weight: 600; color: var(--text); }

.discount-inputs { display: flex; gap: 0.5rem; align-items: center; }
.discount-inputs input {
    width: 60px;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
}

/* Button */
.btn-update {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-update:hover { opacity: 0.9; }

.btn-pdf {
    background: #dc2626;
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-pdf:hover { opacity: 0.9; }

/* Panels */
.dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .dashboard { grid-template-columns: 1fr 1fr; }
}

.panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.panel-title {
    padding: 1rem;
    background: #f1f5f9;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; border-bottom: 2px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.price { font-weight: 700; color: var(--primary); text-align: right; }
.unit { font-size: 0.7rem; color: var(--text-muted); margin-left: 0.4rem; background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 4px; }

.row-unmatched { background: #fff1f2; }

/* Polling Overlay (Simpler) */
#statusOverlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.9);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.loading-card { text-align: center; background: white; padding: 2rem; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.spinner { width: 40px; height: 40px; border: 4px solid #eee; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }