/* /styles/primary.css */

:root {
    --ink: #0f1e2e; --paper: #f0f4f9; --cream: #e2eaf3;
    --blue: #2563eb; --blue-dark: #1d4ed8; --blue-bg: #e8f0fb; --blue-border: #a8c4ed;
    --green: #16a34a; --green-bg: #eaf5ee; --green-border: #a8d9be;
    --rust: #dc2626; --red: #c0392b; --red-bg: #fdecea; --red-border: #f0b0a8;
    --muted: #5a7490; --text2: #6b6965; --text3: #9c9894;
    --purple: #4a3fb0; --purple-bg: #eeedfe; --purple-border: #b0a9ed;
    --orange: #c05a10; --orange-bg: #fef0e0; --orange-border: #f0c890;
    --yellow: #7a6a00; --yellow-bg: #fefce8; --yellow-border: #e8d840;
    --card: #ffffff; --bg: #ffffff; --bg2: #f5f5f4; --bg3: #e8e7e5;
    --border: rgba(15,30,46,0.1); --border2: #c4c2be;
    --shadow: 0 2px 12px rgba(15,30,46,0.08), 0 1px 3px rgba(15,30,46,0.06);
    --shadow-lg: 0 8px 32px rgba(15,30,46,0.14), 0 2px 8px rgba(15,30,46,0.08);
    --radius: 8px; --radius-sm: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--paper); color: var(--ink); min-height: 100vh; padding-bottom: 80px; }

/* ── HEADER ── */
.header { background: linear-gradient(135deg, #0f1e2e 0%, #1e3a5f 100%); color: white; padding: 20px 16px 0; position: sticky; top: 0; z-index: 100; border-bottom: 3px solid var(--blue); box-shadow: var(--shadow); }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; max-width: 1200px; margin-left: auto; margin-right: auto; }
.logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 26px; letter-spacing: -1px; color: white; text-transform: uppercase; }
.logo span { color: #60a5fa; }
.deal-count { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.5); letter-spacing: 1px; text-transform: uppercase; }

.data-btns { display: flex; gap: 8px; padding: 0 16px 14px; max-width: 1200px; margin: 0 auto; }
.btn-export { flex: 1; padding: 9px 12px; border-radius: 9px; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s; background: rgba(255,255,255,0.1); border: 1.5px solid rgba(255,255,255,0.25); color: rgba(255,255,255,0.85); }
.btn-export:hover { background: rgba(255,255,255,0.18); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: #0f1e2e; color: white; padding: 12px 20px; border-radius: 100px; font-size: 13px; font-weight: 600; z-index: 999; transition: transform 0.3s, opacity 0.3s; opacity: 0; white-space: nowrap; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.tab-nav { display: flex; margin-bottom: -3px; overflow-x: auto; scrollbar-width: none; max-width: 1200px; margin-left: auto; margin-right: auto; }
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn { flex: 1; min-width: max-content; padding: 10px 12px; background: transparent; border: none; color: rgba(255,255,255,0.5); font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s; white-space: nowrap; }
.tab-btn.active { color: white; border-bottom-color: #60a5fa; }
.tab-btn.finance-tab.active { border-bottom-color: var(--green); }

/* ── LAYOUT FIX: Contains the dashboard grids ── */
.tab-panel { display: none; padding-top: 20px; max-width: 1200px; margin: 0 auto; }
.tab-panel.active { display: block; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 0 16px 16px; box-shadow: var(--shadow); }
.panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

/* ── FILTER PILLS FIX (Light Background) ── */
.filter-bar { display: flex; gap: 8px; padding: 0 16px 16px; overflow-x: auto; scrollbar-width: none; }
.pill { flex-shrink: 0; padding: 7px 16px; border-radius: 100px; font-size: 12px; font-weight: 600; border: 1.5px solid var(--border); color: var(--muted); background: var(--card); cursor: pointer; transition: all 0.2s; white-space: nowrap; box-shadow: var(--shadow); }
.pill:hover { border-color: var(--blue-border); color: var(--ink); }
.pill.active { background: var(--blue); border-color: var(--blue); color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }

/* ── DEALFLOW CRM CSS ── */
.stats-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); margin: 0 16px 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.stat { background: var(--card); padding: 12px 8px; text-align: center; }
.stat-value { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 22px; color: var(--ink); line-height: 1; }
.stat-label { font-size: 10px; font-weight: 500; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
.add-btn { display: flex; align-items: center; gap: 8px; margin: 0 16px 16px; padding: 14px 20px; background: var(--blue); border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600; color: white; cursor: pointer; width: calc(100% - 32px); justify-content: center; box-shadow: 0 4px 12px rgba(37,99,235,0.35); }
.deals-list { padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.deal-card { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.deal-card.closed-card { border-left: 4px solid var(--green); }
.deal-header { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.deal-address { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; line-height: 1.25; color: var(--ink); }
.status-badge { padding: 4px 10px; border-radius: 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-pre { background: #e8f0fe; color: #3b5bdb; } .badge-active { background: #d3f9d8; color: #2f6a3a; } .badge-contract { background: #fff3cd; color: #856404; } .badge-closed { background: #dcfce7; color: #15803d; }
.deal-body { padding: 12px 16px; }
.deal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.deal-field { background: var(--paper); border-radius: 8px; padding: 8px 10px; }
.field-label { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.field-value { font-size: 14px; font-weight: 500; color: var(--ink); }
.checklist-row { display: flex; gap: 8px; margin-bottom: 10px; }
.check-item { display: flex; align-items: center; gap: 5px; font-size: 12px; background: var(--paper); padding: 5px 10px; border-radius: 8px; flex: 1; justify-content: center; border: 1px solid var(--border); }
.check-item.done { color: var(--blue-dark); background: #dbeafe; border-color: #bfdbfe; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; background: #eff6ff; border-radius: 8px; border: 1px solid #bfdbfe; margin-bottom: 5px; cursor: pointer; }
.card-actions { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--border); }
.btn-close-deal { flex: 2; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 700; border: none; cursor: pointer; background: var(--green); color: white; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-edit { flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; background: var(--ink); color: white; }

/* ── FINANCE CSS (From Portfolio Tracker) ── */
.card-grid { display: grid; gap: 12px; margin: 0 16px 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media(max-width:700px){ .g4{grid-template-columns:1fr 1fr;} .g3{grid-template-columns:1fr 1fr;} }
@media(max-width:480px){ .g2,.g3,.g4{grid-template-columns:1fr;} }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; font-weight: 600; }
.stat-card .value { font-size: 20px; font-weight: 700; line-height: 1.1; font-family: 'Syne', sans-serif; }
.stat-card .sub { font-size: 11px; color: var(--text3); margin-top: 3px; }
.green { color: var(--green); } .red { color: var(--rust); } .orange { color: var(--orange); } .blue { color: var(--blue); }

.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; font-size: 11px; color: var(--muted); font-weight: 700; background: var(--paper); border-bottom: 1px solid var(--border); text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.paid td { opacity: .5; }
tr.current td { background: var(--blue-bg); }

.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 13px; margin: 0 16px 14px; line-height: 1.5; }
.alert-green { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.alert-blue { background: var(--blue-bg); border: 1px solid var(--blue-border); color: var(--blue); }
.alert-purple { background: var(--purple-bg); border: 1px solid var(--purple-border); color: var(--purple); }

.prop-select { display: flex; gap: 10px; margin-bottom: 16px; }
.prop-btn { flex: 1; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 13px; font-weight: 600; text-align: center; color: var(--muted); font-family: 'DM Sans', sans-serif; }
.prop-btn.sel55 { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }
.prop-btn.sel52 { background: var(--green-bg); border-color: var(--green); color: var(--green); }

.ysq-wrap { overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; scrollbar-width: none; }
.ysq-row { display: flex; gap: 10px; min-width: max-content; }
.ysq { min-width: 155px; width: max-content; flex-shrink: 0; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: relative; box-shadow: var(--shadow); }
.ysq.cur { background: var(--green-bg); border-color: var(--green-border); }
.ysq.fut { opacity: .6; }
.ysq .ysq-yr { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.ysq.cur .ysq-yr { color: var(--green); }
.ysq .ysq-amt { font-size: 22px; font-weight: 800; font-family: 'Syne', sans-serif; color: var(--ink); margin-bottom: 6px; line-height: 1; white-space: nowrap; }
.ysq .ysq-pills { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.pill-sq { display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 600; }
.pill-52 { background: var(--green-bg); color: var(--green); } .pill-55 { background: var(--purple-bg); color: var(--purple); }
.ysq-badge { display: inline-block; margin-top: 6px; font-size: 9px; padding: 2px 6px; border-radius: 3px; font-weight: 700; }
.ysq-badge.ok { background: var(--green-bg); color: var(--green); }
.ysq-badge.partial { background: var(--orange-bg); color: var(--orange); }

.prog-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.prog-bar { flex: 1; height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.prog-fill { height: 100%; border-radius: 3px; }
.pf-55 { background: var(--purple); } .pf-52 { background: var(--green); } .pf-gift { background: #7F77DD; }

.badge-fin { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.b-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.b-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }

/* ── MODALS & FORMS (RESTORED) ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 200; display: flex; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.25s; backdrop-filter: blur(4px); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--card); width: 100%; border-radius: 24px 24px 0 0; max-height: 92vh; overflow-y: auto; transform: translateY(100%); transition: transform 0.3s; padding-bottom: env(safe-area-inset-bottom, 16px); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 16px 20px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; background: var(--cream); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--muted); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.form-input, .form-select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-family: 'DM Sans', sans-serif; font-size: 15px; color: var(--ink); background: var(--paper); outline: none; transition: border-color 0.2s; }
.btn-save { padding: 15px; background: var(--blue); color: white; border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.15s; }
.btn-cancel { padding: 15px; background: var(--cream); color: var(--muted); border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 700; cursor: pointer; }
.form-grid { display: grid; gap: 12px; } .fg2 { grid-template-columns: 1fr 1fr; } .fg3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── DETAIL MODAL (RESTORED) ── */
.detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; display: flex; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.25s; backdrop-filter: blur(4px); }
.detail-overlay.open { opacity: 1; pointer-events: all; }
.detail-modal { background: var(--card); width: 100%; border-radius: 24px 24px 0 0; max-height: 90vh; overflow-y: auto; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.34,1.2,0.64,1); padding-bottom: env(safe-area-inset-bottom, 20px); }
.detail-overlay.open .detail-modal { transform: translateY(0); }
.detail-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.detail-address { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); line-height: 1.3; }
.detail-client { font-size: 13px; color: var(--muted); margin-top: 4px; }
.detail-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.detail-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--blue); margin-bottom: 12px; }

/* ── CONFIRM MODAL (RESTORED) ── */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; pointer-events: none; transition: opacity 0.2s; backdrop-filter: blur(6px); }
.confirm-overlay.open { opacity: 1; pointer-events: all; }
.confirm-box { background: white; border-radius: 20px; padding: 28px 24px 20px; width: 100%; max-width: 340px; text-align: center; transform: scale(0.9); transition: transform 0.2s cubic-bezier(0.34,1.2,0.64,1); box-shadow: var(--shadow-lg); }
.confirm-overlay.open .confirm-box { transform: scale(1); }
.confirm-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 20px; margin-bottom: 8px; color: var(--ink); }
.confirm-msg { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 20px; }
.confirm-address { font-weight: 700; color: var(--ink); }
.confirm-btns { display: flex; gap: 10px; }
.confirm-yes { flex: 2; padding: 14px; background: var(--green); color: white; border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 700; cursor: pointer; }
.confirm-no { flex: 1; padding: 14px; background: var(--cream); color: var(--muted); border: none; border-radius: 12px; font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 600; cursor: pointer; }

/* ── DEV DRAWER ── */
.dev-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw; background: #0f1e2e; color: #a8c4ed; z-index: 9999; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -4px 0 24px rgba(0,0,0,0.5); display: flex; flex-direction: column; }
.dev-drawer.open { transform: translateX(0); }
.dev-drawer-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.dev-drawer-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; color: white; }
.dev-drawer-close { background: none; border: none; color: #a8c4ed; font-size: 24px; cursor: pointer; line-height: 1; padding: 0; }
.dev-drawer-close:hover { color: white; }
.dev-drawer-content { padding: 20px; overflow-y: auto; flex: 1; }
.api-card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.api-method { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 800; text-transform: uppercase; margin-right: 8px; }
.api-method.get { background: #dcfce7; color: #15803d; }
.api-method.post { background: #dbeafe; color: #1d4ed8; }
.api-method.patch { background: #fef08a; color: #a16207; }
.api-method.delete { background: #fee2e2; color: #b91c1c; }
.api-endpoint { font-family: monospace; font-size: 13px; color: white; }
.api-desc { font-size: 12px; color: rgba(168,196,237,0.7); margin: 8px 0; line-height: 1.4; }
.api-test-btn { width: 100%; padding: 8px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 6px; color: white; font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.2s; font-family: 'DM Sans', sans-serif; }
.api-test-btn:hover { background: rgba(255,255,255,0.2); }

/* ── IRS FORM 1098 GENERATOR ── */
.tax-controls { display: flex; gap: 12px; margin-bottom: 24px; background: var(--paper); padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.tax-document { background: white; width: 100%; max-width: 850px; margin: 0 auto; border: 2px solid black; color: black; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.tax-header { display: grid; grid-template-columns: 1fr 120px; border-bottom: 2px solid black; }
.tax-title { padding: 12px; }
.tax-title h1 { font-size: 28px; font-weight: 900; margin: 0; letter-spacing: -0.5px; }
.tax-title h2 { font-size: 14px; font-weight: 700; margin: 4px 0 0 0; }
.tax-year-box { display: flex; flex-direction: column; justify-content: center; align-items: center; border-left: 2px solid black; }
.tax-year-text { font-size: 32px; font-weight: 900; }
.tax-year-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; }

.tax-grid { display: grid; grid-template-columns: 1fr 1fr; }
.tax-col-left { border-right: 2px solid black; }
.tax-box { border-bottom: 1px solid black; padding: 6px 8px; min-height: 60px; position: relative; }
.tax-box:last-child { border-bottom: none; }
.tax-box-label { font-size: 10px; font-weight: 700; text-transform: uppercase; display: block; margin-bottom: 4px; }
.tax-box-value { font-size: 14px; font-family: monospace; font-weight: 600; display: block; }
.tax-box-value.large { font-size: 18px; }

.tax-grid-right { display: grid; grid-template-columns: 1fr 1fr; }
.tax-box-right { border-bottom: 1px solid black; border-right: 1px solid black; padding: 6px 8px; min-height: 60px; }
.tax-box-right:nth-child(even) { border-right: none; }

.tax-footer { padding: 12px; border-top: 2px solid black; font-size: 11px; text-align: center; font-weight: 600; }

/* ── PRINT MEDIA QUERY (Crucial for PDFs) ── */
@media print {
    body * { visibility: hidden; }
    body { background: white; padding: 0; margin: 0; }
    #printable1098, #printable1098 * { visibility: visible; }
    #printable1098 { position: absolute; left: 0; top: 0; width: 100%; margin: 0; border: none; }
    .header, .tab-nav, .tax-controls, .toast, .modal-overlay, .dev-drawer { display: none !important; }
}