/* B&L Aircon — Ads Planner. Brand palette from CLAUDE.md. Mobile-first. */
:root {
  --ice: #00b4d8;
  --ice-light: #90e0ef;
  --ice-bg: #e8f8fc;
  --orange: #f4a261;
  --orange-dark: #e76f51;
  --navy: #023e8a;
  --navy-dark: #022f6b;
  --ink: #0f2235;
  --muted: #5b7186;
  --line: #dce5ec;
  --bg: #f4f8fb;
  --card: #ffffff;
  --good: #1f9d55;
  --good-bg: #e7f6ee;
  --warn: #c47a00;
  --warn-bg: #fdf3e0;
  --bad: #c0392b;
  --bad-bg: #fbeae8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(2, 62, 138, 0.08);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 0.85rem; margin: 0.4rem 0 0; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--navy) 0%, var(--ice) 100%);
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 18px 50px rgba(2, 47, 107, 0.35);
  text-align: center;
}
.login-card .brand-mark { font-weight: 800; color: var(--ice); letter-spacing: -0.02em; }
.login-card h1 { margin: 0.3rem 0 0; font-size: 1.7rem; color: var(--navy); }
.login-card p { margin: 0.25rem 0 1.25rem; font-size: 0.85rem; }
.login-card input { margin-bottom: 0.85rem; }

/* ---------- Topbar + tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--navy);
  color: #fff;
}
.topbar-brand { font-weight: 700; font-size: 1rem; }
.topbar-brand span { color: var(--ice-light); }
.topbar-brand em { font-style: normal; color: #b9cbe0; font-weight: 400; font-size: 0.82rem; margin-left: 0.15rem; }

.tabs {
  position: sticky; top: 48px; z-index: 19;
  display: flex; gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  flex: 0 0 auto;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.tabs a.active { background: var(--ice-bg); color: var(--navy); }

/* ---------- Layout ---------- */
.view { padding: 1rem; max-width: 1100px; margin: 0 auto; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.view-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.view-head h2 { margin: 0; font-size: 1.35rem; color: var(--navy); }
.view-head .sub { font-size: 0.85rem; color: var(--muted); }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  border: 1px solid transparent; border-radius: 10px;
  padding: 0.55rem 0.95rem; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; background: #eef3f7; color: var(--ink);
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--ice); color: #00323d; border-color: var(--ice); }
.btn-accent { background: var(--orange); color: #4a2400; border-color: var(--orange); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.4); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--ice); padding: 0.2rem; font-weight: 600; cursor: pointer; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ice-light); border-color: var(--ice); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin: 0 0 0.25rem; }
.field { margin-bottom: 0.85rem; }
.field-row { display: flex; gap: 0.75rem; }
.field-row > .field { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.85rem;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.card-title { font-weight: 700; color: var(--navy); margin: 0; }
.card-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 1.5rem; font-weight: 800; color: var(--navy); margin-top: 0.15rem; line-height: 1.1; }
.stat .value.pos { color: var(--good); }
.stat .value.neg { color: var(--bad); }
.stat .hint { font-size: 0.74rem; color: var(--muted); margin-top: 0.15rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { padding: 0.6rem 0.7rem; text-align: left; white-space: nowrap; }
thead th { background: #f0f5f9; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--line); }
tbody tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: #fafcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges / flags ---------- */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }
.badge.neutral { background: #eef3f7; color: var(--muted); }
.flag-good { color: var(--good); font-weight: 700; }
.flag-bad  { color: var(--bad);  font-weight: 700; }

.status-pill { font-size: 0.72rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 999px; text-transform: capitalize; }
.status-draft  { background: #eef3f7; color: var(--muted); }
.status-active { background: var(--good-bg); color: var(--good); }
.status-paused { background: var(--warn-bg); color: var(--warn); }
.status-ended  { background: var(--bad-bg); color: var(--bad); }

/* ---------- Campaign tree ---------- */
.tree-adset { margin: 0.6rem 0 0.6rem 0; padding-left: 0.85rem; border-left: 3px solid var(--ice-light); }
.tree-ad { font-size: 0.85rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.tree-ad:last-child { border-bottom: none; }
.angle-tag { font-size: 0.68rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 6px; text-transform: uppercase; }
.angle-pain { background: #fdecea; color: var(--orange-dark); }
.angle-promo { background: var(--ice-bg); color: var(--ice); }
.angle-trust { background: #ecf3ff; color: var(--navy); }
.angle-general { background: #eef3f7; color: var(--muted); }

/* ---------- Char counter ---------- */
.char-count { font-size: 0.75rem; font-weight: 700; text-align: right; margin-top: 0.2rem; }
.char-count.ok { color: var(--good); }
.char-count.over { color: var(--bad); }

/* ---------- Plan checklist ---------- */
.phase-block { margin-bottom: 1.25rem; }
.phase-head { display: flex; align-items: baseline; gap: 0.5rem; margin: 0 0 0.5rem; }
.phase-head h3 { margin: 0; color: var(--navy); font-size: 1.05rem; }
.phase-progress { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.task {
  display: flex; gap: 0.7rem; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.7rem 0.8rem; margin-bottom: 0.5rem; box-shadow: var(--shadow);
}
.task.done { opacity: 0.62; }
.task.done .task-title { text-decoration: line-through; }
.task input[type=checkbox] { width: 22px; height: 22px; margin-top: 0.1rem; flex-shrink: 0; accent-color: var(--ice); }
.task-body { flex: 1; min-width: 0; }
.task-day { font-size: 0.7rem; font-weight: 700; color: var(--ice); text-transform: uppercase; }
.task-title { font-weight: 600; }
.task-detail { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 25, 51, 0.55);
  display: grid; place-items: center; padding: 1rem; z-index: 50;
}
.modal {
  background: var(--card); border-radius: 18px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; padding: 1.25rem; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin: 0 0 1rem; color: var(--navy); }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-emoji { font-size: 2rem; display: block; margin-bottom: 0.4rem; }

.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 0.6rem 1rem; border-radius: 10px;
  font-size: 0.85rem; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.copy-group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 800; margin: 1.1rem 0 0.4rem; }
.copy-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; }
.copy-text { flex: 1; }
.copy-len { font-size: 0.72rem; font-weight: 700; flex-shrink: 0; padding: 0.1rem 0.45rem; border-radius: 6px; }

/* ---------- Alerts panel ---------- */
.alerts { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.alert {
  display: flex; align-items: flex-start; gap: 0.6rem;
  border-radius: 12px; padding: 0.65rem 0.85rem; font-size: 0.88rem;
  border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow);
}
.alert .a-icon { font-size: 1.05rem; line-height: 1.3; }
.alert .a-body { flex: 1; }
.alert .a-title { font-weight: 700; }
.alert .a-detail { font-size: 0.8rem; color: var(--muted); }
.alert.red   { border-left: 4px solid var(--bad); }
.alert.amber { border-left: 4px solid var(--warn); }
.alert.green { border-left: 4px solid var(--good); }

.section-title { color: var(--navy); margin: 1.3rem 0 0.6rem; font-size: 1.05rem; }
.section-title .muted-inline { font-weight: 400; font-size: 0.78rem; color: var(--muted); }

/* ---------- Funnel ---------- */
.funnel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
.funnel-row { display: grid; grid-template-columns: 1fr 1.6fr auto; align-items: center; gap: 0.6rem; padding: 0.35rem 0; }
.funnel-label { display: flex; flex-direction: column; }
.funnel-stage { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; }
.funnel-value { font-size: 1.05rem; font-weight: 800; color: var(--navy); }
.funnel-track { background: #eef3f7; border-radius: 8px; height: 22px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 8px; transition: width 0.4s; }
.funnel-conv { font-size: 0.78rem; font-weight: 700; color: var(--ice); min-width: 56px; text-align: right; }

/* ---------- Charts ---------- */
.chart-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
svg.chart { width: 100%; height: auto; display: block; }
.chart-axis { font-size: 10px; fill: var(--muted); }
.chart-legend { display: flex; gap: 1rem; justify-content: center; margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }
.chart-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.chart-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Bar list (top performers / pacing) ---------- */
.barlist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
.barlist-row { margin-bottom: 0.7rem; }
.barlist-row:last-child { margin-bottom: 0; }
.barlist-head { display: flex; justify-content: space-between; font-size: 0.84rem; margin-bottom: 0.25rem; }
.barlist-track { background: #eef3f7; border-radius: 6px; height: 14px; overflow: hidden; position: relative; }
.barlist-bar { height: 100%; border-radius: 6px; }
.barlist-val { font-size: 0.78rem; font-weight: 700; color: var(--navy); margin-top: 0.15rem; }

.pace-bar { background: #eef3f7; border-radius: 8px; height: 20px; overflow: hidden; margin: 0.4rem 0; }
.pace-fill { height: 100%; border-radius: 8px; }

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .topbar { padding: 0.8rem 1.5rem; }
  .tabs { top: 53px; padding: 0.5rem 1rem; }
}
