:root {
    --primary: #16a34a;
    --primary-light: #dcfce7;
    --primary-dark: #15803d;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
}
body.theme-estimate { --primary: #ea580c; --primary-light: #ffedd5; --primary-dark: #c2410c; }
body.theme-invoice { --primary: #0284c7; --primary-light: #e0f2fe; --primary-dark: #0369a1; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); padding: 20px; line-height: 1.5; }
.container { max-width: 1100px; margin: 0 auto; }

/* HEADER */
.app-header { background: var(--primary); color: white; padding: 20px 24px; border-radius: 12px; margin-bottom: 20px; }
.app-header-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.app-logo { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.app-subtitle { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.doc-type-tabs { display: flex; gap: 6px; background: rgba(255,255,255,0.2); padding: 4px; border-radius: 8px; }
.doc-type-tabs button { background: transparent; border: none; color: white; padding: 8px 16px; border-radius: 6px; font-weight: 600; font-size: 12px; cursor: pointer; }
.doc-type-tabs button.active { background: white; color: var(--primary); }
.doc-number-bar { background: rgba(255,255,255,0.15); padding: 8px 12px; border-radius: 6px; margin-top: 12px; font-size: 12px; }
.doc-number-bar strong { display: block; font-size: 14px; margin-top: 2px; }

/* LAYOUT */
.main-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 850px) { .main-grid { grid-template-columns: 1fr; } }

/* CARDS */
.card { background: var(--card); border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 12px; color: var(--muted); }
.section-label { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.5px; margin-bottom: 8px; }

/* FORMS */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-row.full { grid-template-columns: 1fr; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; background: #fafafa; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: white; }

/* SERVICES GRID */
.services-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 600px) { .services-grid { grid-template-columns: repeat(2, 1fr); } }
.service-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: 0.15s; background: white; display: flex; flex-direction: column; justify-content: space-between; }
.service-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }
.service-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 2px var(--primary); }
.service-card-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.service-card-price { color: var(--primary); font-weight: 700; font-size: 14px; }

/* SELECTED LIST */
.selected-list { border-top: 1px solid var(--border); padding-top: 12px; }
.selected-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.selected-item:last-child { border-bottom: none; }
.selected-item-name { font-weight: 500; font-size: 14px; }
.selected-item-price { font-weight: 700; color: var(--primary); cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.selected-item-price:hover { background: var(--primary-light); }
.selected-item-price input { width: 70px; text-align: right; padding: 4px; margin: 0; }
.delete-btn { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px; }
.delete-btn:hover { color: var(--danger); }

/* SIDEBAR */
.total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.total-row.grand { border-top: 2px solid var(--border); margin-top: 8px; padding-top: 12px; font-size: 18px; font-weight: 800; }
.total-row.grand .total-value { color: var(--primary); }
.btn { width: 100%; padding: 12px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; font-family: inherit; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* SEARCH */
.search-container { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; max-height: 200px; overflow-y: auto; z-index: 100; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.autocomplete-item { padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); font-size: 13px; }
.autocomplete-item:hover { background: var(--primary-light); }
.autocomplete-item:last-child { border-bottom: none; }

/* ============================================ */
/* PRINT / PDF STYLES (Professional Decal Style) */
/* ============================================ */
.print-document { display: none; padding: 40px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #111; }
.print-header { display: flex; justify-content: space-between; margin-bottom: 30px; border-bottom: 2px solid #111; padding-bottom: 20px; }
.print-left { flex: 1; }
.print-title { font-size: 28px; font-weight: 800; margin: 0; color: var(--primary); letter-spacing: -0.5px; }
.print-meta { font-size: 13px; color: #444; margin: 4px 0; }
.print-right { text-align: right; flex: 1; }
.print-biz-name { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.print-biz-info { font-size: 12px; color: #555; line-height: 1.5; }

.print-bill-to { margin-bottom: 25px; padding: 15px; background: #f8f9fa; border-radius: 6px; }
.print-bill-to h3 { font-size: 12px; text-transform: uppercase; color: #666; margin-bottom: 6px; letter-spacing: 0.5px; }
#print-customer-details { font-size: 14px; font-weight: 500; line-height: 1.5; }

.print-table { width: 100%; border-collapse: collapse; margin-bottom: 25px; }
.print-table th { text-align: left; padding: 10px 0; border-bottom: 2px solid #111; font-size: 12px; text-transform: uppercase; color: #444; font-weight: 600; }
.print-table td { padding: 12px 0; border-bottom: 1px solid #eee; font-size: 14px; }
.th-price { text-align: right !important; width: 120px; }
.print-table td:last-child { text-align: right; font-weight: 600; }

.print-totals { width: 280px; margin-left: auto; margin-bottom: 30px; }
.print-total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: #333; }
.print-total-row.grand { border-top: 2px solid #111; margin-top: 8px; padding-top: 10px; font-size: 18px; font-weight: 800; color: #111; }

.print-notes { margin-bottom: 30px; padding: 12px; background: #f8f9fa; border-radius: 6px; font-size: 12px; color: #444; line-height: 1.5; }
.print-notes strong { display: block; margin-bottom: 4px; color: #111; }

.print-footer { text-align: center; font-size: 13px; font-weight: 600; color: var(--primary); padding-top: 20px; border-top: 1px solid #eee; margin-top: 20px; }

@media print {
    @page { margin: 15mm; size: letter; }
    body { background: white; padding: 0; margin: 0; }
    .no-print { display: none !important; }
    .print-document { display: block !important; }
    .container { max-width: 100%; padding: 0; margin: 0; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}


@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}