/* Adidas-inspired design language: high-contrast black/white, bold uppercase
   typography, sharp corners (no soft rounding), generous whitespace, thin
   hairline borders instead of heavy shadows, minimal color used sparingly
   as accent only. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f5f5;
  --border: #e0e0e0;
  --border-strong: #111111;
  --text: #111111;
  --muted: #6e6e6e;
  --accent: #111111;      /* primary action = near-black, adidas-style */
  --accent-2: #333333;
  --green: #0a8a3f;
  --yellow: #b8860b;
  --red: #d02b2b;
  --radius: 0px;           /* sharp corners throughout */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

.app-shell {
  min-height: 100vh;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 36px 56px 100px;
}

/* Burger menu: always available from the left, with a full account footer. */
.sidebar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  width: min(320px, calc(100vw - 44px));
  height: 100dvh;
  background: #ffffff;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  transform: translateX(-101%);
  transition: transform 0.2s ease;
  overflow-y: auto;
  box-shadow: 16px 0 36px rgba(17,17,17,.14);
}
.sidebar.is-open { transform: translateX(0); }
.menu-header { display: flex; align-items: flex-start; gap: 12px; }
.menu-close, .menu-toggle { border: 1px solid var(--border-strong); background: #ffffff; color: #111111; cursor: pointer; }
.menu-close { width: 38px; height: 38px; flex: 0 0 38px; font-size: 25px; line-height: 1; font-weight: 300; }
.menu-toggle { position: relative; z-index: 20; width: 40px; height: 40px; padding: 10px 9px; display: flex; flex-direction: column; justify-content: center; gap: 5px; flex: 0 0 40px; }
.menu-toggle span { display: block; width: 20px; height: 2px; background: #111111; }
.menu-backdrop { position: fixed; z-index: 25; inset: 0; border: 0; background: rgba(0,0,0,.26); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; cursor: pointer; }
.menu-backdrop.is-visible { opacity: 1; visibility: visible; }
body.menu-open { overflow: hidden; }

.brand {
  display: block;
  flex: 1;
  padding: 0 0 20px;
  border-bottom: 2px solid var(--border-strong);
  margin-bottom: 20px;
}
.brand img { display: block; width: 100%; height: auto; }
/* The supplied logo is white artwork on black. On the platform's white canvas,
   this gives it black artwork and makes the original black field disappear. */
.logo-black { filter: invert(1); mix-blend-mode: multiply; }


.nav-group { margin-bottom: 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { background: var(--panel-2); color: var(--text); border-left-color: transparent; }
.nav-link .icon { width: 18px; text-align: center; filter: grayscale(1); }
.nav-link.pwa-install-menu { width: 100%; border: 0; background: transparent; font-family: inherit; text-align: left; -webkit-appearance: none; appearance: none; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 2px solid var(--border-strong);
}
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 14px; text-transform: none; letter-spacing: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #111111; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #ffffff; }

.btn {
  padding: 12px 22px; border: 2px solid #111111; background: #111111;
  color: #ffffff; font-weight: 800; cursor: pointer; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.06em; border-radius: 0;
  transition: background 0.12s, color 0.12s;
}
.btn:hover { background: #ffffff; color: #111111; }
.btn.ghost { background: transparent; border: 2px solid var(--border-strong); color: #111111; }
.btn.ghost:hover { background: #111111; color: #ffffff; }
.btn.full { width: 100%; }
.btn:disabled { background: var(--panel-2); color: var(--muted); border-color: var(--border); cursor: not-allowed; }
.btn:disabled:hover { background: var(--panel-2); color: var(--muted); }

.page-header { margin: 0 0 32px; }
.page-title-row { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 32px; font-weight: 900; margin: 0; text-transform: uppercase; letter-spacing: 0.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin: 8px 0 0 54px; }

.card {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 0;
  padding: 24px; margin-bottom: 24px;
}
.card h2 {
  margin: 0 0 16px; font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.07em; border-bottom: 1px solid var(--border); padding-bottom: 12px;
}
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 11px; text-transform: none; letter-spacing: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }

.badge {
  display: inline-block; padding: 4px 10px; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid currentColor;
}
.badge-green { color: var(--green); }
.badge-yellow { color: var(--yellow); }
.badge-red { color: var(--red); }

.stat-block { text-align: center; padding: 14px 0; border: 1px solid var(--border); }
.stat-block .num { font-size: 34px; font-weight: 900; line-height: 1.1; }
.stat-block .label { color: var(--muted); font-size: 11px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.05em; }

.muted { color: var(--muted); }
.error { color: var(--red); }
.small { font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.status-done { color: var(--green); font-weight: 700; }
.status-missed { color: var(--red); font-weight: 700; }
.status-pending { color: var(--yellow); font-weight: 700; }
.status-rest { color: var(--muted); }

input, select {
  width: 100%; padding: 11px 12px; margin-top: 4px; border: 1px solid var(--border-strong);
  background: #ffffff; color: var(--text); font-size: 14px; border-radius: 0; font-family: inherit;
}
/* iOS Safari gives its native date control an intrinsic minimum width. Without
   overriding it, a narrow card can be wider than its viewport. */
input[type="date"] { min-width: 0; max-width: 100%; }
button, input, select, textarea { font: inherit; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 420px; }
input:focus, select:focus { outline: none; border-color: #111111; box-shadow: 0 0 0 1px #111111; }
label { display: block; margin-bottom: 16px; font-size: 11px; color: var(--muted); text-align: left; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.consent { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 12px; text-transform: none; letter-spacing: 0; font-size: 12px; line-height: 1.45; font-weight: 500; }
.consent input { width: 16px; height: 16px; min-width: 16px; margin: 1px 0 0; accent-color: #111111; }
.consent a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.auth-note { margin: 2px 0 16px; text-align: left; line-height: 1.45; }

.banner {
  background: #111111; border: none; color: #ffffff;
  padding: 12px 16px; margin-bottom: 24px; font-size: 13px; font-weight: 600;
}

/* First-plan onboarding: informative progress rather than a blocking modal. */
.onboarding-card { border: 2px solid var(--border-strong); background: #111111; color: #fff; padding: 24px; margin: 0 0 24px; }
.onboarding-card.is-complete { background: #fff; color: var(--text); }
.onboarding-kicker { color: #bcbcbc; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 9px; }
.onboarding-card.is-complete .onboarding-kicker { color: var(--green); }
.onboarding-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.onboarding-head h2 { margin: 0 0 8px; padding: 0; border: 0; color: inherit; font-size: 18px; }
.onboarding-head p { max-width: 700px; margin: 0; color: #e3e3e3; font-size: 14px; line-height: 1.55; }
.onboarding-card.is-complete .onboarding-head p { color: var(--muted); }
.onboarding-progress { display: flex; gap: 5px; flex: 0 0 auto; padding-top: 4px; }
.onboarding-progress span { display: block; width: 32px; height: 5px; background: #5a5a5a; }
.onboarding-progress span.is-done, .onboarding-progress span.is-current { background: #fff; }
.onboarding-card.is-complete .onboarding-progress span { background: var(--border); }
.onboarding-card.is-complete .onboarding-progress span.is-done { background: var(--green); }
.onboarding-checklist { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 20px 0; font-size: 12px; font-weight: 700; }
.onboarding-checklist span { color: #bcbcbc; }
.onboarding-checklist .is-current, .onboarding-checklist .is-done { color: #fff; }
.onboarding-action { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.onboarding-card .btn { background: #fff; color: #111; border-color: #fff; }
.onboarding-card .btn:hover { background: #111; color: #fff; }
.onboarding-card.is-complete .btn { background: #111; color: #fff; border-color: #111; }
.onboarding-card.is-complete .btn:hover { background: #fff; color: #111; }
.onboarding-card .muted { color: #c9c9c9; }
.onboarding-card.is-complete .muted { color: var(--muted); }

/* Chat */
.chat-panel { display: flex; flex-direction: column; height: 480px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 4px 4px 12px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 78%; padding: 12px 16px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: #111111; color: #ffffff; }
.chat-msg.assistant { align-self: flex-start; background: #ffffff; border: 1px solid var(--border-strong); }
.chat-input-row { display: flex; gap: 0; margin-top: 12px; border: 1px solid var(--border-strong); }
.chat-input-row input { flex: 1; margin: 0; border: none; }
.chat-input-row input:focus { box-shadow: none; }
.chat-input-row .btn { border: none; border-left: 1px solid var(--border-strong); }
.chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto; text-transform: uppercase; letter-spacing: 0.04em; }

.sub-heading { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 10px; color: var(--muted); }
.integration-form { margin-bottom: 8px; }
.integration-form label { margin-bottom: 12px; }

.conn-row {
  display: flex; align-items: center; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.conn-row:last-child { border-bottom: none; }
.conn-info { flex: 1; }
.conn-name { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.conn-row a { text-decoration: none; }
.conn-help { white-space: nowrap; }

.integration-guide-overlay { position: fixed; z-index: 60; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.38); }
.integration-guide-overlay[hidden] { display: none; }
.integration-guide { position: relative; width: min(540px, 100%); max-height: min(720px, 90dvh); overflow-y: auto; background: #fff; border: 2px solid var(--border-strong); padding: 28px; box-shadow: 14px 14px 0 rgba(17,17,17,.16); }
.integration-guide h2 { margin: 0 42px 18px 0; font-size: 18px; text-transform: uppercase; }
.integration-guide ol { padding-left: 21px; margin: 0 0 20px; }
.integration-guide li { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.integration-guide-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 1px solid var(--border-strong); background: #fff; color: #111; font-size: 25px; cursor: pointer; }
.guide-redirect { margin: 0 0 20px; padding: 12px; border: 1px solid var(--border); background: var(--panel-2); }
.guide-redirect span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.guide-redirect code { display: block; overflow-wrap: anywhere; font-family: inherit; font-size: 13px; }
body.modal-open { overflow: hidden; }

/* PWA installation: Android/desktop can open the browser's native prompt.
   iPhone requires Safari's Share → Add to Home Screen flow, so keep that
   instruction one tap away instead of burying it in documentation. */
#pwa-install-guide { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.4); }
.pwa-install-dialog { position: relative; width: min(440px, 100%); border: 2px solid #111; background: #fff; padding: 28px 26px 24px; box-shadow: 10px 10px 0 rgba(17,17,17,.22); }
.pwa-install-kicker { margin: 0 0 8px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.pwa-install-dialog h2 { margin: 0 36px 18px 0; font-size: 19px; line-height: 1.2; text-transform: uppercase; }
.pwa-install-dialog ol { margin: 0; padding-left: 22px; }
.pwa-install-dialog li { margin: 0 0 13px; font-size: 15px; line-height: 1.45; }
.pwa-install-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 1px solid #111; background: #fff; color: #111; font-size: 25px; line-height: 1; cursor: pointer; }

@media (max-width: 860px) {
  .conn-row { flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 20px 20px 72px; }
  .page-title { font-size: 26px; line-height: 1.1; }
  .page-header { margin-bottom: 24px; }
  .page-sub { line-height: 1.5; }
  .card { padding: 18px; margin-bottom: 16px; }
  /* Session tables must never define the card's width on a narrow viewport.
     Keep wide data scrollable within the card instead. */
  .table-scroll { max-width: 100%; }
  .chat-panel, .plan-chat-panel { height: min(62vh, 480px); }
  .chat-input-row, .plan-chat-input-row { flex-wrap: wrap; }
  .chat-input-row input, .plan-chat-input-row input { min-width: 0; width: 100%; padding: 13px 12px; }
  .chat-input-row .btn, .plan-chat-input-row .btn { width: 100%; border-left: 0; border-top: 1px solid var(--border-strong); }
  .conn-row { align-items: flex-start; gap: 10px; }
  .conn-row .btn { width: 100%; }
  .conn-row a { width: 100%; }
  .conn-help { width: 100%; }
  .integration-guide-overlay { padding: 12px; }
  .integration-guide { padding: 22px 18px; }
  .onboarding-card { padding: 18px; }
  .onboarding-head { gap: 12px; }
  .onboarding-head h2 { font-size: 16px; }
  input, select, textarea { font-size: 16px; min-height: 46px; }
  .btn { min-height: 46px; }
}

@media (max-width: 480px) {
  .content { padding: 18px 14px 64px; }
  .menu-toggle { width: 40px; height: 40px; }
  .menu-toggle span { width: 20px; }
  .sidebar { width: min(320px, calc(100vw - 28px)); padding: 20px 16px; }
  .card { padding: 15px; }
  .page-title-row { gap: 12px; }
  .page-title { font-size: 25px; }
  .page-sub { margin-left: 0; font-size: 14px; }
  .stat-block .num { font-size: 28px; }
  .grid-3 { gap: 10px; }
}
