:root {
  --gold: #C9911A;
  --gold-soft: rgba(201, 145, 26, 0.1);
  --gold-line: rgba(201, 145, 26, 0.2);
  --cream: #fdfaf5;
  --panel: #f5f0e8;
  --ink: #1a1208;
  --ink-soft: #6b5d4f;
  --muted: #9c8a7a;
  --border: #e8ddd0;
  --green: #2f7a3a;
  --red: #b23a2e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.tab {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { background: var(--gold-soft); color: var(--ink); }
.tab.active { background: var(--gold); color: #fff; }

.sidebar-footer {
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status { font-size: 12px; color: var(--muted); }

main {
  flex: 1;
  padding: 24px;
  max-width: 1120px;
  min-width: 0;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

.field input {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  background: #fff;
}

.stat .n { font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1; }
.stat .l { font-size: 13px; color: var(--ink-soft); margin-top: 6px; text-transform: capitalize; }

h1 { font-size: 1.9rem; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.02em; }
.sub { color: var(--ink-soft); margin: 0 0 28px; }

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  margin-bottom: 24px;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.row:hover { border-color: var(--gold); }

.thumb {
  width: 120px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel);
}

.row-body { flex: 1; min-width: 0; }

.row-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.row-meta { font-size: 13px; color: var(--muted); }
.row-url {
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  word-break: break-all;
}
.row-url:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.pending { background: var(--gold-soft); color: var(--gold); }
.badge.approved { background: #e6f4ea; color: var(--green); }
.badge.rejected { background: #fbeae6; color: var(--red); }
.badge.posted { background: var(--ink); color: #fff; }

.comment {
  background: var(--panel);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: 6px;
  margin: 8px 0;
  font-size: 14px;
  font-style: italic;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--gold);
  cursor: pointer;
  transition: filter 0.15s;
}
button:hover { filter: brightness(1.08); }

.btn-approve { background: var(--gold); color: #fff; }
.btn-deny { background: #fff; color: var(--red); }
.btn-post { background: var(--ink); color: #fff; }
.btn-modify { background: #fff; color: var(--ink-soft); border-style: dashed; }
.btn-ghost { background: transparent; color: var(--ink-soft); }

.empty { padding: 32px; text-align: center; color: var(--muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 8, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--border);
}

.modal h2 { margin: 0 0 12px; font-size: 1.2rem; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.modal input, .modal select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}
.modal .row-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }
.modal .footer-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--ink-soft); font-weight: 600; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.totals { margin-top: 16px; padding: 14px 18px; background: var(--panel); border-radius: 8px; font-weight: 700; }
.totals .big { color: var(--gold); font-size: 20px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 1.2rem; font-weight: 800; margin: 0; }
.muted-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* Content strategy tab */
#panel-strategy table { font-size: 12.5px; }

/* SEO / Search Console tab */
.stat-tip {
  position: relative;
  display: inline-block;
  margin-left: 6px;
  color: var(--gold);
  cursor: help;
  font-size: 12px;
  vertical-align: middle;
}
.stat-tip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  max-width: 60vw;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 8px;
  z-index: 20;
  transition: opacity 0.15s;
  pointer-events: none;
  white-space: normal;
  text-align: left;
}
.stat-tip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.stat-tip:hover .stat-tip-text,
.stat-tip:focus .stat-tip-text {
  visibility: visible;
  opacity: 1;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 110px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Detailed SEO chart */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chart-range-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chart-range {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.chart-range.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.chart-legend { margin-left: auto; display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg::before { content: ''; width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-imp::before { background: var(--gold); }
.lg-click::before { background: var(--green); border-radius: 50%; }
.lg-pos::before { background: var(--ink); border-radius: 50%; }

.chart-wrap {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.seo-chart { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-label { font-size: 10px; fill: var(--muted); }
.bar-imp { fill: var(--gold); opacity: 0.75; }
.bar-imp:hover { opacity: 1; }
.line-click { fill: none; stroke: var(--green); stroke-width: 2; }
.dot-click { fill: var(--green); }
.line-pos { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 3; }
.dot-pos { fill: var(--ink); }
.hover-zone { fill: transparent; cursor: crosshair; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 30;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.chart-tooltip b { color: var(--gold); }
.chart-empty { padding: 40px; text-align: center; color: var(--muted); }
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--gold), rgba(201,145,26,.5));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.bar-label {
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: top left;
}
#panel-strategy .day-number { font-weight: 700; color: var(--gold); }
#panel-strategy .pillar { font-style: italic; color: var(--ink-soft); }
#panel-strategy .caption { max-width: 300px; }
#panel-strategy .image-plan { max-width: 200px; }
#panel-strategy .strategy-img { width: 100%; max-width: 180px; border-radius: 6px; border: 1px solid var(--border); }
#panel-strategy .hashtags { max-width: 220px; word-wrap: break-word; font-size: 0.9em; color: var(--ink-soft); }
#panel-strategy .lead-magnet { font-size: 0.9em; color: var(--ink-soft); }

/* ============
   Mobile-responsive design (targets the ACTUAL layout classes)
   ============ */
@media (max-width: 768px) {
  /* Collapse the sidebar into a top bar */
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand {
    padding: 0 4px 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
  }
  /* Tabs become a horizontally scrollable pill row */
  .tabs {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: #fff;
  }
  .tab.active { border-color: var(--gold); }
  .sidebar-footer {
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 4px 0;
    gap: 8px;
  }

  /* Main content: tighter padding */
  main { padding: 16px 14px 32px; }

  /* Topbar inputs stack and go full width */
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .field { width: 100%; }
  .field input { width: 100%; flex: 1; padding: 8px 10px; font-size: 13px; }

  /* Stat cards: 2x2 grid with tighter spacing */
  .summary { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .stat { padding: 14px 16px; }
  .stat .n { font-size: 22px; }

  /* Suggestion rows: thumbnail shrinks, content wraps */
  .row { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .thumb { width: 96px; height: 54px; }
  .row-body { flex: 1 1 100%; }

  /* Bigger touch targets for buttons */
  .actions button { padding: 10px 16px; font-size: 14px; min-height: 44px; }

  /* Section headings + notes */
  .section-head h2 { font-size: 1.05rem; }
  .muted-note { font-size: 12px; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

@media (max-width: 420px) {
  /* Very small phones: single-column stats */
  .summary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat .n { font-size: 20px; }
  .stat .l { font-size: 11px; }
  .thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  main { padding: 12px 10px 28px; }
  table { font-size: 12px; }
  th, td { padding: 8px; }
}
