/* ===================================================
   STOI Milk Refer & Earn — Global Stylesheet
   Mobile-first, no frameworks
   =================================================== */

/* ── Google Font ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Variables ───────────────────────────────────── */
:root {
  --brand:       #1a6fd4;
  --brand-dark:  #1459b0;
  --brand-light: #e8f0fd;
  --accent:      #ff6b2b;
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --pending-bg:  #fef9c3;
  --pending-clr: #854d0e;
  --avail-bg:    #dcfce7;
  --avail-clr:   #166534;
  --bg:          #f4f7fb;
  --card-bg:     #ffffff;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --radius:      12px;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Utility ─────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }

/* ── Container ───────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}
.container-sm {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,111,212,.15);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #e85e22; color: #fff; }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-outline {
  background: #fff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn-outline:hover { background: var(--brand-light); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ── ─────────────────── TOP NAV ─────────────────── */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.topnav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--brand);
  text-decoration: none;
}
.topnav-brand span { color: var(--accent); }
.topnav-links { display: flex; align-items: center; gap: 8px; }

/* ── HERO ────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1a6fd4 0%, #1459b0 50%, #0f3f82 100%);
  color: #fff;
  padding: 64px 16px 72px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(26px, 5vw, 48px);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
}
.hero h1 span { color: #ffcc00; }
.hero p {
  font-size: 16px;
  opacity: .85;
  max-width: 520px;
  margin: 0 auto 28px;
}
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── HOW IT WORKS ────────────────────────────────── */
.hiw {
  padding: 56px 16px;
  background: #fff;
}
.hiw h2 {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 40px;
}
.hiw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  max-width: 860px;
  margin: 0 auto;
}
.hiw-step {
  text-align: center;
  padding: 24px 16px;
}
.hiw-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand-light);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 24px;
}
.hiw-step h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.hiw-step p  { font-size: 13px; color: var(--text-muted); }

/* ── AUTH PAGES ──────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand);
}
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.auth-footer {
  text-align: center;
  font-size: 14px;
  margin-top: 20px;
  color: var(--text-muted);
}

/* ── DASHBOARD ───────────────────────────────────── */
.dashboard-wrap {
  min-height: 100vh;
  background: var(--bg);
}
.dashboard-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.welcome-header {
  margin-bottom: 24px;
}
.welcome-header h1 { font-size: 22px; font-weight: 700; }
.welcome-header p  { color: var(--text-muted); font-size: 14px; }

/* Referral link box */
.ref-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.ref-box-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.ref-code { font-size: 22px; font-weight: 800; color: var(--brand); letter-spacing: 2px; margin-bottom: 10px; }
.ref-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ref-link-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
  min-width: 0;
}
.ref-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* Money cards */
.money-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 500px) {
  .money-grid { grid-template-columns: repeat(3, 1fr); }
}
.money-card {
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.money-card.pending  { background: var(--pending-bg); }
.money-card.avail    { background: var(--avail-bg); }
.money-card.total    { background: var(--brand-light); }
.money-amount {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.money-card.pending  .money-amount { color: var(--pending-clr); }
.money-card.avail    .money-amount { color: var(--avail-clr); }
.money-card.total    .money-amount { color: var(--brand); }
.money-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* ── TABLE ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-signup   { background: #e0f2fe; color: #0369a1; }
.badge-trial    { background: #fef9c3; color: #854d0e; }
.badge-subscr   { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-pending  { background: #fef9c3; color: #854d0e; }
.badge-available{ background: #dcfce7; color: #166534; }
.badge-paid     { background: #e0f2fe; color: #0369a1; }
.badge-cancelled{ background: #f1f5f9; color: #64748b; }

/* ── REFERRAL / CUSTOMER FORM ────────────────────── */
.ref-form-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--brand-light) 0%, var(--bg) 300px);
  padding: 40px 16px 60px;
}
.ref-form-header {
  text-align: center;
  margin-bottom: 28px;
}
.ref-form-header h1 { font-size: 26px; font-weight: 800; color: var(--brand); }
.ref-form-header p  { color: var(--text-muted); font-size: 15px; margin-top: 6px; }

/* ── SUCCESS ─────────────────────────────────────── */
.success-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.success-card {
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  text-align: center;
}
.success-icon { font-size: 56px; margin-bottom: 16px; }
.success-card h1 { font-size: 24px; font-weight: 800; color: var(--brand); margin-bottom: 12px; }
.success-card p  { color: var(--text-muted); }

/* ── ADMIN ───────────────────────────────────────── */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  background: #1e293b;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.admin-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-logo h2 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}
.admin-logo p { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px; }
.admin-nav { flex: 1; padding: 12px 0; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.admin-nav a:hover, .admin-nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.admin-nav a .nav-icon { font-size: 17px; width: 22px; text-align: center; }
.admin-content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--bg);
}
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-topbar h1 { font-size: 17px; font-weight: 700; }
.admin-body { padding: 24px; }

/* Admin stats */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.admin-stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}
.admin-stat-card .value { font-size: 26px; font-weight: 800; color: var(--brand); }
.admin-stat-card .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 2px; }

/* Mobile sidebar toggle */
@media (max-width: 700px) {
  .admin-sidebar { display: none; }
  .admin-sidebar.open { display: flex; position: fixed; top:0; left:0; height:100vh; z-index:200; }
}

/* Search / filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filter-bar .form-control { width: auto; min-width: 160px; }
.filter-bar select { padding: 9px 12px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
}
.pagination a:hover { background: var(--brand-light); border-color: var(--brand); }
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  padding: 28px 24px;
}
.modal-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.modal-box p  { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .ref-code  { font-size: 18px; }
  .stat-value{ font-size: 22px; }
  .money-amount { font-size: 20px; }
}

/* ── Footer ──────────────────────────────────────── */
.site-footer {
  background: #1e293b;
  color: rgba(255,255,255,.55);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}
