/* DESIGN.md — Intercom-inspired. See /DESIGN.md for the full spec.
   Inter is the free substitute for Saans; JetBrains Mono for SaansMono. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400&display=swap');

:root {
  --ink: #111111;
  --on-primary: #ffffff;
  --ink-muted: #626260;
  --ink-subtle: #7b7b78;
  --ink-tertiary: #9c9fa5;
  --canvas: #f5f1ec;
  --surface-1: #ffffff;
  --surface-2: #ebe7e1;
  --hairline: #d3cec6;
  --hairline-soft: #ebe7e1;
  --fin-orange: #ff5600;
  --semantic-error: #c41c1c;

  /* Status pill colors are fixed across themes via these aliases — overridden in dark mode below */
  --status-ok-bg: #e3f7eb;
  --status-ok-fg: #0a7a36;
  --status-warn-bg: #fdecdc;
  --status-warn-fg: #8a4a00;
  --error-bg: #fbe9e9;
  --error-border: #e8c7c7;
  --success-bg: #e3f7eb;
  --success-border: #b9e4c8;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;

  --font-sans: 'Inter', 'Saans Fallback', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SaansMono Fallback', ui-monospace, monospace;
}

/* Dark mode — pure near-black canvas, dark gray cards, white type.
   Buttons auto-invert because they reference --ink for their background. */
:root[data-theme="dark"] {
  --ink: #ffffff;
  --on-primary: #0a0a0a;
  --ink-muted: #a8a8a4;
  --ink-subtle: #888884;
  --ink-tertiary: #666664;
  --canvas: #0a0a0a;
  --surface-1: #1c1c1b;
  --surface-2: #262624;
  --hairline: #2e2e2c;
  --hairline-soft: #1f1f1e;
  --semantic-error: #e26666;

  --status-ok-bg: #133b22;
  --status-ok-fg: #6fd998;
  --status-warn-bg: #3a2a14;
  --status-warn-fg: #f0c389;
  --error-bg: #3a1818;
  --error-border: #5a2424;
  --success-bg: #133b22;
  --success-border: #1e5d36;

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.50;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Top bar — cream sticky nav with hairline divider */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--s-lg);
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  height: 56px;
}
.topbar strong {
  font-weight: 500;
  letter-spacing: -0.3px;
  font-size: 17px;
}
.topbar-right { display: flex; gap: var(--s-md); align-items: center; }
.inline { display: inline; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
}
.link-button:hover { text-decoration: underline; }

/* Page wrappers */
.page {
  max-width: 1080px;
  margin: var(--s-xl) auto var(--s-xxl);
  padding: 0 var(--s-lg);
}

.auth-page {
  max-width: 360px;
  margin: 10vh auto;
  padding: 0 var(--s-md);
}
.auth-page h1 {
  margin: 0 0 var(--s-md);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.5px;
  text-align: center;
  line-height: 1.20;
}

/* Cards — white lift on cream, hairline border, NO shadow */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-lg);
}
.card + .card { margin-top: var(--s-md); }
.card h2 {
  margin: 0 0 var(--s-sm);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

/* Forms */
.form { display: flex; flex-direction: column; gap: var(--s-md); }
.form label {
  display: flex;
  flex-direction: column;
  gap: var(--s-xxs);
  font-size: 14px;
  font-weight: 500;
}
.form input,
.form textarea,
.form select {
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font: inherit;
  font-weight: 400;
  background: var(--surface-1);
  color: var(--ink);
}
.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--ink);
}
.form button[type="submit"] {
  padding: 10px 18px;
  background: var(--ink);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.20;
  cursor: pointer;
  align-self: flex-start;
}
.form button[type="submit"]:hover { background: #000; }

.error {
  padding: var(--s-sm) var(--s-md);
  background: var(--error-bg);
  color: var(--semantic-error);
  border: 1px solid var(--error-border);
  border-radius: var(--r-md);
  font-size: 14px;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--ink); }
.plain-link { color: inherit; text-decoration: none; }
.plain-link:hover { text-decoration: none; }

/* Page header (title + action) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-lg);
  gap: var(--s-md);
}
.page-header h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.8px;
  line-height: 1.15;
}
.back-link {
  display: inline-block;
  margin-bottom: var(--s-xs);
  font-size: 14px;
  color: var(--ink-muted);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* Buttons (as links / inline forms) */
.button {
  display: inline-block;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.20;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: #000; text-decoration: none; }
.button.secondary {
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.button.secondary:hover { background: var(--canvas); }
.button.danger { background: var(--semantic-error); }
.button.danger:hover { background: #a01818; }

.form-actions { display: flex; gap: var(--s-sm); align-items: center; }
.cancel-link { font-size: 14px; color: var(--ink-muted); }

/* Tables */
.card.no-padding { padding: 0; overflow: hidden; }
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: var(--s-sm) var(--s-md);
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 14px;
}
.data-table th {
  background: var(--canvas);
  font-weight: 500;
  color: var(--ink-muted);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--canvas); }

/* Status pills */
.status {
  display: inline-block;
  padding: 2px var(--s-xs);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.40;
}
.status-ok { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.status-warn { background: var(--status-warn-bg); color: var(--status-warn-fg); }

/* Config dl */
.config {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--s-sm) var(--s-lg);
  margin: 0;
  font-size: 14px;
}
.config dt { color: var(--ink-muted); font-weight: 500; }
.config dd { margin: 0; word-break: break-all; }
.config dd.notes { white-space: pre-wrap; word-break: normal; }

.empty { text-align: center; color: var(--ink-muted); }

/* Danger card */
.card.danger { border-color: var(--error-border); }
.card.danger h2 { color: var(--semantic-error); }

code {
  font-family: var(--font-mono);
  background: var(--canvas);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-size: 13px;
  border: 1px solid var(--hairline-soft);
}

.preview-table-header {
  padding: var(--s-lg) var(--s-lg) var(--s-sm);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-md);
}
.preview-table-header h2 { margin: 0; }

.skipped-list {
  list-style: none;
  padding: 0;
  margin: var(--s-xs) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-xxs) var(--s-md);
  font-size: 14px;
}
.skipped-list li { padding: 2px 0; }

.date-row {
  display: flex;
  align-items: end;
  gap: var(--s-md);
}
.date-row label { flex: 0 0 auto; }
.date-row button {
  height: 40px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.20;
  cursor: pointer;
}
.date-row button:disabled { opacity: 0.5; cursor: wait; }

.invoice-status { margin-top: var(--s-sm); }
.invoice-success {
  margin-top: var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--r-md);
  font-size: 14px;
}
.invoice-success p { margin: var(--s-xxs) 0; }

/* Price settings — collapsible card */
.price-settings { padding: 0; }
.price-settings > .card-summary {
  list-style: none;
  cursor: pointer;
  padding: var(--s-lg);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-md);
  user-select: none;
}
.price-settings > .card-summary::-webkit-details-marker { display: none; }
.price-settings > .card-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--s-xs);
  transition: transform 0.15s ease;
  color: var(--ink-tertiary);
}
.price-settings[open] > .card-summary::before { transform: rotate(90deg); }
.card-summary-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.3px;
}
.card-summary-sub { font-size: 14px; color: var(--ink-muted); }
.price-settings > :not(.card-summary) {
  padding-left: var(--s-lg);
  padding-right: var(--s-lg);
}
.price-settings > :last-child { padding-bottom: var(--s-lg); }

.recommended-toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--s-xs);
  margin: 0 0 var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md);
  font-size: 14px;
  cursor: pointer;
}
.recommended-toggle input[type="checkbox"] { margin-top: 3px; }

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--s-xs) var(--s-sm);
  margin-top: var(--s-xs);
}
.tier-cell { display: flex; flex-direction: column; gap: var(--s-xxs); }
.tier-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}
.tier-input-wrap { position: relative; display: flex; align-items: center; }
.tier-prefix {
  position: absolute;
  left: var(--s-xs);
  color: var(--ink-tertiary);
  font-size: 14px;
  pointer-events: none;
}
.tier-input-wrap input {
  width: 100%;
  padding: 8px 10px 8px 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font: inherit;
  background: var(--surface-1);
  font-size: 14px;
}
.tier-input-wrap input:focus {
  outline: none;
  border-color: var(--ink);
}

/* Translate button + Google Translate widget chrome suppression */
.translate-btn {
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 6px 12px;
  background: var(--surface-1);
  color: var(--ink);
  cursor: pointer;
}
.translate-btn:hover {
  background: var(--canvas);
  text-decoration: none;
}

/* App-wide footer (injected by theme.js on every page) */
.app-footer {
  max-width: 1080px;
  margin: var(--s-xxl) auto var(--s-lg);
  padding: var(--s-md) var(--s-lg);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-md);
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: var(--ink-muted);
  border-top: 1px solid var(--hairline-soft);
}
.app-footer a {
  color: var(--ink-muted);
  text-decoration: none;
}
.app-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Theme (dark mode) toggle — same chrome as the translate button */
.theme-btn {
  font-size: 16px;
  line-height: 1;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 6px 10px;
  background: var(--surface-1);
  color: var(--ink);
  cursor: pointer;
}
.theme-btn:hover {
  background: var(--canvas);
  text-decoration: none;
}

#google_translate_element { display: none !important; }
.goog-te-banner-frame.skiptranslate { display: none !important; }
body { top: 0 !important; }
.goog-tooltip,
.goog-tooltip:hover,
.goog-text-highlight {
  display: none !important;
  background: none !important;
  box-shadow: none !important;
}
