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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f0f10;
  color: #d0d0d0;
  min-height: 100vh;
  padding: 32px 20px;
  font-size: 13px;
}
.wrap {
  max-width: 860px;
  margin: 0 auto;
}

h1 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}
.sub {
  color: #444;
  font-size: 12px;
  margin-bottom: 28px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid #222;
}
.tab {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s;
}
.tab:hover {
  color: #aaa;
}
.tab.active {
  color: #fff;
  border-bottom-color: #6366f1;
}
.tab.ads-tab.active {
  border-bottom-color: #f59e0b;
  color: #fbbf24;
}
.panel {
  display: none;
}
.panel.active {
  display: block;
}

/* ── Context row ── */
.ctx {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.ctx-field label {
  font-size: 11px;
  color: #555;
  display: block;
  margin-bottom: 3px;
}
.ctx-field input {
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 10px;
  font-size: 12px;
  width: 160px;
  outline: none;
}
.ctx-field input:focus {
  border-color: #444;
}

/* ── Platform cards ── */
.pcard {
  background: #1a1a1c;
  border: 1px solid #242426;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}
.pname {
  font-size: 14px;
  font-weight: 500;
  color: #f0f0f0;
}
.pmeta {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}
.pmeta.ok {
  color: #4ade80;
}
.pmeta.exp {
  color: #f87171;
}
.pmeta.warn {
  color: #fbbf24;
}
.spacer {
  flex: 1;
}

/* ── Buttons ── */
.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:hover {
  opacity: 0.8;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-primary {
  background: #4f46e5;
  color: #fff;
}
.btn-amber {
  background: #92400e;
  color: #fbbf24;
  border: 1px solid #b45309;
}
.btn-ghost {
  background: #1f1f22;
  color: #888;
  border: 1px solid #2e2e32;
}
.btn-danger {
  background: #1f0f0f;
  color: #f87171;
  border: 1px solid #3f1212;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── Forms ── */
.form-row {
  margin-bottom: 14px;
}
.form-row label {
  font-size: 11px;
  color: #555;
  display: block;
  margin-bottom: 5px;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: #444;
}
.form-row select option {
  background: #1a1a1c;
}
.form-row textarea {
  min-height: 80px;
}
.row {
  display: flex;
  gap: 10px;
}
.row .form-row {
  flex: 1;
}

/* ── Metadata builder ── */
.meta-builder {
  background: #141416;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.meta-builder-title {
  font-size: 11px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta-builder-title span {
  flex: 1;
}
.meta-field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-start;
}
.meta-field-row input {
  flex: 1;
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
}
.meta-field-row input:focus {
  border-color: #444;
}
.meta-field-label {
  font-size: 11px;
  color: #555;
  width: 110px;
  flex-shrink: 0;
  padding-top: 7px;
}
.meta-url-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.meta-url-item {
  display: flex;
  gap: 6px;
}
.meta-url-item input {
  flex: 1;
}
.add-url-btn {
  font-size: 11px;
  color: #555;
  background: none;
  border: 1px dashed #2a2a2e;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition: border-color 0.15s;
  text-align: left;
}
.add-url-btn:hover {
  border-color: #444;
  color: #888;
}
.hint {
  font-size: 11px;
  color: #333;
  margin-top: 6px;
  line-height: 1.5;
}
.post-type-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.pt-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #2a2a2e;
  color: #666;
  background: #1a1a1c;
  transition: all 0.15s;
}
.pt-pill:hover {
  border-color: #444;
  color: #aaa;
}
.pt-pill.active {
  border-color: #4f46e5;
  color: #a5b4fc;
  background: #1e1e30;
}

/* ── Resource cards ── */
.rcard {
  background: #1a1a1c;
  border: 1px solid #242426;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.rcard-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.rtag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.rtag.draft {
  background: #1e1e24;
  color: #7c7cff;
  border: 1px solid #2e2e44;
}
.rtag.scheduled {
  background: #1a1f12;
  color: #a3e635;
  border: 1px solid #2a3318;
}
.rtag.processing {
  background: #1f1a0d;
  color: #fbbf24;
  border: 1px solid #3d320f;
}
.rtag.published {
  background: #0f1f12;
  color: #4ade80;
  border: 1px solid #133320;
}
.rtag.failed {
  background: #1f0f0f;
  color: #f87171;
  border: 1px solid #3f1212;
}
.rtag.ACTIVE {
  background: #0f1f12;
  color: #4ade80;
  border: 1px solid #133320;
}
.rtag.PAUSED {
  background: #1f1f22;
  color: #888;
  border: 1px solid #333;
}
.rtag.DELETED {
  background: #1f0f0f;
  color: #f87171;
  border: 1px solid #3f1212;
}
.rtag.ARCHIVED {
  background: #1a1a1c;
  color: #555;
  border: 1px solid #2a2a2e;
}
.rplatform-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  border: 1px solid #2a2a2e;
  color: #888;
  background: #1a1a1c;
}
.rtime {
  font-size: 11px;
  color: #444;
  margin-left: auto;
}
.rcontent {
  font-size: 12px;
  color: #999;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: hidden;
}
.rmeta {
  font-size: 11px;
  color: #555;
  margin-top: 4px;
  font-family: monospace;
}
.rerror {
  font-size: 11px;
  color: #f87171;
  margin-top: 4px;
}
.ractions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ── Section heading ── */
.sec {
  font-size: 11px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 12px;
  margin-top: 24px;
}
.sec:first-child {
  margin-top: 0;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #1f1f22;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 12px;
  transition: transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}
#toast.ok {
  border-color: #166534;
  color: #4ade80;
}
#toast.err {
  border-color: #7f1d1d;
  color: #f87171;
}

/* ── Empty / health ── */
.empty {
  color: #333;
  font-size: 12px;
  padding: 20px 0;
  text-align: center;
}
pre.health {
  background: #141416;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 16px;
  font-size: 11px;
  color: #666;
  overflow-x: auto;
  line-height: 1.7;
}

/* ── Modals ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.open {
  display: flex;
}
.modal {
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 16px;
}
.modal-err {
  color: #f87171;
  font-size: 11px;
  margin-top: 10px;
  min-height: 16px;
}
.modal-hint {
  font-size: 11px;
  color: #444;
  margin-top: -10px;
  margin-bottom: 14px;
  line-height: 1.6;
}
.modal-hint a {
  color: #6366f1;
  text-decoration: none;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar select,
.filter-bar input[type="date"] {
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: #d0d0d0;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
}

/* ── Result box ── */
.result-box {
  background: #141416;
  border: 1px solid #222;
  border-radius: 6px;
  padding: 12px;
}
.result-box .rid {
  font-size: 11px;
  color: #a5b4fc;
  word-break: break-all;
  font-family: monospace;
}
.result-box .rlabel {
  font-size: 11px;
  color: #555;
  margin-bottom: 6px;
}

/* ── Ads sub-tabs ── */
.ads-sub-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid #1a1a1c;
}
.ads-sub-tab {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s;
}
.ads-sub-tab:hover {
  color: #888;
}
.ads-sub-tab.active {
  color: #fbbf24;
  border-bottom-color: #f59e0b;
}
.ads-sub-panel {
  display: none;
}
.ads-sub-panel.active {
  display: block;
}

/* ── KPI cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.kpi-card {
  background: #141416;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 12px 14px;
}
.kpi-label {
  font-size: 10px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 20px;
  font-weight: 600;
  color: #e0e0e0;
  line-height: 1;
}
.kpi-sub {
  font-size: 10px;
  color: #555;
  margin-top: 4px;
}
.kpi-card.highlight {
  border-color: #2a2010;
}
.kpi-card.highlight .kpi-value {
  color: #fbbf24;
}

/* ── Account selector ── */
.account-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.account-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #2a2a2e;
  color: #666;
  background: #1a1a1c;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.account-pill:hover {
  border-color: #f59e0b;
  color: #fbbf24;
}
.account-pill.active {
  border-color: #f59e0b;
  color: #fbbf24;
  background: #1c1706;
}
.account-pill .platform-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Ad account cards ── */
.acard {
  background: #1a1a1c;
  border: 1px solid #242426;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.acard-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}
.acard-body {
  flex: 1;
  min-width: 0;
}
.acard-name {
  font-size: 13px;
  font-weight: 500;
  color: #f0f0f0;
  margin-bottom: 3px;
}
.acard-meta {
  font-size: 11px;
  color: #555;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.acard-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.acard-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* ── Campaign table ── */
.campaign-table {
  width: 100%;
  border-collapse: collapse;
}
.campaign-table th {
  font-size: 10px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #1f1f22;
}
.campaign-table td {
  font-size: 12px;
  color: #999;
  padding: 10px;
  border-bottom: 1px solid #141416;
  vertical-align: middle;
}
.campaign-table tr:hover td {
  background: #141416;
}
.campaign-table .name-cell {
  color: #d0d0d0;
  font-weight: 500;
  max-width: 200px;
}
.campaign-table .name-cell small {
  display: block;
  font-size: 10px;
  color: #444;
  font-weight: 400;
  margin-top: 2px;
}
.campaign-table .metric {
  color: #888;
  font-family: monospace;
  font-size: 11px;
}
.campaign-table .actions-cell {
  display: flex;
  gap: 4px;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid #1f1f22;
  border-radius: 8px;
}

/* ── Trend chart ── */
.chart-wrap {
  background: #141416;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.chart-title {
  font-size: 11px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #555;
}
.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
canvas.trend-chart {
  width: 100%;
  height: 160px;
  display: block;
}

/* ── Compare grid ── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.compare-box {
  background: #141416;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 12px 14px;
}
.compare-box h4 {
  font-size: 10px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.compare-row .label {
  font-size: 11px;
  color: #555;
}
.compare-row .val {
  font-size: 11px;
  color: #d0d0d0;
  font-family: monospace;
}

/* ── Sync badge ── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
}
.sync-badge.syncing {
  background: #1c1706;
  color: #fbbf24;
  border: 1px solid #b45309;
}
.sync-badge.done {
  background: #0f1f12;
  color: #4ade80;
  border: 1px solid #133320;
}
.sync-badge.error {
  background: #1f0f0f;
  color: #f87171;
  border: 1px solid #3f1212;
}
.sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.sync-dot.pulse {
  animation: pulse 0.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ── Misc ── */
.group-header {
  font-size: 11px;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 16px 0 8px;
}
.group-header:first-child {
  margin-top: 0;
}
.divider {
  border: none;
  border-top: 1px solid #1f1f22;
  margin: 16px 0;
}
.date-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.date-row label {
  font-size: 11px;
  color: #555;
}
.date-row input[type="date"] {
  background: #1a1a1c;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: #e0e0e0;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.status-dot.ACTIVE {
  background: #4ade80;
}
.status-dot.PAUSED {
  background: #888;
}
.status-dot.DELETED {
  background: #f87171;
}
.no-data {
  color: #2a2a2e;
  font-size: 12px;
  padding: 32px 0;
  text-align: center;
}

/* ── Inline campaign form panel ── */
.campaign-form-panel {
  background: #141416;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  transition:
    max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease,
    margin-bottom 0.32s ease;
  pointer-events: none;
}
.campaign-form-panel.open {
  max-height: 1000px;
  opacity: 1;
  margin-bottom: 20px;
  pointer-events: all;
}
.campaign-form-panel-inner {
  padding: 20px;
}
.cfp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.cfp-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.cfp-close {
  background: none;
  border: none;
  color: #444;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition:
    color 0.15s,
    background 0.15s;
}
.cfp-close:hover {
  color: #aaa;
  background: #222;
}
.cfp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cfp-grid .form-row {
  margin-bottom: 0;
}
.cfp-full {
  grid-column: 1 / -1;
}
.cfp-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #1f1f22;
  align-items: center;
  flex-wrap: wrap;
}
.cfp-err {
  flex: 1;
  font-size: 11px;
  color: #f87171;
  min-height: 16px;
  min-width: 200px;
}

/* ── Special categories checkboxes ── */
.cat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
}
.cat-label input[type="checkbox"] {
  width: auto;
  accent-color: #4f46e5;
}
