:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #dde1e6;
  --text: #1c2430;
  --text-muted: #5b6572;
  --primary: #1f5fbf;
  --primary-dark: #164a97;
  --danger: #c0362c;
  --danger-bg: #fdecea;
  --success: #1e7e46;
  --success-bg: #e8f6ee;
  --warn: #9a6b00;
  --warn-bg: #fff6e0;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  /* Matches the sibling klaviyo-uploader app's auth card for visual
     consistency across the shared portal. */
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 9px 14px;
}
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
button:disabled { opacity: 0.6; cursor: default; }
.full-width { width: 100%; }

.error-banner, .success-banner {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.error-banner.visible { display: block; background: var(--danger-bg); color: var(--danger); }
.success-banner.visible { display: block; background: var(--success-bg); color: var(--success); }

.small-text { font-size: 13px; color: var(--text-muted); }

/* App shell (post-login pages) */
.app-shell { max-width: 1080px; margin: 0 auto; padding: 24px; }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.app-header h1 { font-size: 20px; }
.app-header .actions { display: flex; gap: 8px; }
.home-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.home-link:hover { background: var(--bg); color: var(--primary); }
/* Auth pages (login/signup/reset/etc.) have no app-header of their own
   to hold the home-link -- pin it to the corner instead, so the "back to
   portal home" affordance stays available everywhere, not just once
   already logged in. */
.home-link-corner { position: fixed; top: 16px; left: 16px; background: var(--card-bg); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.auth-logo { display: block; width: 220px; max-width: 80%; height: auto; margin: 0 auto 24px; }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat-tile .stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-tile .stat-label { font-size: 12px; color: var(--text-muted); }

.status-banner { padding: 12px 14px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }
.status-banner.pending { background: var(--warn-bg); color: var(--warn); }
.status-banner.rejected, .status-banner.suspended { background: var(--danger-bg); color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.approved, .badge.success { background: var(--success-bg); color: var(--success); }
.badge.rejected, .badge.suspended, .badge.error, .badge.failed { background: var(--danger-bg); color: var(--danger); }
.badge.inactive { background: #eee; color: #666; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; color: var(--text-muted); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Segmented-control style filter, distinct from .tabs (page navigation)
   -- this filters what's already in view rather than switching pages,
   so it reads as lighter-weight than the underlined nav tabs above. */
.filter-pills { display: inline-flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 999px; flex-shrink: 0; }
.filter-pills button { border: none; background: none; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--text-muted); }
.filter-pills button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 4px 10px; font-size: 12px; }

/* Ghost buttons: no border/fill until hovered, for actions that would
   otherwise crowd a dense table row with too many equally-heavy boxes
   (e.g. Sites/Regions "edit", or a table row's less-primary actions
   like "Reset password"). */
button.subtle { border-color: transparent; background: transparent; color: var(--text-muted); }
button.subtle:hover { background: var(--bg); border-color: var(--border); color: var(--text); }

/* Small square icon-only button -- an inline pencil next to a list of
   badges reads much lighter than a bordered "Edit" text button. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-left: 4px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  vertical-align: middle;
}
.icon-btn:hover { background: var(--bg); border-color: var(--border); color: var(--primary); }
.icon-btn svg { width: 14px; height: 14px; }

/* Sites/Regions cells hold a wrapping list of badges plus the edit
   button -- align everything on one flexible baseline instead of the
   badges and button drifting onto separate implicit lines. */
.badge-list { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Inline text-style button, e.g. a store name in a table row that opens
   its details -- reads as a link without being a navigation. */
button.link-button { border: none; background: none; padding: 0; color: var(--primary); font-size: inherit; text-align: left; }
button.link-button:hover { text-decoration: underline; }

/* Native <dialog> modal (Esc to close, focus kept inside, backdrop). */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal::backdrop { background: rgba(28, 36, 48, 0.45); }
.modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 4px 20px 20px; }

.detail-section h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.detail-list { display: grid; grid-template-columns: 150px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
/* Shows a value exactly as stored (spacing, punctuation) -- for checking
   data such as phone numbers against what Salesforce displays. */
.detail-raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg); padding: 1px 6px; border-radius: 4px; white-space: pre-wrap; }
.feed-record summary { cursor: pointer; font-size: 13px; color: var(--primary); }
.feed-record pre { margin: 8px 0 0; padding: 12px; max-height: 280px; overflow: auto; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }

@media (max-width: 520px) {
  .detail-list { grid-template-columns: 1fr; gap: 2px; }
  .detail-list dd { margin-bottom: 8px; }
}

.hidden { display: none !important; }

/* Matches klaviyo-uploader's dropzone exactly for a consistent feel
   across the portal. The real file input lives inside, hidden -- click
   proxies to it (see wireDropzone in common.js), so this still works
   for anyone who can't/doesn't want to drag-and-drop. */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--primary); background: #eaf1fb; color: var(--primary); }
.dropzone strong { color: var(--text); }
