/* ============================================================
   SUAPM Reddit Growth Tool — design system
   Single source of truth for tokens, typography, components.
   Gmail/Material density. Do not define :root in templates.
   ============================================================ */

:root {
  /* -- Color tokens ------------------------------------------------ */
  --text-primary: #1f1f1f;
  --text-secondary: #5f6368;
  --text-muted: #80868b;

  --surface: #ffffff;
  --surface-alt: #f6f8fc;
  --border: #e0e0e0;

  --accent: #C1624A;            /* SUAPM terracotta */
  --accent-soft: #f8ece8;

  --success: #1e7a3a;
  --success-soft: #e6f4ea;
  --warning: #8a5a00;
  --warning-soft: #fff4e0;
  --danger: #c5221f;
  --danger-soft: #fde9ef;

  /* -- Legacy aliases (older template CSS still references these) -- */
  --bg: var(--surface);
  --text: var(--text-primary);
  --text-mid: var(--text-secondary);
  --text-dim: var(--text-muted);
  --accent-light: var(--accent-soft);
  --black: var(--text-primary);
  --white: #ffffff;
  --warn-light: var(--warning-soft);
  --warn-text: var(--warning);

  /* -- Spacing scale (only these values) --------------------------- */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* -- Type ---------------------------------------------------------- */
  --font-ui: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Roboto Mono', ui-monospace, 'Menlo', monospace;

  --radius-card: 8px;
  --radius-pill: 16px;
  --row-h: 44px;
  --shadow-modal: 0 8px 28px rgba(0, 0, 0, 0.15);
}

/* ============ Base typography — 6 steps only ============ */

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

body {
  font-family: var(--font-ui);
  font-size: 14px;            /* body */
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.t-display  { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.t-heading  { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.t-subhead  { font-size: 15px; font-weight: 600; line-height: 1.4; }
.t-body     { font-size: 14px; font-weight: 400; line-height: 1.5; }
.t-label    { font-size: 13px; font-weight: 500; line-height: 1.4; }
.t-caption  { font-size: 12px; font-weight: 400; line-height: 1.4; color: var(--text-muted); }

.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============ Utilities ============ */

.hidden { display: none; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.scroll-x { overflow-x: auto; }

/* Material icon glyphs — sized by font-size, exempt from the text scale */
.icon {
  font-family: 'Material Symbols Outlined';
  font-size: 16px;
  vertical-align: middle;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
}

/* Icon size utilities (glyph dimensions, not text scale) */
.icon-12 { font-size: 12px; }
.icon-16 { font-size: 16px; }
.icon-24 { font-size: 24px; }
.icon-32 { font-size: 32px; }

/* ============ Buttons — one primary per view ============ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--s4);
  border-radius: 18px;
  font-family: var(--font-ui);
  font-size: 13px;            /* label */
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent); opacity: 0.88; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text-primary); }

/* ============ Cards ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  /* shadows only on modals */
}
.card-pad { padding: var(--s4); }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--s4);
  margin-bottom: var(--s5);
}
.section > h2 {
  font-size: 15px;            /* subheading */
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* ============ Pills / badges ============ */

.pill, .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;            /* caption */
  font-weight: 500;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pill-accent  { background: var(--accent-soft);  border-color: var(--accent);  color: var(--accent); }
.pill-success { background: var(--success-soft); border-color: #b7dec3;        color: var(--success); }
.pill-warning { background: var(--warning-soft); border-color: #ecd9a8;        color: var(--warning); }
.pill-danger  { background: var(--danger-soft);  border-color: #f3c4d3;        color: var(--danger); }

/* ============ Form inputs ============ */

input[type="text"], input[type="password"], input[type="number"],
textarea, select {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--s2) var(--s3);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { line-height: 1.5; resize: vertical; }
label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

/* ============ Tables — compact rows ============ */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  height: 40px;
}
table.data td.num, table.data th.num { text-align: right; }

/* ============ Toast / snackbar ============ */

.snackbar {
  position: fixed;
  bottom: var(--s5);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #2b2b2b;
  color: #ffffff;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-card);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.2s, transform 0.25s ease;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}
.snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.snackbar .icon { font-size: 18px; }

/* ============ Sidebar nav — Gmail-style ============ */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s5) var(--s3) var(--s4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-logo { display: block; padding: 0 var(--s3) var(--s1); text-decoration: none; }
.sidebar-logo img { display: block; max-width: 130px; height: auto; }
.sidebar-sub {
  font-size: 11px;             /* tiny sidebar section marker — uppercase allowed */
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 var(--s3);
  margin-bottom: var(--s5);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 40px;
  padding: 0 var(--s4);
  margin-bottom: 2px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0 20px 20px 0;   /* Gmail-style full-width rounded-right */
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item .icon { font-size: 20px; }
.nav-item-muted { color: var(--text-muted); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: var(--s3); }
.sidebar-user {
  font-size: 12px;
  color: var(--text-muted);
  padding: var(--s1) var(--s4);
  margin-bottom: var(--s1);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-user .icon { font-size: 16px; }
.nav-hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 201;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--s2) 10px;
  cursor: pointer;
}

body.has-nav { padding-left: 220px; }

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-hamburger { display: inline-flex; align-items: center; }
  body.has-nav { padding-left: 0; }
}

/* ============ Page scaffolding ============ */

.page { max-width: 820px; margin: 0 auto; padding: var(--s6) var(--s6) 80px; }
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--s1); }
.page-sub { font-size: 12px; color: var(--text-muted); margin-bottom: var(--s5); }

/* ============ Modal ============ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open, .modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--s5);
  max-width: 560px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.modal h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--s3); }
