@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,700;1,9..40,400&display=swap');

:root {
  --brand: #EBC736;
  --action: #0EA5E9;
  --action-hover: #38BDF8;
  --action-active: #0284C7;
  --success: #34C759;
  --error: #FF3B30;
  --error-hover: #FF453A;
  --error-active: #D70015;
  --warning: #FF9F0A;

  --surface: #FFFFFF;
  --light-bg: #F6F6F6;

  --text-primary: #000000;
  --text-secondary: #525252;
  --text-tertiary: #6B6B6B;
  --text-placeholder: #A3A3A3;

  --border: #C4C4C4;
  --border-hover: #A3A3A3;
  --divider: #EEEEEE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  --dur-instant: 100ms;
  --dur-micro: 150ms;
  --dur-short: 250ms;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-toast: 0 8px 24px rgba(0,0,0,0.16);
}

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

html { font-size: 16px; }
html, body { min-height: 100vh; min-height: 100dvh; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

h1, .h1 { font-size: 32px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h2, .h2 { font-size: 24px; font-weight: 700; line-height: 1.2; }
h3, .h3 { font-size: 18px; font-weight: 700; line-height: 1.3; }
.body-lg { font-size: 18px; font-weight: 400; }
p, .body { font-size: 16px; font-weight: 400; }
.caption { font-size: 13px; color: var(--text-tertiary); }
.label-text { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: -0.04em; color: var(--text-placeholder); }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* ─── LAYOUT ──────────────────────────────────────────────────── */

.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 var(--space-6); }

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-topbar {
  border-bottom: 1px solid var(--divider);
  padding: var(--space-4) var(--space-6);
  padding-top: calc(var(--space-4) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.app-logo { height: 22px; width: auto; display: block; }

.app-nav { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }

.app-nav-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}

.app-nav-link:hover { color: var(--text-primary); }
.app-nav-link.active { color: var(--text-primary); border-bottom-color: var(--brand); }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
}

@media (max-width: 600px) { .app-main { padding: var(--space-8) var(--space-4); } }

/* ─── BUTTONS ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-instant) ease-out, border-color var(--dur-instant) ease-out;
}

.btn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); }
.btn-primary:active { background: var(--action-active); }

.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--light-bg); border-color: var(--border-hover); }

.btn-sm { min-height: 36px; padding: 7px 16px; font-size: 14px; }
.w-full { width: 100%; }

/* ─── FORMS ───────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: var(--space-2); }

.field-label { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.field-required { color: var(--error); font-size: 12px; font-weight: 700; margin-left: 4px; }
.field-helper { font-size: 13px; color: var(--text-tertiary); }

.input, textarea.input, select.input {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
}

.input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(14,165,233,0.15); }
.input::placeholder { color: var(--text-placeholder); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }

.select-wrapper { position: relative; }
.select-wrapper select { appearance: none; padding-right: 40px; }
.select-chevron { position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-tertiary); }

.field-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--error);
  font-size: 13px;
}

/* ─── CARDS ───────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.divider { border: none; border-top: 1px solid var(--divider); }

/* ─── STATUS ──────────────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  background: var(--light-bg);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-placeholder); }
.status-pill.is-installed .status-dot { background: var(--success); }
.status-pill.is-scheduled .status-dot { background: var(--warning); }

/* ─── ALERT ───────────────────────────────────────────────────── */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.alert-success { background: rgba(52,199,89,0.08); border-color: rgba(52,199,89,0.3); }

/* ─── TOAST ───────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: #1C1C1E;
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-toast);
  font-size: 14px;
  animation: toast-in var(--dur-short) ease-out;
}

.toast.out { animation: toast-out var(--dur-short) ease-in forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* ─── LOGIN PAGE ──────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  padding-top: calc(var(--space-6) + env(safe-area-inset-top));
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
}

.login-card { width: 100%; max-width: 380px; }
.login-logo { height: 28px; width: auto; display: block; margin: 0 auto var(--space-8); }
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: var(--space-2); }
.login-subtitle { font-size: 15px; color: var(--text-secondary); text-align: center; margin-bottom: var(--space-8); }
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }

/* ─── REFERRAL ────────────────────────────────────────────────── */

.referral-link-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--light-bg);
  font-size: 14px;
  overflow-x: auto;
  white-space: nowrap;
}

.referral-note {
  border-left: 3px solid var(--brand);
  padding-left: var(--space-4);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ─── UTILITIES ───────────────────────────────────────────────── */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.font-bold { font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
