/* Analog MFG — Apple-inspired design system (tokens + components + app shell) */

:root {
  /* Canvas */
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbfd;
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #86868b;
  --color-divider: rgba(0, 0, 0, 0.08);

  /* Brand */
  --color-accent: #B7410E;
  --color-accent-hover: #9A360C;
  --color-accent-soft: rgba(183, 65, 14, 0.08);
  --color-accent-text: #ffffff;

  /* Semantic */
  --color-danger: #ff3b30;
  --color-warning: #ff9f0a;
  --color-success: #34c759;
  --color-info: #0071e3;

  /* Legacy aliases (inline JS / dynamic markup) */
  --color-accent-100: #f9f0ec;
  --color-accent-200: #f0d5c8;
  --color-accent-400: #d4784a;
  --color-accent-600: #c44d18;
  --color-accent-700: #B7410E;
  --color-accent-800: #9A360C;
  --color-accent-900: #6b2508;
  --color-accent-2-100: #fff0ef;
  --color-accent-2-300: #ffb8b3;
  --color-accent-2-600: #e0352b;
  --color-accent-2-700: #ff3b30;
  --color-accent-2-800: #c62828;
  --color-neutral-100: #f5f5f7;
  --color-neutral-200: #e8e8ed;
  --color-neutral-400: #aeaeb2;
  --color-neutral-600: #6e6e73;
  --color-neutral-800: #3a3a3c;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-body: var(--font-sans);
  --font-heading: var(--font-sans);
  --font-heading-weight: 600;

  --text-display: 40px;
  --text-title: 28px;
  --text-headline: 21px;
  --text-body: 17px;
  --text-callout: 14px;
  --text-caption: 12px;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Space & radius */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 980px;

  --stage-max: 1080px;
  --bar-height: 52px;
}

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

html, body { height: 100%; margin: 0; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.47;
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-title); }
h3 { font-size: var(--text-headline); }
p { margin: 0 0 var(--space-3); }

a {
  color: var(--color-accent);
  text-underline-offset: 3px;
}
a:hover { color: var(--color-accent-hover); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-info);
  outline-offset: 2px;
}

::selection {
  background: rgba(0, 113, 227, 0.18);
}

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

/* — buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-callout);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-text);
}
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-divider);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-neutral-200); }

.btn-ghost {
  background: transparent;
  color: var(--color-accent);
  min-height: 36px;
  padding-inline: var(--space-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-accent-soft); }

.btn-block { width: 100%; margin-top: var(--space-3); }

/* — forms — */
.field > label {
  display: block;
  font-size: var(--text-callout);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font: inherit;
  font-size: var(--text-callout);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--color-text-tertiary); opacity: 1; }
.input:hover { border-color: rgba(0, 0, 0, 0.16); }
.input:focus-visible {
  border-color: var(--color-info);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}
textarea.input { min-height: 120px; resize: vertical; }

/* — segmented control — */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-pill);
  gap: 2px;
}
.seg-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  font-size: var(--text-callout);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.seg-opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.seg-opt:has(input:checked) {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.seg-opt:not(:has(input:checked)):hover { color: var(--color-text); }
.seg-opt:has(input:focus-visible) {
  outline: 2px solid var(--color-info);
  outline-offset: 2px;
}

/* — cards — */
.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.card-title {
  font-size: var(--text-headline);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}
.card-body {
  margin: 0;
  font-size: var(--text-callout);
  color: var(--color-text-secondary);
  flex: 1;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* — tags — */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}
.tag-accent { background: var(--color-accent-soft); color: var(--color-accent); }
.tag-accent-2 { background: rgba(255, 59, 48, 0.1); color: var(--color-danger); }
.tag-neutral { background: var(--color-neutral-200); color: var(--color-text-secondary); }
.tag-outline {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--color-accent);
  color: var(--color-accent);
}

/* — page head — */
.page-head {
  margin-bottom: var(--space-6);
  max-width: 720px;
}
.page-head h1 {
  font-size: clamp(28px, 5vw, var(--text-display));
  line-height: 1.1;
  margin: 0 0 var(--space-3);
}
.page-head p {
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  margin: 0;
}

h2.sec {
  font-size: var(--text-headline);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-4);
}

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

/* — tiles (chat starters) — */
.starters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4) 0 var(--space-5);
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.tile-title {
  font-size: var(--text-callout);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}
.tile-caption {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  margin-top: 4px;
}

/* — list rows — */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
  transition: background 0.15s ease;
}
.list-row:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.list-row:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.list-row:only-child { border-radius: var(--radius-lg); }
.list-row:hover { background: var(--color-surface-2); }
.list-stack {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* — KPI — */
.kpi-grid {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: var(--space-5) 0 var(--space-6);
}
.kpi {
  flex: 1 1 140px;
  min-width: 120px;
  padding: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.kpi-value {
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-label {
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════
   App shell
   ═══════════════════════════════════════════════════════════════ */

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

.app-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--bar-height);
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-divider);
}

.app-bar-inner {
  max-width: var(--stage-max);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  font-size: 18px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-accent);
  white-space: nowrap;
  /* it's the shop's own name now, so it can be long — truncate, don't push */
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.navlink {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: var(--text-callout);
  font-weight: var(--weight-regular);
  color: var(--color-text-secondary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.navlink:hover { color: var(--color-text); }
.navlink.on {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.app-bar-trail {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  flex-shrink: 0;
}

.account-menu { position: relative; }

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 8px;
  font-family: var(--font-sans);
  font-size: var(--text-callout);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease;
}
.account-btn:hover { background: var(--color-surface-2); }

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: 12px;
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  display: none;
}
.account-dropdown.open { display: block; }

.account-dropdown-meta {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.account-dropdown button,
.account-dropdown a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-callout);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.account-dropdown button:hover,
.account-dropdown a:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.sign-out-link {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.sign-out-link:hover { color: var(--color-text); }

/* Mobile bottom bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(245, 245, 247, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--color-divider);
  padding: var(--space-2) var(--space-4);
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
}
.bottom-nav-inner {
  max-width: var(--stage-max);
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  gap: var(--space-2);
}
.bottom-nav .navlink {
  flex: 1;
  text-align: center;
  padding: var(--space-2);
}

.stage {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.stage-inner {
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) 120px;
}

.page { display: none; }
.page.active { display: block; }

.page-sub { display: none; }
.page-sub.active { display: block; }

.page-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

/* — chat — */
.chat-log {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-4);
  padding: var(--space-4) 0 140px;
  min-height: calc(100vh - 380px);
}
.row-msg { display: flex; }
.row-msg.user { justify-content: flex-end; }
.bub {
  max-width: 75%;
  width: fit-content;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-body);
  line-height: 1.47;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bub.user {
  background: var(--color-accent);
  color: var(--color-accent-text);
}
.bub.bot {
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.bub.err {
  background: rgba(255, 59, 48, 0.08);
  color: var(--color-danger);
}
.bub .src {
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-3);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}
.typing {
  color: var(--color-text-tertiary);
  font-size: var(--text-callout);
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  padding: var(--space-3) var(--space-5);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--color-bg) 70%, transparent);
}
.composer-inner {
  max-width: var(--stage-max);
  margin: 0 auto;
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-3) var(--space-4);
}
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  line-height: 1.47;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  background: none;
  padding: var(--space-2) 0;
}
.composer .btn-primary {
  border-radius: var(--radius-pill);
  min-height: 40px;
  padding: 0 var(--space-5);
  flex-shrink: 0;
}

/* — dashboard / shop — */
.card-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
}
.stat-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  font-weight: var(--weight-medium);
}
.stat-big {
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
  margin-top: var(--space-2);
  letter-spacing: -0.02em;
}
.attn {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: var(--space-4);
  cursor: pointer;
  border-left: 3px solid var(--color-danger);
  margin-bottom: var(--space-3);
}
.attn-cta {
  font-size: var(--text-callout);
  color: var(--color-accent);
  white-space: nowrap;
  align-self: center;
  font-weight: var(--weight-medium);
}
.mrow { cursor: pointer; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dot.run { background: var(--color-success); }
.dot.down { background: var(--color-danger); }
.dot.idle { background: var(--color-neutral-400); }
.bar {
  height: 6px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}
.bar > i.late { background: var(--color-danger); }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

#dash-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  background: var(--color-surface);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
#dash-refresh:hover {
  color: var(--color-accent);
  background: var(--color-surface-2);
}
#dash-refresh.busy {
  color: var(--color-warning);
  cursor: default;
}
#dash-refresh.busy svg {
  animation: dash-spin 0.8s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }

.dash-head-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  width: 100%;
}
.dash-head-row h1 { margin: 0 !important; flex: 0 1 auto; }
.dash-head-row #dash-ts {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  white-space: nowrap;
}
#page-dash .page-head { max-width: none; }
#page-dash .page-head p { max-width: 720px; }

/* — upload — */
.drop {
  border: 2px dashed rgba(27, 67, 50, 0.35);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop.drag {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.upl-limits {
  font-size: var(--text-caption);
  margin-top: var(--space-3);
}
.upl-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  font-weight: var(--weight-medium);
  margin: var(--space-6) 0 var(--space-3);
}
.upl-row { padding: var(--space-3) var(--space-4); }   /* .card's gap spaces the lines */
.upl-head { gap: var(--space-3); }
.upl-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-semibold);
  font-size: var(--text-callout);
}
.upl-meta {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.upl-bar {
  height: 3px;
  margin-top: var(--space-1);
  background: var(--color-neutral-200);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.upl-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent-600);
  transition: width 0.4s ease;
}
.upl-note {
  font-size: var(--text-caption);
  line-height: 1.45;
  color: var(--color-text-secondary);
}
.upl-note.bad { color: var(--color-danger); }

/* — cycle chart — */
.chart-wrap { position: relative; }
.cycle-chart {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 190;
  overflow: visible;
}
.cycle-chart .cyc-surface { cursor: crosshair; }
.cyc-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: var(--text-caption);
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}
.cyc-tip b { font-size: var(--text-callout); font-weight: var(--weight-semibold); }
.cyc-tip span { opacity: 0.7; font-size: 11px; }
.cyc-tip.over b { color: #ffb59a; }

/* — team — */
.team-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
}
.team-row:last-child { border-bottom: none; }
.team-who {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.team-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-callout);
}
.team-you {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}
.team-email {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}
.team-role {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 8px 28px 8px 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e6e73' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.team-role:focus {
  outline: none;
  border-color: var(--color-info);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}
.team-row .lnk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.team-row .lnk:hover:not(:disabled) {
  background: var(--color-neutral-200);
  color: var(--color-text);
}
.team-row .lnk:disabled { opacity: 0.4; cursor: default; }
.team-row .lnk[id^="save-"]:not(:disabled) {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}
.team-row .lnk.danger { color: var(--color-danger); }
.team-row .lnk.danger:hover { background: rgba(255, 59, 48, 0.08); }

/* — auth — */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-7) var(--space-5);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-7) var(--space-6);
}
.auth-brand {
  font-size: 22px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-accent);
  text-align: center;
  margin-bottom: var(--space-6);
}
.auth-card h1 {
  font-size: var(--text-title);
  text-align: center;
  margin-bottom: var(--space-2);
}
.auth-hint {
  color: var(--color-text-secondary);
  font-size: var(--text-callout);
  text-align: center;
  margin: 0 0 var(--space-6);
}
.auth-msg {
  font-size: var(--text-callout);
  text-align: center;
  margin: var(--space-4) 0 0;
  min-height: 20px;
}
.auth-msg.err { color: var(--color-danger); }
.auth-msg.ok { color: var(--color-success); }
.req { color: var(--color-danger); }
.note-box {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  line-height: 1.5;
  background: var(--color-surface-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-top: var(--space-5);
}
.status-icon { color: var(--color-success); }
.status-icon.bad { color: var(--color-danger); }

/* — responsive — */
@media (max-width: 820px) {
  .app-nav { display: none; }
  .bottom-nav { display: block; }
  .stage-inner { padding-top: var(--space-5); padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .composer { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1fr; }
  input, textarea, select { font-size: 16px !important; }
  .sign-out-link { display: none; }
}

@media (max-width: 640px) {
  .team-email { flex: 1 0 100%; }
  .team-actions { flex: 1 0 100%; justify-content: flex-start; margin-top: var(--space-2); }
  .dash-head-row h1 { flex: 1 0 100%; }
  .starters { grid-template-columns: 1fr; }
  .upl-head { flex-wrap: wrap; row-gap: var(--space-1); }
  .upl-name { flex: 1 0 100%; }
  .upl-meta { flex: 1; white-space: normal; }
}

@media (max-width: 600px) {
  .cycle-chart { aspect-ratio: 640 / 230; }
}
