/* SGE — Path A warm-editorial skin (token-level port from the AMOS Path A
   reference: paper background, cream cards, tan accent, Poppins UI + IBM Plex
   Mono for numbers). Class names match the markup; behavior untouched. */

/* ---- self-hosted fonts (no CDN; CSP stays 'self') ---- */
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/poppins-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/poppins-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/poppins-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

/* ---- Path A tokens ---- */
:root {
  --paper: #F4F1E8;
  --paper-2: #EEE9DC;
  --card: #FFFFFF;
  --line: #E6E1D4;
  --line-soft: #EEEADF;
  --ink: #1B1A17;
  --ink-2: #56524A;
  --ink-3: #6E6A60;
  --muted: #8C877B;
  --faint: #A6A092;
  --accent: #A6713C;
  --accent-deep: #8E5E2E;
  --accent-soft: #F1E7D7;
  --green: #5C7348;
  --green-soft: #E7EDE0;
  --amber: #B5852F;
  --amber-soft: #F3EAD4;
  --teal: #2C5C56;
  --teal-soft: #DFE9E7;
  --red: #9A4A33;
  --red-soft: #F2E0DA;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-md: 0 1px 2px rgba(27, 26, 23, 0.04), 0 10px 28px rgba(27, 26, 23, 0.05);
  --font: 'Poppins', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  /* legacy aliases used across the markup */
  --bg: var(--paper);
  --border: var(--line);
  --error: var(--red);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); text-decoration-color: rgba(166, 113, 60, 0.4); }
a:hover { color: var(--accent); }

h1 { font-weight: 600; letter-spacing: -0.01em; }
h2 { font-weight: 600; font-size: 1.05rem; margin: 1.4rem 0 0.6rem; color: var(--ink-2); }

/* ---- auth card (login) ---- */
.card {
  background: var(--card);
  padding: 2.25rem 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: min(360px, 92vw);
}
.card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.sub { margin: 0 0 1.4rem; color: var(--muted); font-size: 0.9rem; }

label {
  display: block;
  margin-bottom: 0.95rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  font-weight: 500;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
button:hover { background: var(--accent-deep); }

.error {
  background: var(--red-soft);
  color: var(--red);
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ---- app frame v2: full-bleed header ---- */
body:has(.appbar) { display: block; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.55rem 1.5rem;
}
.logo-link { display: block; flex-shrink: 0; line-height: 0; }
.logo { height: 38px; width: auto; display: block; }
.logo-auth { height: 56px; }

/* the cream nav capsule */
.navbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
  padding: 4px;
  background: #FBFAF5;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.navbar::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* thumb-sized tap target */
  padding: 0 1.05rem;
  background: transparent;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill:hover { color: var(--ink); }
.pill.active { background: var(--ink); color: #fff; }
.pill.active:hover { color: #fff; }

.nav-right { display: flex; align-items: center; gap: 0.9rem; flex-shrink: 0; margin-left: auto; }
.identity { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.id-name { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; color: var(--ink); }
.id-role { font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.nav-logout { flex-shrink: 0; }
.nav-logout button.pill, .pill-outline {
  width: auto;
  min-height: 36px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.66rem;
}
.nav-logout button.pill:hover { background: var(--paper-2); border-color: var(--faint); color: var(--ink-2); }

/* ---- content frame: cards on paper ---- */
.frame {
  max-width: 1180px;
  margin: 1.6rem auto 3.5rem;
  padding: 0 1.5rem;
}

.pagehead { margin: 0.5rem 0 1.4rem; }
.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.headline {
  margin: 0 0 0.35rem;
  font-size: 2.4rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--ink);
}

.scard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.1rem;
}
.slabel {
  margin: 0 0 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-stats { font-size: 0.95rem; margin: 0 0 1.2rem; }

/* ---- login ---- */
.auth { display: flex; flex-direction: column; align-items: center; gap: 1.3rem; }

.muted { color: var(--muted); font-size: 0.85rem; }

.search { display: flex; gap: 0.5rem; margin: 1rem 0; }
.search input[type="search"], .search select { margin: 0; }
.search button { width: auto; padding: 0.6rem 1.1rem; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  text-decoration: none;
  padding: 0.28rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-2);
  background: #fff;
  text-transform: capitalize;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover td { background: #FBFAF5; }
th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line);
}
th a { color: var(--muted); text-decoration: none; }
th a:hover { color: var(--accent-deep); }
th.num, td.num { text-align: right; font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }

/* ---- status pills (warmed to sit on paper) ---- */
.status {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: capitalize;
}
.status-active { background: var(--green-soft); color: var(--green); }
.status-cold { background: var(--paper-2); color: var(--ink-3); }
.status-warm { background: var(--amber-soft); color: var(--amber); }
.status-won { background: var(--teal-soft); color: var(--teal); }

/* ---- customer detail ---- */
.detail { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.5rem; }
.detail dt { color: var(--muted); font-size: 0.82rem; }
.detail dd { margin: 0; font-size: 0.92rem; }
.contacts { padding-left: 1.1rem; }
.contacts li { margin-bottom: 0.3rem; font-size: 0.9rem; }

/* ---- dashboards ---- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin: 1.1rem 0; }
.tiles.minis { grid-template-columns: repeat(3, 1fr); max-width: 28rem; }
.tile {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.05rem;
  background: #FBFAF5; box-shadow: var(--shadow-sm);
}
a.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.tile-num { display: block; font-size: 1.55rem; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; }
.tile-label { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.tile-label em { font-style: normal; opacity: 0.85; }

.attention, .recent { list-style: none; padding: 0; }
.attention li, .recent li { padding: 0.45rem 0; border-bottom: 1px solid var(--line-soft); font-size: 0.9rem; }

/* ---- invested / returned panels ---- */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; background: #FBFAF5; box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; font-size: 1rem; }
.panel.returned { background: var(--accent-soft); border-color: #E3D3BC; }
.panel .pending { color: var(--muted); padding-left: 1.1rem; }
.panel li { font-size: 0.9rem; }
.panel.plan { margin: 1rem 0; background: var(--accent-soft); border-color: #E3D3BC; }

/* ---- visit timeline ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline .visit {
  border-left: 3px solid var(--accent);
  padding: 0.45rem 0 0.45rem 1rem;
  margin-bottom: 0.95rem;
}
.timeline .visit.courier { border-left-color: var(--faint); }
.visit-head { margin-bottom: 0.2rem; }
.visit-head .muted { font-family: var(--mono); font-size: 0.78rem; }
.timeline p { margin: 0.15rem 0; font-size: 0.9rem; }
.sample-lines { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.84rem; font-family: var(--mono); }
.photos { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.45rem; }
.thumb {
  width: 96px; height: 96px; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius-sm); display: block;
}

/* ---- visit form ---- */
.visit-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 1rem; padding: 0.7rem 0.9rem; }
.visit-form legend { font-size: 0.8rem; color: var(--muted); padding: 0 0.35rem; font-weight: 500; }
label.inline { display: inline-block; margin-right: 1.25rem; font-weight: 400; color: var(--ink); }
label.inline input { display: inline; width: auto; margin-right: 0.3rem; }
.visit-form textarea, .manage-form textarea { font-family: inherit; }
.visit-form button[type="submit"], .manage-form button[type="submit"] { margin-top: 0.6rem; }
#sample-results { list-style: none; padding: 0; margin: 0.3rem 0; }
#sample-results button {
  width: 100%; text-align: left; background: #fff; color: var(--ink);
  border: 1px solid var(--line); margin-bottom: 0.2rem; font-size: 0.82rem;
  font-family: var(--mono);
}
#sample-results button:hover { border-color: var(--accent); background: var(--accent-soft); }
#sample-lines { padding-left: 1.1rem; }
#sample-lines li { margin-bottom: 0.4rem; font-size: 0.88rem; font-family: var(--mono); }
#sample-lines .qty { display: inline; width: 4.5rem; margin: 0 0.4rem; }
#sample-lines button { width: auto; padding: 0.2rem 0.65rem; font-size: 0.72rem; background: var(--ink-3); }

/* ---- settings sliders ---- */
.setting { margin-bottom: 1.2rem; }
.setting label { font-size: 0.95rem; color: var(--ink); font-weight: 500; }
.setting input[type="range"] { width: 70%; display: inline-block; vertical-align: middle; margin: 0.4rem 0.6rem 0 0; accent-color: var(--accent); }
.range-value { font-weight: 600; color: var(--accent-deep); font-family: var(--mono); }
.setting .muted { margin: 0.15rem 0 0; }

/* ---- effectiveness score ---- */
.score-total { display: flex; align-items: center; gap: 1rem; margin: 1.3rem 0; }
.score-number { font-size: 3.6rem; font-weight: 600; line-height: 1; font-family: var(--mono); letter-spacing: -0.04em; }
.band-strong { color: var(--green); }
.band-watch { color: var(--amber); }
.band-needs_support { color: var(--red); }
.status-score-strong { background: var(--green-soft); color: var(--green); }
.status-score-watch { background: var(--amber-soft); color: var(--amber); }
.status-score-needs_support { background: var(--red-soft); color: var(--red); }

.score-breakdown { margin: 1rem 0 1.5rem; }
.score-row { display: grid; grid-template-columns: 11rem 1fr 16rem; gap: 0.8rem; align-items: center; margin-bottom: 0.65rem; }
.score-label { font-size: 0.9rem; font-weight: 500; }
.score-bar { background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: 999px; height: 0.7rem; overflow: hidden; }
.score-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.score-detail { font-size: 0.84rem; font-family: var(--mono); }
.score-detail .muted { font-family: var(--font); }
.legend { padding-left: 1.1rem; }
.legend li { margin-bottom: 0.35rem; font-size: 0.9rem; }

/* CSP-clean bar widths: no inline styles, enumerated classes in 5% steps. */
.w-0 { width: 0%; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; }
.w-20 { width: 20%; } .w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; }
.w-40 { width: 40%; } .w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; }
.w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; } .w-75 { width: 75%; }
.w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ---- planner ---- */
.planner-map {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  min-height: 160px;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2); /* graceful placeholder if the proxy 502s */
}
.planner-table td a { font-weight: 500; }

/* ---- responsive (field phones ~390px) ---- */
@media (max-width: 720px) {
  .frame { padding: 0 0.9rem; margin: 1rem auto 2.5rem; }
  .appbar-inner { padding: 0.45rem 0.75rem; gap: 0.6rem; }
  .logo { height: 32px; }
  .headline { font-size: 1.7rem; }
  .scard { padding: 0.9rem 0.95rem; }
  .id-role { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .panels { grid-template-columns: 1fr; }
  .score-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .detail { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .detail dt { margin-top: 0.5rem; }
  table { font-size: 0.84rem; }
  th, td { padding: 0.5rem 0.4rem; }
  .search { flex-wrap: wrap; }
  .setting input[type="range"] { width: 100%; }
}

@media (max-width: 460px) {
  .identity { display: none; }
}

/* ---- training guide ---- */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin: 0.9rem 0;
  color: var(--ink-2);
}
.guide-toc li { margin: 0.55rem 0; }
.guide-list { padding-left: 1.2rem; }
.guide-list li { margin: 0.3rem 0; }
.guide-pager { display: flex; justify-content: space-between; gap: 1rem; margin: 1.2rem 0 0; }

/* ---- guide v2: checks + progress ---- */
.guide-state { font-size: 0.8rem; color: var(--ink-2); margin-left: 0.4rem; white-space: nowrap; }
.guide-passed { color: var(--green); font-weight: 600; }
.guide-continue { font-weight: 600; }
.track-complete {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin: 0.9rem 0;
}
.track-complete-title { margin: 0; font-weight: 600; color: var(--accent-deep); }
.quiz-q { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin: 0.8rem 0; }
.quiz-q legend { font-weight: 600; padding: 0 0.3rem; }
.quiz-q label.inline { display: block; margin: 0.25rem 0; }
.quiz-verdict { font-weight: 600; }
.quiz-pass { color: var(--green); }
.quiz-fail { color: var(--red); }
.quiz-result { border-left: 4px solid var(--line); padding: 0.4rem 0.9rem; margin: 0.7rem 0; }
.quiz-result.quiz-ok { border-left-color: var(--green); }
.quiz-result.quiz-wrong { border-left-color: var(--red); }
.quiz-why { color: var(--ink-2); background: var(--paper-2); border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; }

/* ---- daily report ---- */
.tile-sub { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }
.report-nav { margin: 0 0 0.6rem; }
.report-sp { margin: 0.9rem 0 0.3rem; font-size: 0.85rem; }
.report-log { padding-left: 1.2rem; }
.report-log li { margin: 0.25rem 0; }

/* ---- visits calendar ---- */
.cal-views { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.cal-week th, .cal-month th { font-size: 0.72rem; }
.cal-week th.cal-today, .cal-month td.cal-today { background: var(--accent-soft); }
.cal-cell { vertical-align: top; min-width: 84px; }
.cal-cell.cal-today { background: var(--accent-soft); }
.cal-chip {
  display: block; margin: 0.15rem 0; padding: 0.18rem 0.45rem;
  border-radius: var(--radius-sm); font-size: 0.74rem; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.cal-chip.cal-sales { border-left: 3px solid var(--accent); }
.cal-chip.cal-rel { border-left: 3px solid var(--teal); }
.cal-chip.cal-drop { border-left: 3px solid var(--faint); background: var(--paper-2); color: var(--ink-3); }
.cal-tag { display: inline-block; margin-left: 0.35rem; font-size: 0.65rem; color: var(--muted); text-transform: lowercase; }
.cal-lane { margin: 0.9rem 0 0.3rem; font-size: 0.85rem; }
.cal-cards { padding-left: 1.2rem; }
.cal-card { margin: 0.3rem 0; padding-left: 0.5rem; border-left: 3px solid var(--accent); }
.cal-card.cal-rel { border-left-color: var(--teal); }
.cal-card.cal-drop { border-left-color: var(--faint); color: var(--ink-3); }
.cal-mcell { vertical-align: top; min-width: 70px; height: 72px; }
.cal-mcell.cal-out { opacity: 0.45; }
.cal-dnum { font-family: var(--mono); font-size: 0.78rem; text-decoration: none; }
.cal-totals { font-size: 0.68rem; color: var(--muted); margin: 0.1rem 0; }
.cal-more { display: block; font-size: 0.7rem; margin-top: 0.15rem; }
@media (max-width: 640px) {
  .cal-week, .cal-month { display: block; overflow-x: auto; }
}
