:root {
    --primary: #2563eb; 
    --bg: #f8fafc; 
    --surface: #ffffff; 
    --text: #0f172a; 
    --text-muted: #64748b;
    --border: #cbd5e1; 
    --c-profit: #22c55e; 
    --c-loss: #ef4444;
    --bg-hardware: #fdf4ff;
    --border-hardware: #fae8ff;
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --bg-hardware: #2e1065;
    --border-hardware: #4c1d95;
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); margin: 0; display: flex; flex-direction: column; align-items: center; }

/* LAYOUT */
.ad-container { width: 100%; max-width: 900px; padding: 10px; box-sizing: border-box; display: flex; justify-content: center; }
.ad-top { margin-bottom: 10px; }
.ad-bottom { margin-top: 20px; }
.main-layout { display: flex; gap: 20px; justify-content: center; width: 100%; max-width: 1300px; padding: 0 10px; box-sizing: border-box; }
.ad-side { width: 160px; flex-shrink: 0; display: none; }
@media (min-width: 1200px) { .ad-side { display: block; } }
.ad-placeholder { background: #e2e8f0; border: 1px dashed #94a3b8; color: #64748b; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 0.8rem; padding: 10px; width: 100%; box-sizing: border-box; overflow: hidden; }
.ad-placeholder.skyscraper { height: 600px; }
[data-theme="dark"] .ad-placeholder { background: #334155; border-color: #475569; color: #94a3b8; }

.app-container { max-width: 900px; width: 100%; gap: 25px; display: flex; flex-direction: column; flex-grow: 1; }
.card { background: var(--surface); padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 1px solid var(--border); transition: background 0.3s; }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
h2 { margin: 0; font-size: 1.5rem; color: var(--text); font-weight: 800; }
h3 { font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin: 25px 0 15px 0; letter-spacing: 0.5px; }

/* BUTTONS */
.btn-group { display: flex; gap: 15px; margin-top: 25px; }
.btn { border: none; padding: 15px; border-radius: 8px; cursor: pointer; font-weight: 700; width: 100%; font-size: 1.1rem; transition: opacity 0.2s; white-space: nowrap; }
.btn:hover { opacity: 0.9; }
.btn-print { background: #1e293b; color: white; }
.btn-pdf { background: #2563eb; color: white; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; width: auto; background: var(--primary); color: white; border-radius: 6px; border:none; cursor: pointer; }
.btn-add { background: var(--bg); color: var(--text); border: 1px solid var(--border); padding: 10px; border-radius: 6px; width: 100%; cursor: pointer; font-weight: 600; }
.btn-add:hover { background: var(--border); }
.btn-del { background: #fee2e2; color: #dc2626; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.btn-icon { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 5px; }
.help-btn { background: var(--border); border: none; color: var(--text); border-radius: 50%; width: 16px; height: 16px; font-size: 10px; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; }
.help-btn:hover { background: var(--primary); color: white; }

/* GRIDS & INPUTS */
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; white-space: nowrap; }
.input-wrapper { position: relative; display: flex; align-items: center; }
input, select { width: 100%; padding: 9px 10px 9px 25px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; text-align: right; box-sizing: border-box; background: var(--surface); color: var(--text); }
input[type="text"] { text-align: left; padding-left: 10px; } 
select { padding-left: 10px; text-align: left; appearance: none; }
.currency-symbol { position: absolute; left: 10px; color: var(--text-muted); font-size: 0.85rem; pointer-events: none; z-index: 2; }
.calc-display { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; font-weight: 700; cursor: default; }

/* INVOICE */
#invoice-area { background: #fff; color: #0f172a; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); margin-top: 20px; border: 1px solid var(--border); }
[data-theme="dark"] #invoice-area { filter: brightness(0.9); } 
.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; border-bottom: 2px solid #0f172a; padding-bottom: 20px; flex-wrap: wrap; gap: 20px; }
.inv-title { font-size: 2rem; font-weight: 800; color: #0f172a; line-height: 1; }
.clean-input { border: none; background: transparent; font-weight: 600; color: #334155; font-size: 0.95rem; width: 100%; padding: 0; text-align: right; }
.inv-table, .margin-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 0.9rem; border: 1px solid #e2e8f0; }
.inv-table th, .margin-table th { text-align: left; border-bottom: 2px solid #e2e8f0; padding: 10px 5px; color: #64748b; font-weight: 700; background: #f8fafc; }
.inv-table td, .margin-table td { border-bottom: 1px solid #f1f5f9; padding: 12px 5px; color: #334155; }
.margin-custom { background: #eff6ff; font-weight: 700; border-left: 3px solid var(--primary); }
.profit-pos { color: var(--c-profit); font-weight: 700; }
.profit-neg { color: var(--c-loss); font-weight: 700; }
.screen-only { display: block; }
.section-box { background: var(--bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 15px; }
.lib-row { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dashed var(--border); }

/* MODAL */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: var(--surface); color: var(--text); margin: 15% auto; padding: 20px; border: 1px solid var(--border); width: 80%; max-width: 400px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.close-btn { color: var(--text-muted); float: right; font-size: 28px; font-weight: bold; cursor: pointer; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .header-row { flex-direction: column; align-items: flex-start; }
    .lib-row { flex-direction: column; align-items: flex-start; }
    .lib-row select, .lib-row button { width: 100%; }
    .inv-header { flex-direction: column; }
    .inv-header > div { width: 100%; text-align: left; }
    .inv-header input { text-align: left; }
    .ad-side { display: none; }
    .btn-group { flex-direction: column; }
}

/* === PRINT STYLES === */
@media print {
    body { background: white !important; color: black !important; margin: 0; padding: 0; -webkit-print-color-adjust: exact; }
    .card, .ad-container, .btn-group, .ad-side, .header-row, h3, h2, .section-box, .help-btn, .modal, .screen-only, details { display: none !important; }
    #invoice-area { display: block !important; box-shadow: none; border: none; margin: 0; padding: 0; width: 100%; position: absolute; top: 0; left: 0; filter: none !important; }
    :root { --text: #000; --text-muted: #333; --border: #ccc; }
}
/* ... Previous CSS ... */

/* === FOOTER STYLES === */
.app-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.footer-nav button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: underline;
    padding: 0;
}

.footer-nav button:hover {
    color: var(--text);
}

.footer-nav .sep { color: var(--border); }

.footer-section {
    display: none; /* Hidden by default */
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: left;
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.footer-section h4 {
    margin-top: 0;
    color: var(--text);
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 20px;
}

/* Print Logic: Hide Footer */
@media print {
    .app-footer { display: none !important; }
}
/* ... [Previous CSS] ... */

/* === COOKIE BANNER === */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: #1e293b;
    color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 9999;
    display: none; /* Hidden by default, JS shows it */
    border: 1px solid #334155;
}

.cookie-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.cookie-content p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.cookie-btns {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.btn-accept { background: var(--primary); color: white; border: none; }
.btn-decline { background: transparent; border: 1px solid #64748b; color: #cbd5e1; }
.btn-decline:hover { background: #334155; }

/* Mobile Stack for Cookie Banner */
@media (max-width: 600px) {
    .cookie-content { flex-direction: column; text-align: left; }
    .cookie-btns { width: 100%; justify-content: flex-end; }
}