/* ============================================================
   Weaning Champs Affiliate Portal — single stylesheet
   Light + dark themes via [data-theme] on <html>
   Brand: forest green + golden amber (from the WC logo)
   ============================================================ */
:root {
  --primary: #1e6b4f;
  --primary-dark: #15503a;
  --primary-soft: #d9efe4;
  --primary-grad: linear-gradient(135deg, #1e6b4f, #2f9c6d);
  --accent: #f0a422;
  --accent-soft: #fdf0d8;
  --bg: #f4f7f5;
  --bg-grad: radial-gradient(1200px 500px at 50% -10%, #e3f2ea 0%, #f4f7f5 60%);
  --card: #ffffff;
  --card-hover: #fbfdfc;
  --text: #1d2a24;
  --muted: #66766e;
  --line: #e3e9e5;
  --danger: #d64545;
  --danger-soft: #fde4e4;
  --green: #1f9d57;
  --green-soft: #ddf3e6;
  --blue: #2563eb;
  --blue-soft: #e0eafd;
  --amber: #a96a08;
  --amber-soft: #fdeecb;
  --teal: #0f766e;
  --teal-soft: #d5f0ee;
  --gray-soft: #eef2ef;
  --chip-bg: #15503a;
  --chip-fg: #ffe9bd;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(18, 38, 29, .06), 0 4px 16px rgba(18, 38, 29, .06);
  --shadow-lift: 0 2px 4px rgba(18, 38, 29, .08), 0 10px 28px rgba(18, 38, 29, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
  --primary: #3ecf8e;
  --primary-dark: #2fb377;
  --primary-soft: rgba(62, 207, 142, .14);
  --primary-grad: linear-gradient(135deg, #24915f, #3ecf8e);
  --accent: #f4b13e;
  --accent-soft: rgba(244, 177, 62, .16);
  --bg: #0d1411;
  --bg-grad: radial-gradient(1200px 500px at 50% -10%, #14241c 0%, #0d1411 60%);
  --card: #151f1a;
  --card-hover: #18241e;
  --text: #e4eee8;
  --muted: #8fa398;
  --line: #24332b;
  --danger: #f47c7c;
  --danger-soft: rgba(244, 124, 124, .15);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, .14);
  --blue: #7ca8f7;
  --blue-soft: rgba(124, 168, 247, .15);
  --amber: #f4b13e;
  --amber-soft: rgba(244, 177, 62, .15);
  --teal: #5eead4;
  --teal-soft: rgba(94, 234, 212, .13);
  --gray-soft: #1d2a23;
  --chip-bg: #0b3527;
  --chip-fg: #ffe9bd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 14px 34px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); background-image: var(--bg-grad);
  background-attachment: fixed; color: var(--text); font-size: 15px; line-height: 1.55;
  transition: background-color .25s ease, color .25s ease;
}
a { color: var(--primary); text-decoration: none; transition: color .15s ease; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin-bottom: 4px; letter-spacing: -.2px; }
h2 { font-size: 17px; margin-bottom: 10px; letter-spacing: -.1px; }
h3 { font-size: 15px; margin-bottom: 8px; }
p { margin-bottom: 10px; }
code { background: var(--gray-soft); border-radius: 6px; padding: 1px 6px; font-size: 13px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---- shell ------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 254px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: background-color .25s ease, border-color .25s ease;
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 26px; max-width: 1200px; width: 100%; margin: 0 auto; animation: pageIn .3s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.foot { padding: 14px 24px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---- brand ------------------------------------------------ */
.brand { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.brand-logo {
  display: block; background: #fff; border-radius: 12px; padding: 9px 12px;
  box-shadow: inset 0 0 0 1px rgba(20, 55, 40, .08);
}
.brand-logo img { display: block; width: 100%; max-width: 160px; height: auto; margin: 0 auto; }
.brand-sub { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; text-align: center; margin-top: 8px; }

/* ---- nav -------------------------------------------------- */
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px; position: relative;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--text); font-weight: 500; font-size: 14px;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.nav-link:hover { background: var(--gray-soft); text-decoration: none; transform: translateX(2px); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 99px; background: var(--primary-grad);
}
.nav-icon { width: 20px; text-align: center; font-size: 13px; opacity: .8; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #3a2a05;
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 8px;
}
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.user-chip { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-grad); color: #fff;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.user-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11.5px; color: var(--muted); }

/* ---- topbar ------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 11px 24px; position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }

.theme-toggle {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; font-size: 16px; line-height: 1;
  transition: background-color .2s ease, transform .15s ease, border-color .2s ease;
}
.theme-toggle:hover { transform: translateY(-1px); background: var(--gray-soft); }
.theme-toggle .tt-sun, .theme-toggle .tt-moon {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  transition: opacity .2s ease, transform .3s ease;
}
:root:not([data-theme="dark"]) .theme-toggle .tt-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root:not([data-theme="dark"]) .theme-toggle .tt-moon { opacity: 1; }
[data-theme="dark"] .theme-toggle .tt-sun { opacity: 1; }
[data-theme="dark"] .theme-toggle .tt-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }

/* ---- cards ------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
  transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title h2 { margin-bottom: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- stat cards -------------------------------------------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, background-color .25s ease, border-color .25s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: transparent; border-radius: 99px;
}
.stat-accent::after { background: var(--primary-grad); }
.stat-amber::after { background: linear-gradient(90deg, var(--accent), #f7c96b); }
.stat-green::after { background: linear-gradient(90deg, var(--green), #7ce0a5); }
.stat-blue::after { background: linear-gradient(90deg, var(--blue), #93b8f9); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 2px; letter-spacing: -.4px; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---- badges ------------------------------------------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.badge-gray { background: var(--gray-soft); color: var(--muted); }

/* ---- tables -------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 9px 12px; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; transition: background-color .12s ease; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--gray-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* ---- forms ---------------------------------------------------- */
label.field { display: block; margin-bottom: 14px; }
label.field .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--font); font-size: 14px; background: var(--card); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .25s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled { opacity: .6; }
textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.checkline { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; font-size: 14px; }
.checkline input { margin-top: 3px; accent-color: var(--primary); }
input[type=checkbox] { accent-color: var(--primary); }

/* ---- buttons ---------------------------------------------------- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
  transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 2px 8px rgba(30, 107, 79, .3); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(30, 107, 79, .4); }
[data-theme="dark"] .btn-primary { color: #06281a; }
.btn-outline { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--gray-soft); color: var(--text); border: none; }
.btn-ghost:hover { background: var(--line); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---- flash ---------------------------------------------------- */
.flash { padding: 11px 15px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 500; animation: pageIn .3s ease both; }
.flash-success { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-warning { background: var(--amber-soft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); }

/* ---- promo code chip ------------------------------------------- */
.code-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--chip-bg); color: var(--chip-fg); font-family: ui-monospace, Consolas, monospace;
  font-size: 15px; font-weight: 700; letter-spacing: 1px;
  padding: 8px 14px; border-radius: 12px; box-shadow: var(--shadow);
}
.code-chip button {
  background: rgba(255, 255, 255, .14); border: none; color: inherit; border-radius: 7px;
  padding: 3px 9px; font-size: 12px; cursor: pointer; transition: background-color .15s ease;
}
.code-chip button:hover { background: rgba(255, 255, 255, .28); }

/* ---- link rows (My Links) --------------------------------------- */
.link-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.link-row:last-child { border-bottom: none; }
.link-thumb {
  width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: var(--gray-soft); border: 1px solid var(--line);
}
.link-meta { min-width: 0; flex: 1; }
.link-title { font-weight: 600; font-size: 14px; }
.link-url {
  font-size: 12px; color: var(--muted); font-family: ui-monospace, Consolas, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* ---- misc ------------------------------------------------------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 14px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.contract-body {
  white-space: pre-wrap; font-size: 14px; line-height: 1.7; background: var(--gray-soft);
  border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-height: 420px; overflow-y: auto;
}

/* ---- public (login/apply) pages --------------------------------- */
.public-body { background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed; }
.public-theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 50; }
.public-wrap { max-width: 460px; margin: 0 auto; padding: 48px 18px; animation: pageIn .35s ease both; }
.public-brand { text-align: center; margin-bottom: 22px; }
.public-logo {
  display: inline-block; background: #fff; border-radius: 16px; padding: 12px 20px;
  box-shadow: var(--shadow);
}
.public-logo img { display: block; width: 190px; max-width: 60vw; height: auto; }
.public-brand-sub { color: var(--muted); font-size: 12px; margin-top: 10px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lift); padding: 26px;
}
.public-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 20px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13.5px; flex-wrap: wrap; gap: 6px; }

/* ---- responsive --------------------------------------------------- */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; height: 100vh; height: 100dvh;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 50px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}
@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- print (contract) --------------------------------------------- */
@media print {
  .sidebar, .topbar, .foot, .btn, .flash, .theme-toggle, .no-print { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; }
  .contract-body { max-height: none; border: none; background: #fff; }
}
