/* ══════════════════════════════════════════════════════════════
   Analytics Agent — Pricing Agent Web
   Design system: analitics-agent-case style (light, orange accents)
   ══════════════════════════════════════════════════════════════ */

:root {
    --orange: #FF7629;
    --orange-hover: #FF9255;
    --orange-light: #FFF3EB;
    --blue-light: #99DCF6;
    --black: #1A1A1A;
    --dim: #888;
    --border: #E8E8E8;
    --bg: #F5F5F5;
    --card: #FFFFFF;
    --green: #2ECC71;
    --green-bg: #EAFAF1;
    --red: #E74C3C;
    --red-bg: #FDEDEC;
    --yellow: #F39C12;
    --yellow-bg: #FEF5E7;
    --radius-card: 20px;
    --radius-btn: 30px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--black);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
    background: var(--card);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { height: 36px; }
.header-badge {
    background: var(--orange-light);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.user-name { font-weight: 600; color: var(--dim); font-size: 13px; }
.btn-refresh {
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-btn);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-refresh:hover { background: var(--orange-hover); }
.btn-refresh:disabled { opacity: 0.6; cursor: wait; }
.btn-logout {
    color: var(--dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}
.btn-logout:hover { color: var(--red); }

/* ── Nav section tabs ───────────────────────────────────── */
.nav-tab {
    color: var(--dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-tab:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: var(--orange-light);
}
.nav-tab-active {
    background: var(--orange);
    color: #fff !important;
    border-color: var(--orange);
}
.nav-tab-active:hover {
    background: var(--orange-hover);
    border-color: var(--orange-hover);
}

/* ── Alert ──────────────────────────────────────────────── */
.alert-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 500;
}

/* ── Summary Cards ──────────────────────────────────────── */
.summary {
    display: flex;
    gap: 16px;
    padding: 24px 32px 0;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--card);
    border-radius: var(--radius-card);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-card.stat-urgent { border: 2px solid var(--red); }
.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--black);
    line-height: 1.2;
}
.stat-urgent .stat-value { color: var(--red); }
.stat-profit .stat-value { color: var(--green); }
.stat-loss .stat-value { color: var(--red); }
.stat-refund { border: 2px solid var(--yellow); }
.stat-refund .stat-value { color: var(--yellow); }
.stat-label {
    font-size: 12px;
    color: var(--dim);
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Main Layout ────────────────────────────────────────── */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    padding: 20px 32px;
    min-height: calc(100vh - 260px);
}

/* ── Table ───────────────────────────────────────────────── */
.table-section {
    background: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.section-title {
    font-size: 16px;
    font-weight: 700;
    padding: 16px 20px 12px;
    color: var(--black);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.table-wrap { overflow-x: auto; }
.events-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.events-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    font-size: 11px;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.events-table td {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
}
.event-row { cursor: pointer; transition: background 0.15s; }
.event-row:hover { background: var(--orange-light); }
.event-row.active { background: var(--orange-light); border-left: 3px solid var(--orange); }
.event-row.urgent td { background: #FFF8F5; }
.td-name { font-weight: 600; }
.td-rev { font-variant-numeric: tabular-nums; }
.td-cost { font-variant-numeric: tabular-nums; color: #888; font-size: 13px; }

/* Tier dots */
.tier-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.tier-dot.t1 { background: var(--orange); }
.tier-dot.t2 { background: var(--blue-light); }
.tier-dot.t3 { background: var(--border); }

/* ── Fill bars (mini) ───────────────────────────────────── */
.fill-bar-mini {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 6px;
}
.fill-bar-inner {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.fill-green { background: var(--green); }
.fill-orange { background: var(--orange); }
.fill-yellow { background: var(--yellow); }
.fill-red { background: var(--red); }
.fill-pct { font-weight: 600; font-size: 12px; }

/* ── Action badges ──────────────────────────────────────── */
.action-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.action-hold { background: #F0F0F0; color: #888; }
.action-raise { background: var(--green-bg); color: var(--green); }
.action-lower { background: var(--red-bg); color: var(--red); }
.action-promo { background: var(--yellow-bg); color: #B7791F; }

/* ── Detail Panel ───────────────────────────────────────── */
.detail-panel {
    background: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    position: sticky;
    top: 80px;
}
.detail-placeholder {
    color: var(--dim);
    text-align: center;
    padding: 80px 20px;
    font-size: 15px;
}
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.detail-header h2 { font-size: 20px; font-weight: 800; }
.detail-tier {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.tier-badge-1 { background: var(--orange); color: #fff; }
.tier-badge-2 { background: var(--blue-light); color: #333; }
.tier-badge-3 { background: var(--border); color: #888; }
.detail-date { color: var(--dim); font-size: 13px; margin-bottom: 16px; }

/* Fill bar big */
.fill-section { margin-bottom: 16px; }
.fill-bar-big {
    width: 100%;
    height: 14px;
    background: var(--bg);
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 6px;
}
.fill-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.sg-item {
    background: var(--bg);
    border-radius: 12px;
    padding: 10px 14px;
}
.sg-label { display: block; font-size: 11px; color: var(--dim); font-weight: 500; text-transform: uppercase; }
.sg-value { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }

/* Sections */
.section-subtitle {
    font-size: 12px;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    margin-top: 16px;
}

/* Breakeven */
.be-section { margin-bottom: 8px; }
.be-info { font-size: 13px; color: var(--dim); font-weight: 500; }

/* Refund warning */
.refund-warning {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* No-budget warning */
.no-budget-warning {
    background: var(--yellow-bg);
    color: #B7791F;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Marketing section */
.marketing-section { margin-bottom: 8px; }
.marketing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Recommendation */
.rec-card {
    padding: 12px 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.rec-hold { background: #F5F5F5; }
.rec-raise { background: var(--green-bg); }
.rec-lower { background: var(--red-bg); }
.rec-promo { background: var(--yellow-bg); }
.rec-action {
    font-weight: 800;
    font-size: 15px;
    white-space: nowrap;
}
.rec-confidence {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.conf-high { background: var(--green); color: #fff; }
.conf-med, .conf-medium { background: var(--yellow); color: #fff; }
.conf-low { background: var(--border); color: var(--dim); }
.rec-reason { font-size: 13px; color: var(--dim); }

/* Price scenarios */
.scenarios-section { margin-top: 8px; }
.scenarios-table { font-size: 13px; }
.sc-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--dim);
    text-transform: uppercase;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.sc-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.sc-cut { font-weight: 600; color: var(--red); }
.sc-block-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--black);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.floor-price {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

/* Agents */
.metrika-section {
    margin-top: 8px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 14px;
}
/* ── Channel tabs (target / seeding / offline) ─────────── */
.ch-tab {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    transition: all .15s;
}
.ch-tab:hover { background: #f0f9ff; }
.ch-tab-active { background: #2563EB; color: #fff; border-color: #2563EB; }
.ch-tab-active:hover { background: #1d4ed8; }
.utm-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.utm-table th {
    text-align: left; font-weight: 600; color: #94a3b8;
    font-size: 10px; text-transform: uppercase; letter-spacing: .3px;
    padding: 4px 6px; border-bottom: 1px solid #dbeafe;
}
.utm-table td { padding: 5px 6px; border-bottom: 1px solid #f1f5f9; }
.utm-table tr:last-child td { border-bottom: none; }
.utm-source { font-weight: 600; color: #1e293b; }
.utm-campaign { color: #64748b; font-size: 10px; word-break: break-all; }
.ch-summary {
    display: flex; gap: 12px; margin-bottom: 10px;
    font-size: 12px; color: #475569;
}
.ch-summary strong { color: #1e293b; }
.ch-empty { color: #94a3b8; font-size: 12px; padding: 8px 0; }
/* ── Target cards (spend summary) ──────────────────────── */
.target-cards {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.tc-card {
    flex: 1; min-width: 60px;
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 8px; padding: 8px 6px; text-align: center;
}
.tc-val { font-size: 14px; font-weight: 700; color: #1e293b; }
.tc-lbl { font-size: 10px; color: #94a3b8; margin-top: 2px; }
.gap-alert {
    margin-top: 10px; padding: 8px 12px;
    background: #fef3c7; border: 1px solid #fcd34d;
    border-radius: 8px; font-size: 11px; color: #92400e;
}
/* ── Cancelled badge ───────────────────────────────────────── */
.badge-cancelled {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 8px;
    background: #F0F0F0;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-left: 4px;
}
.cancelled-row td { opacity: 0.55; }
.cancelled-row:hover { background: #fafafa !important; }

.agents-section { margin-top: 8px; }

/* ── Promo codes ──────────────────────────────────────────── */
.promo-section { margin-top: 12px; }
.promo-row {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 12px;
}
.promo-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.promo-row-note {
    font-size: 11px;
    color: var(--dim);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.promo-code { font-weight: 700; font-family: monospace; letter-spacing: 0.5px; }
.promo-discount { color: var(--orange); font-weight: 700; white-space: nowrap; }
.promo-note { color: var(--dim); }
.promo-del {
    width: 20px; height: 20px; border: none; background: none;
    cursor: pointer; color: #ccc; font-size: 14px; text-align: center;
    border-radius: 4px; transition: color 0.15s;
}
.promo-del:hover { color: #e53e3e; }
.promo-add-form { margin-top: 8px; }
.btn-promo-add {
    width: 100%; padding: 6px; background: #f8f8f8; border: 1px dashed #ddd;
    border-radius: 6px; font-size: 12px; color: #666; cursor: pointer;
    font-family: inherit; transition: all 0.15s;
}
.btn-promo-add:hover { background: var(--orange-light); border-color: var(--orange); color: var(--orange); }
.promo-empty { font-size: 12px; color: #aaa; font-style: italic; padding: 4px 0; }
.agent-row {
    display: grid;
    grid-template-columns: 1fr 60px 90px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.agent-name { font-weight: 600; }
.agent-sold { text-align: right; color: var(--dim); }
.agent-rev  { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* AI */
.ai-section { margin-top: 8px; }
.ai-list {
    list-style: none;
    padding: 0;
}
.ai-list li {
    padding: 8px 12px;
    background: var(--orange-light);
    border-radius: 10px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
    border-left: 3px solid var(--orange);
}

/* Chart */
.chart-section { margin-top: 16px; }

/* ── Utility ────────────────────────────────────────────── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-dim { color: var(--dim); }

/* ── Footer ─────────────────────────────────────────────── */
.page-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--dim);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .detail-panel {
        position: static;
        max-height: none;
    }
    .summary { gap: 10px; }
    .stat-card { min-width: 100px; padding: 14px 12px; }
    .stat-value { font-size: 22px; }
    .header { padding: 12px 16px; }
    .main-layout { padding: 16px; }
    .summary { padding: 16px 16px 0; }
}

@media (max-width: 640px) {
    .summary { flex-direction: column; }
    .stat-card { min-width: auto; }
    .events-table { font-size: 12px; }
    .events-table th, .events-table td { padding: 8px 6px; }
}
