/* ==========================================================================
   tracking-setup — global stylesheet

   Layout convention mirrors scenes-v2's CODING.md: shared styles + utilities
   live here; page-specific styles live in static/<page>.css and are imported
   per-template via {% block head %}<link rel="stylesheet" ...>{% endblock %}.

   Sections:
     1. CSS variables
     2. Base / reset
     3. Layout (topbar, container, footer)
     4. Utilities
     5. Buttons + button variants
     6. Forms + auth card
     7. Data tables
     8. Status badges
     9. Action cards + kind badges
    10. Reports (shared between detail/review)
    11. Comments thread
    12. Edit-form details (inline edit panels)
    13. Misc components (invite form, report list)
    14. Responsive
   ========================================================================== */


/* 1. CSS variables ========================================================= */
:root {
  --bg: #fafaf7;
  --bg-card: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #ddd;
  --accent: #2860d8;
  --accent-hover: #1f4baf;
  --error: #b3261e;
  --error-bg: #fce8e6;
  --success: #1b5e20;
  --success-bg: #e8f5e9;
  --warning-bg: #fff3cd;
  --info-bg: #e3f2fd;
  --info-fg: #0d47a1;
  --code-bg: #f3f3ee;
  --shaded-bg: #f5f5f0;
  --max-width: 1100px;
}


/* 2. Base / reset ========================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
section { margin-bottom: 2rem; }


/* 3. Layout (topbar, container, footer) ===================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.brand { font-weight: 600; color: var(--fg); }

.topnav { display: flex; gap: 1rem; align-items: center; }
.topnav a { color: var(--fg); }
.topnav .who { color: var(--muted); font-size: 0.9rem; margin-left: 1rem; }
.topnav .role { color: var(--muted); }
.topnav .inline { display: inline; margin: 0; }
.topnav .link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.topnav .link:hover { text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin: 1.5rem auto;
  padding: 0 1.25rem;
}

.appfoot {
  max-width: var(--max-width);
  margin: 2rem auto 1.5rem;
  padding: 0 1.25rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
}


/* 4. Utilities ============================================================= */
.row { display: flex; align-items: baseline; justify-content: space-between; }
.muted { color: var(--muted); }
.error { background: var(--error-bg); color: var(--error); padding: 0.5rem 0.75rem; border-radius: 4px; }
.success { background: var(--success-bg); color: var(--success); padding: 0.5rem 0.75rem; border-radius: 4px; }
form.inline { display: inline; }
code { background: var(--code-bg); padding: 0.05rem 0.3rem; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.9em; }


/* 5. Buttons =============================================================== */
button, .button {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--fg); text-decoration: none; }

button.primary, .button.primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
button.primary:hover, .button.primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
}

button.danger, .button.danger {
  background: var(--error); color: white; border-color: var(--error);
}
button.danger:hover, .button.danger:hover { background: #8a1d18; }

button.muted-button { color: var(--muted); }


/* 6. Forms + auth card ===================================================== */
.auth-card {
  max-width: 380px;
  margin: 3rem auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.75rem;
}
.auth-card h1 { margin-top: 0; }
.auth-card form label { display: block; margin: 0.75rem 0; font-size: 0.9rem; color: var(--muted); }
.auth-card input[type=email], .auth-card input[type=password], .auth-card input[type=text],
.auth-card input[type=url], .auth-card textarea, .auth-card select {
  display: block; width: 100%; margin-top: 0.25rem;
  padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px;
  font: inherit;
  background: var(--bg-card);
}
.auth-card button { margin-top: 0.5rem; width: 100%; }
.auth-card .button { width: auto; margin-top: 0.5rem; margin-left: 0.5rem; }

.checkbox-row { display: flex; align-items: flex-start; gap: 0.5rem; }
.checkbox-row input[type=checkbox] { margin-top: 0.25rem; }
.checkbox-row span { color: var(--fg); }


/* 7. Data tables =========================================================== */
table.data {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
table.data th, table.data td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data th { background: var(--code-bg); font-weight: 600; font-size: 0.9rem; }


/* 8. Status badges ========================================================= */
.status {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}
.status-draft, .status-proposed, .status-pending { background: #eee; color: #444; }
.status-sent, .status-in_review { background: var(--warning-bg); color: #7a4a00; }
.status-running { background: var(--warning-bg); color: #7a4400; }
.status-approved { background: var(--success-bg); color: var(--success); }
.status-implementing, .status-done { background: var(--info-bg); color: var(--info-fg); }
.status-rejected, .status-failed, .status-cost_exceeded { background: var(--error-bg); color: var(--error); }
.status-edited { background: #fff8d6; color: #7a4400; }


/* 9. Action cards + kind badges ============================================ */
.action-list { list-style: none; padding: 0; margin: 0; counter-reset: action; }
.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.85rem;
  counter-increment: action;
}
.action-card::before { content: counter(action) "."; color: var(--muted); font-weight: 600; margin-right: 0.5rem; }
.action-head { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.action-head strong { font-size: 1.05rem; flex: 1; min-width: 200px; }
.action-notes { color: #333; margin: 0.5rem 0 0.75rem; }
.notes-md { white-space: pre-wrap; font-family: inherit; margin: 0; line-height: 1.5; }
.spec { background: var(--shaded-bg); padding: 0.75rem; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 0.85rem; overflow-x: auto; }
.spec-list { padding-left: 1rem; margin: 0.5rem 0 0; }
.spec-list li { margin-bottom: 0.25rem; }
.spec-details summary { cursor: pointer; color: var(--muted); padding: 0.25rem 0; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  background: #eef;
  color: #224;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.kind-event { background: #ddebff; color: #0d3d7a; }
.badge.kind-conversion_marking { background: #fff0d6; color: #7a4400; }
.badge.kind-ads_import { background: #ffe2eb; color: #7a0030; }
.badge.kind-custom_dimension, .badge.kind-custom_metric { background: #e3f3e3; color: #1a5a1a; }
.badge.kind-search_console, .badge.kind-settings { background: #eee; color: #444; }


/* 10. Reports (shared) ===================================================== */
.report-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}
.summary-md { white-space: pre-wrap; font-family: inherit; margin: 0; line-height: 1.6; }


/* 11. Comments thread ====================================================== */
.comment-thread { background: #f7f7f2; border-radius: 4px; padding: 0.5rem 0.75rem; margin: 0.5rem 0; }
.comment { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment .small { font-size: 0.8em; }


/* 12. Edit-form panels (inline edit details) =============================== */
.edit-form, .meta-edit { margin-top: 0.5rem; }
.edit-form summary, .meta-edit summary { cursor: pointer; color: var(--muted); }
.edit-form form, .meta-edit form { margin-top: 0.5rem; padding: 0.75rem; background: #fafaf2; border-radius: 4px; }
.edit-form label, .meta-edit label { display: block; margin: 0.5rem 0; font-size: 0.9rem; }
.edit-form input[type=text], .edit-form textarea,
.meta-edit input[type=text], .meta-edit textarea {
  display: block; width: 100%; padding: 0.4rem;
  border: 1px solid var(--border); border-radius: 4px; font: inherit;
}
.edit-form .mono, textarea.mono { font-family: ui-monospace, monospace; font-size: 0.85em; }


/* 13. Misc ================================================================== */
.invite-form { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; margin-top: 0.75rem; }
.invite-form label { display: block; font-size: 0.85rem; color: var(--muted); }
.invite-form input { padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }

.report-list { list-style: none; padding: 0; margin: 0; }
.report-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 0.75rem; padding: 1rem;
}
.report-link { display: block; color: var(--fg); }


/* 14. Responsive =========================================================== */
@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .topnav { flex-wrap: wrap; }
  .invite-form { flex-direction: column; align-items: stretch; }
  .row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
}
