/* Campaign Dashboard - light theme (default and only theme) */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --border-strong: #cfd7e6;
  --text: #0f1b33;
  --text-muted: #5b6985;
  --text-faint: #8592ab;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --green: #15803d;
  --green-soft: #e6f6ec;
  --yellow: #a16207;
  --yellow-soft: #fef6dc;
  --red: #b91c1c;
  --red-soft: #fdecec;
  --blue: #1d4ed8;
  --blue-soft: #e8f0ff;
  --gray: #475569;
  --gray-soft: #eef1f5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 27, 51, 0.04), 0 6px 18px rgba(15, 27, 51, 0.05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1400px 420px at 85% -120px, #e3ecff 0%, rgba(245, 247, 251, 0) 70%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-layout {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

/* Page Header (Title + Subtitle + Last Updated + Sync Status) */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 22px;
}

.page-title {
  min-width: 0;
  flex: 1;
}

.page-title h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-title p {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.45;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
  padding-top: 4px;
}

.meta-item { display: flex; flex-direction: column; align-items: flex-end; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; }
.meta-value { font-size: 13px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--gray-soft);
  color: var(--gray);
  white-space: nowrap;
}
.sync-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sync-ok { background: var(--green-soft); color: var(--green); }
.sync-warn { background: var(--yellow-soft); color: var(--yellow); }
.sync-bad { background: var(--red-soft); color: var(--red); }
.sync-info { background: var(--blue-soft); color: var(--blue); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dashboard-views { display: flex; flex-direction: column; gap: 20px; }

/* Filters (Positioned first inside ready state) */
.filters-card { padding: 18px 22px 20px; }
.filters-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.filters-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.link-btn {
  background: none;
  border: 0;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}
.link-btn:hover { background: var(--primary-soft); }
.filters-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 1.7fr);
  gap: 18px;
  align-items: start;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.select,
.date-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.select:focus, .date-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.select:disabled, .date-input:disabled, .seg-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.segmented {
  display: flex;
  background: var(--gray-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  min-height: 40px;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn:hover:not(:disabled) { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--primary-dark); box-shadow: 0 1px 3px rgba(15, 27, 51, 0.12); }

.date-inputs { display: flex; align-items: center; gap: 8px; }
.date-inputs:empty { display: none; }
.date-sep { color: var(--text-muted); font-size: 13px; }
.filter-date .note-line { margin-top: 2px; line-height: 1.4; }

button:focus-visible, .select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Campaign Overview */
.overview-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.65fr) minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 0;
  padding: 0;
}
.overview-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding: 20px 24px;
  min-width: 0;
  border-left: 1px solid var(--border);
}
.overview-cell:first-child { border-left: 0; }
.cell-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.cell-text { font-size: 14px; color: var(--text-muted); }
.cell-note { font-size: 12px; color: var(--text-faint); line-height: 1.35; }
.campaign-title { font-size: 19px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }

.copy-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  overflow: hidden;
}
.copy-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-overflow: ellipsis;
}
.copy-input:focus { outline: none; }
.copy-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.copy-btn {
  border: 0;
  border-left: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
}
.copy-btn:hover { background: var(--primary-soft); }

.status-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.status-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-yellow { background: var(--yellow-soft); color: var(--yellow); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-gray, .tone-neutral { background: var(--gray-soft); color: var(--gray); }

.budget-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress-track { height: 9px; background: #e6ecf7; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width 0.4s ease; }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 18px 20px;
  min-width: 0;
  min-height: 118px;
}
.kpi-title { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.kpi-number {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: auto; }
.kpi-delta {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--gray);
  font-variant-numeric: tabular-nums;
}
.kpi-delta.up { background: var(--green-soft); color: var(--green); }
.kpi-delta.down { background: var(--red-soft); color: var(--red); }

.note-line { font-size: 12.5px; color: var(--text-muted); margin-top: 10px; }

.notice {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--border);
}
.notice-info { background: var(--blue-soft); border-color: #cfe0ff; color: #1e3a8a; }
.notice-empty { background: #fff; border: 1px dashed var(--border-strong); color: var(--text-muted); margin-top: 0; }
.notice-empty strong { color: var(--text); margin-right: 6px; }

/* Performance Tables */
.tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.table-card { padding: 18px 20px 16px; min-width: 0; }
.card-header { margin-bottom: 14px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.section-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.table-scroll-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: #f6f8fc;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table thead th:first-child,
.data-table tbody td:first-child { padding-left: 14px; }
.data-table thead th:last-child,
.data-table tbody td:last-child { padding-right: 14px; }
.data-table th.th-numeric,
.data-table td.th-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fafbfe; }
.td-entity { display: flex; align-items: center; gap: 9px; font-weight: 600; white-space: nowrap; }
.empty-table-row { text-align: center; color: var(--text-faint); padding: 28px 12px !important; }
.flag-container { display: inline-flex; width: 22px; height: 16px; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--border); flex: none; }
.flag-icon { width: 100%; height: 100%; object-fit: cover; display: block; }
.device-icon { width: 18px; height: 18px; stroke: var(--text-muted); flex: none; }

/* States */
.state-view { margin-top: 8px; }
.state-message-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.state-icon-wrapper { color: var(--primary); background: var(--primary-soft); width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.state-title { font-size: 20px; font-weight: 700; }
.state-description { color: var(--text-muted); max-width: 520px; }

.skeleton-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.skeleton-card {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef2f9 25%, #f7f9fd 50%, #eef2f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.skeleton-wide { grid-column: 1 / -1; height: 110px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.demo-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 13.5px;
  line-height: 1.4;
}
.demo-badge { background: var(--blue); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 6px; }

/* Footer */
.app-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}
.footer-note { color: var(--text-muted); }
.footer-meta { font-size: 12px; color: var(--text-faint); }

/* Responsive Breakpoints */
@media (max-width: 1439px) {
  .tables-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
  .app-layout { padding: 24px 24px 32px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .skeleton-grid { grid-template-columns: repeat(3, 1fr); }
  .overview-card { grid-template-columns: 1fr 1fr; }
  .overview-cell:nth-child(3) { border-left: 0; }
  .overview-cell:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .filters-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .app-layout { padding: 18px 14px 28px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-meta { justify-content: flex-start; padding-top: 0; }
  .meta-item { align-items: flex-start; }
  .page-title h1 { font-size: 25px; }
  .overview-card { grid-template-columns: 1fr; }
  .overview-cell { border-left: 0; border-top: 1px solid var(--border); padding: 16px 18px; }
  .overview-cell:first-child { border-top: 0; }
  .kpi-grid, .skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-number { font-size: 23px; }
  .filters-grid { grid-template-columns: 1fr; }
  .date-inputs { flex-wrap: wrap; }
  .table-card { padding: 14px 12px 12px; }
}

@media (max-width: 440px) {
  .kpi-grid, .skeleton-grid { grid-template-columns: 1fr; }
  .seg-btn { font-size: 12px; padding: 6px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill, .skeleton-card { transition: none; animation: none; }
}
