/* ============================================
   IMPORT BUSINESS ANALYTICS v2.0
   Desktop-First, High Information Density
   Multi-Product, Dark Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-card: #151d2e;
    --bg-input: #0d1320;
    --border-color: #1e2d45;
    --border-light: #253552;
    --text-primary: #e2e8f0;
    --text-secondary: #8899b4;
    --text-muted: #5a6d8a;
    --accent-blue: #3b82f6;
    --accent-blue-dim: #2563eb;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --profit-green: #22c55e;
    --loss-red: #ef4444;
    --highlight: rgba(59, 130, 246, 0.08);
    --row-hover: rgba(59, 130, 246, 0.05);
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --radius-sm: 4px;
    --radius-md: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 13px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; line-height: 1.4; }

/* ── Header ── */
.top-header { background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); padding: 8px 20px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.top-header h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.top-header h1 span { color: var(--accent-blue); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-green); display: inline-block; margin-right: 4px; }
.header-actions .status-text { font-size: 11px; color: var(--text-muted); margin-right: 12px; }
.header-actions a { text-decoration: none; }

/* ── Nav Tabs ── */
.nav-tabs { background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: flex; padding: 0 16px; overflow-x: auto; }
.nav-tabs button { background: none; border: none; color: var(--text-muted); font-family: var(--font-body); font-size: 12px; font-weight: 500; padding: 9px 16px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: all 0.15s; }
.nav-tabs button:hover { color: var(--text-secondary); background: var(--row-hover); }
.nav-tabs button.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ── Tab Content ── */
.tab-content { display: none; padding: 16px 20px; }
.tab-content.active { display: block; }

/* ── Sections ── */
.section-title { font-size: 13px; font-weight: 700; padding: 8px 0 6px; border-bottom: 1px solid var(--border-color); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Cards ── */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; }
.card-header { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ── KPI Strip ── */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi-box { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 10px 12px; }
.kpi-box .kpi-label { font-size: 10px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.kpi-box .kpi-value { font-family: var(--font-mono); font-size: 16px; font-weight: 700; }
.kpi-box.positive .kpi-value { color: var(--profit-green); }
.kpi-box.negative .kpi-value { color: var(--loss-red); }
.kpi-box.accent .kpi-value { color: var(--accent-blue); }
.kpi-box.warning .kpi-value { color: var(--accent-yellow); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
table th { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; }
table th.r, table td.r { text-align: right; }
table td { padding: 6px 10px; border-bottom: 1px solid rgba(30, 45, 69, 0.5); }
table tr:hover td { background: var(--row-hover); }
table td.mono { font-family: var(--font-mono); font-size: 12px; }
table td.positive { color: var(--profit-green); }
table td.negative { color: var(--loss-red); }
table td.bold { font-weight: 700; }
table tr.total-row td { background: var(--bg-tertiary); font-weight: 700; border-top: 2px solid var(--border-light); border-bottom: 2px solid var(--border-light); }
table tr.subtotal-row td { background: rgba(59, 130, 246, 0.04); font-weight: 600; border-top: 1px solid var(--border-light); }
table tr.separator-row td { padding: 2px; border: none; }
table tr.highlight-row td { background: var(--highlight); }
table tr.group-header td { font-weight: 700; color: var(--accent-blue); background: rgba(59, 130, 246, 0.04); border-bottom: 1px solid var(--border-color); padding-top: 10px; }
table tr.net-profit td { font-weight: 800; font-size: 13px; background: var(--bg-tertiary); border-top: 2px solid var(--accent-blue); border-bottom: 2px solid var(--accent-blue); }

/* ── Param Grid ── */
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }
.param-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--radius-sm); background: var(--bg-primary); border: 1px solid transparent; }
.param-row:hover { border-color: var(--border-color); }
.param-row label { flex: 1; font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.param-row input { width: 100px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-mono); font-size: 12px; padding: 4px 8px; text-align: right; outline: none; transition: border-color 0.15s; }
.param-row input[type="text"] { width: 160px; text-align: left; }
.param-row input:focus { border-color: var(--accent-blue); }
.param-row .unit { font-size: 10px; color: var(--text-muted); min-width: 50px; text-align: left; }

/* ── Buttons ── */
.btn { font-family: var(--font-body); font-size: 11px; font-weight: 600; padding: 6px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); cursor: pointer; background: var(--bg-tertiary); color: var(--text-secondary); transition: all 0.15s; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--border-color); color: var(--text-primary); }
.btn-primary { background: var(--accent-blue-dim); border-color: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: var(--accent-blue); }
.btn-danger { background: rgba(239,68,68,0.15); border-color: var(--accent-red); color: var(--accent-red); }
.btn-danger:hover { background: rgba(239,68,68,0.3); }
.btn-sm { padding: 4px 10px; font-size: 10px; }
.btn-group { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }

/* ── Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

/* ── Product Tabs ── */
.product-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border-color); }

/* ── Select ── */
.param-select { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-body); font-size: 12px; padding: 5px 10px; outline: none; cursor: pointer; }
.param-select:focus { border-color: var(--accent-blue); }

/* ── Badges ── */
.badge { display: inline-block; font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-amazon { background: #f59e0b22; color: var(--accent-yellow); border: 1px solid #f59e0b44; }
.badge-website { background: #3b82f622; color: var(--accent-blue); border: 1px solid #3b82f644; }
.badge-whatsapp { background: #10b98122; color: var(--accent-green); border: 1px solid #10b98144; }

/* ── Notes ── */
.info-note { font-size: 11px; color: var(--text-muted); padding: 6px 10px; background: rgba(6, 182, 212, 0.04); border-left: 2px solid var(--accent-cyan); margin: 8px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.info-note a { color: var(--accent-blue); text-decoration: none; }
.info-note a:hover { text-decoration: underline; }

/* ── P&L ── */
.pl-table td:first-child { padding-left: 20px; }
.pl-table tr.group-header td { padding-left: 8px; }

/* ── Pricing ── */
.target-profit-highlight { background: rgba(16, 185, 129, 0.1) !important; border-left: 3px solid var(--accent-green); }

/* ── Loading ── */
.loading-overlay { position: fixed; inset: 0; background: rgba(10, 14, 23, 0.95); display: flex; align-items: center; justify-content: center; z-index: 999; flex-direction: column; gap: 12px; }
.loading-overlay .spinner { width: 28px; height: 28px; border: 3px solid var(--border-color); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay span { font-size: 12px; color: var(--text-muted); }

/* ── Toast ── */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg-tertiary); border: 1px solid var(--accent-green); color: var(--accent-green); padding: 8px 16px; border-radius: var(--radius-md); font-size: 12px; z-index: 1000; animation: slideIn 0.3s ease, fadeOut 0.3s ease 2s forwards; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* ── Footer ── */
.page-footer { text-align: center; padding: 16px; font-size: 10px; color: var(--text-muted); border-top: 1px solid var(--border-color); margin-top: 20px; }
.page-footer a { color: var(--accent-blue); text-decoration: none; }

/* ── Utilities ── */
.text-green { color: var(--profit-green); }
.text-red { color: var(--loss-red); }
.text-blue { color: var(--accent-blue); }
.text-yellow { color: var(--accent-yellow); }
.text-muted { color: var(--text-muted); }
.text-bold { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Responsive ── */
@media (max-width: 1200px) { .grid-3 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
