/* PlanMate Analytics — Google Ads dashboard */
:root {
    --pm-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --pm-bg: #f5f6f8;
    --pm-surface: #ffffff;
    --pm-surface-2: #f9fafb;
    --pm-border: #e5e7eb;
    --pm-text: #191919;
    --pm-text-2: #666666;
    --pm-accent: #257de0;
    --pm-accent-soft: #e8f1fc;
    --pm-sidebar: #0f172a;
    --pm-sidebar-text: #cbd5e1;
    --pm-good: #0a7d2c;
    --pm-bad: #c62828;
    --pm-warn: #b25e00;
    /* chart roles (categorical slots in fixed order) */
    --series-1: #257de0;
    --series-2: #f47230;
    --series-3: #00b894;
    --series-4: #f2a600;
    --series-5: #ee7fac;
    --series-6: #008a17;
    --series-7: #6a4ce2;
    --series-8: #ec4647;
    --series-prev: #b9bec7;
    --grid: #eceef1;
    --sidebar-w: 248px;
}
[data-bs-theme="dark"] {
    --pm-bg: #111214;
    --pm-surface: #191919;
    --pm-surface-2: #202122;
    --pm-border: #2c2d30;
    --pm-text: #efefef;
    --pm-text-2: #9c9c9c;
    --pm-accent: #338ced;
    --pm-accent-soft: #15283f;
    --pm-sidebar: #0b0c0e;
    --pm-good: #3ccf63;
    --pm-bad: #ff7a7a;
    --pm-warn: #f2b04a;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --series-4: #d28e05;
    --series-5: #e24d8b;
    --series-6: #0aac23;
    --series-7: #9887ef;
    --series-8: #eb6263;
    --series-prev: #55595f;
    --grid: #2a2b2e;
    --bs-body-bg: #111214;
}

html, body { height: 100%; }
body {
    font-family: var(--pm-font);
    background: var(--pm-bg);
    color: var(--pm-text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--pm-accent); }
.btn-primary { --bs-btn-bg: var(--pm-accent); --bs-btn-border-color: var(--pm-accent); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: var(--pm-sidebar); color: var(--pm-sidebar-text);
    display: flex; flex-direction: column; padding: 18px 12px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: #fff; text-decoration: none; padding: 4px 8px 18px; }
.auth-card .brand { color: var(--pm-text); padding: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #257de0, #00b894); display: grid; place-items: center; color: #fff; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 16px 10px 6px; font-weight: 600; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--pm-sidebar-text); text-decoration: none; font-weight: 500; }
.nav-item i { font-size: 16px; width: 18px; text-align: center; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(51,140,237,.18); color: #fff; }
.nav-item.active i { color: #6aabf1; opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 6px 10px; border-radius: 20px; text-decoration: none; }
.conn-ok { background: rgba(10,172,35,.15); color: #6ee787; }
.conn-off { background: rgba(236,70,71,.15); color: #ff9b9b; }
.conn-demo { background: rgba(242,166,0,.15); color: #f7c75c; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--pm-surface); border-bottom: 1px solid var(--pm-border); position: sticky; top: 0; z-index: 1020; }
.topbar-title h1 { font-size: 18px; font-weight: 700; margin: 0; }
.topbar-title .sub { font-size: 12px; color: var(--pm-text-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--pm-border); background: var(--pm-surface); color: var(--pm-text); padding: 0; }
.btn-user { display: flex; align-items: center; gap: 8px; border: 1px solid var(--pm-border); border-radius: 8px; padding: 4px 10px 4px 4px; background: var(--pm-surface); color: var(--pm-text); }
.avatar { width: 28px; height: 28px; border-radius: 6px; background: var(--pm-accent-soft); color: var(--pm-accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }

.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 12px 28px; background: var(--pm-surface); border-bottom: 1px solid var(--pm-border); }
.filter label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--pm-text-2); margin-bottom: 4px; }
.filter .form-select, .filter .form-control { min-width: 170px; }
.filter #fCustomer { min-width: 260px; max-width: 360px; }
.filter-actions { display: flex; gap: 6px; }
.compare-note { margin-left: auto; align-self: center; }

.content { padding: 24px 28px 48px; max-width: 1600px; width: 100%; }

/* ---------- cards ---------- */
.card { background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 12px; box-shadow: none; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.card-head .hint { font-size: 12px; color: var(--pm-text-2); }
.card-head .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 18px 18px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1200px) { .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .g-2, .g-3 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1400px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 992px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: border-color .15s; text-align: left; color: inherit; width: 100%; }
.kpi:hover { border-color: var(--pm-accent); }
.kpi.active { border-color: var(--pm-accent); box-shadow: inset 0 0 0 1px var(--pm-accent); }
.kpi .label { font-size: 12px; color: var(--pm-text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 2px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .prev { font-size: 11px; color: var(--pm-text-2); font-weight: 400; margin-left: 4px; }
.delta.up.good, .delta.down.good { color: var(--pm-good); }
.delta.up.bad, .delta.down.bad { color: var(--pm-bad); }
.delta.flat { color: var(--pm-text-2); }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--pm-text-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .sw.line { height: 3px; border-radius: 2px; vertical-align: 2px; width: 14px; }
.legend .sw.dash { background: repeating-linear-gradient(90deg, var(--series-prev) 0 4px, transparent 4px 7px) !important; }

/* ---------- bar list ---------- */
.barlist { display: flex; flex-direction: column; gap: 10px; }
.barlist .row-i { display: grid; grid-template-columns: 120px 1fr 88px; gap: 10px; align-items: center; font-size: 13px; }
.barlist .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barlist .track { height: 10px; background: var(--pm-surface-2); border-radius: 4px; overflow: hidden; }
.barlist .fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.barlist .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--pm-text); }
.barlist .val small { color: var(--pm-text-2); display: block; font-size: 11px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data-table th { position: sticky; top: 0; background: var(--pm-surface-2); color: var(--pm-text-2); font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--pm-border); white-space: nowrap; user-select: none; }
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--pm-text); }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--pm-border); vertical-align: middle; }
.data-table tbody tr:hover td { background: var(--pm-surface-2); }
.data-table tfoot td { font-weight: 700; background: var(--pm-surface-2); border-bottom: 0; }
.data-table td.text { max-width: 360px; min-width: 160px; }
.data-table td.muted { color: var(--pm-text-2); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table .sort-ind { font-size: 10px; margin-left: 4px; }
.ad-cell .h { font-weight: 600; color: var(--pm-accent); }
.ad-cell .u { font-size: 12px; color: var(--pm-good); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--pm-text-2); }
.status.enabled::before { background: #0aac23; }
.status.paused::before { background: #f2a600; }
.status.removed::before { background: #ec4647; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--pm-surface-2); border: 1px solid var(--pm-border); color: var(--pm-text-2); }
.qs { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 5px; font-weight: 700; font-size: 12px; }
.qs.hi { background: rgba(10,172,35,.14); color: var(--pm-good); }
.qs.mid { background: rgba(242,166,0,.16); color: var(--pm-warn); }
.qs.lo { background: rgba(236,70,71,.14); color: var(--pm-bad); }

.table-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--pm-border); }
.table-toolbar .search { max-width: 280px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; font-size: 12px; color: var(--pm-text-2); }

/* ---------- insights ---------- */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--pm-border); background: var(--pm-surface-2); }
.insight i { font-size: 18px; line-height: 1.2; }
.insight .t { font-weight: 600; font-size: 13px; }
.insight .d { font-size: 12.5px; color: var(--pm-text-2); margin-top: 2px; }
.insight.good i { color: var(--pm-good); }
.insight.warning i { color: var(--pm-warn); }
.insight.critical i { color: var(--pm-bad); }
.insight.info i { color: var(--pm-accent); }

/* ---------- states ---------- */
.skeleton { background: linear-gradient(90deg, var(--pm-surface-2) 25%, var(--pm-border) 37%, var(--pm-surface-2) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 40px 20px; color: var(--pm-text-2); }
.empty i { font-size: 32px; display: block; margin-bottom: 8px; }
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000; background: var(--pm-accent); transform-origin: left; animation: load 1.2s ease-in-out infinite; display: none; }
.loading .loading-overlay { display: block; }
@keyframes load { 0% { transform: scaleX(0); } 50% { transform: scaleX(.7); } 100% { transform: scaleX(1); opacity: 0; } }

/* ---------- settings ---------- */
.step { display: flex; gap: 14px; }
.step-num { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--pm-accent-soft); color: var(--pm-accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.step-num.done { background: rgba(10,172,35,.15); color: var(--pm-good); }
.copy-field { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.settings-nav a { color: var(--pm-text-2); text-decoration: none; display: block; padding: 6px 0; }
.settings-nav a:hover { color: var(--pm-accent); }

/* ---------- auth ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: 14px; padding: 32px; }

/* ---------- report (print) ---------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.report-head h2 { font-size: 22px; font-weight: 700; margin: 0; }
.report-section-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; }

/* ---------- responsive sidebar ---------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1030; }
    .topbar, .filterbar { padding-left: 16px; padding-right: 16px; }
    .content { padding: 16px; }
    .compare-note { margin-left: 0; }
    .filter { flex: 1 1 100%; }
    .filter .form-select, .filter .form-control, .filter #fCustomer { min-width: 0; max-width: none; width: 100%; }
}

@media print {
    .sidebar, .topbar, .filterbar, .no-print, .alert { display: none !important; }
    body { background: #fff; color: #000; font-size: 12px; }
    .content { padding: 0; max-width: none; }
    .card { border-color: #ddd; break-inside: avoid; }
    .chart-box { height: 240px; }
}
