:root {
  --accent: #e65100;
  --accent-strong: #bf360c;
  --accent-soft: #fff3e0;
  --danger: #c62828;

  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #1c1e21;
  --text-muted: #6b7078;

  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 24 30 / 6%), 0 3px 10px rgb(20 24 30 / 5%);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff8a3d;
    --accent-strong: #ffab70;
    --accent-soft: #3a2414;
    --danger: #ef5350;

    --bg: #111214;
    --surface: #1b1d20;
    --border: #2b2e33;
    --text: #e8e9ec;
    --text-muted: #9a9ea6;

    --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 3px 10px rgb(0 0 0 / 25%);

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Color Emoji", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ───────────────────────────────────────────── entrada ── */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login__card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}

.login__logo { font-size: 56px; }
.login__card h1 { margin: 8px 0; }
.login__button { display: flex; justify-content: center; margin-top: 20px; min-height: 44px; }

.alert { padding: 10px 12px; border-radius: 10px; margin-top: 16px; text-align: left; }
.alert--error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* ───────────────────────────────────────────── estrutura ── */

.app { min-height: 100dvh; padding-bottom: 120px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--accent);
  color: #fff;
}

.topbar__title {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 70%);
  background: rgb(255 255 255 / 20%) center / cover no-repeat;
  color: #fff;
  font-weight: 700;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent-soft);
  color: var(--text);
}

.content { max-width: 720px; margin: 0 auto; padding: 12px 16px; }

.section-title { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 20px 4px 8px; }

.section-toggle {
  border: 0;
  background: none;
  color: var(--text-muted);
  padding: 16px 4px 8px;
  font-weight: 600;
}

.empty { text-align: center; padding: 48px 16px; }
.empty__icon { font-size: 40px; letter-spacing: 4px; }

.callout {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 8px;
}
.callout__icon { font-size: 28px; }

/* ───────────────────────────────────────────── cartões ── */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  border-left: 5px solid var(--sport);
  cursor: pointer;
}

.card__icon { font-size: 26px; }
.card__body { flex: 1; min-width: 0; }
.card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-muted); font-size: 0.85rem; }

.badge { font-size: 0.8rem; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.badge--todo { background: var(--border); color: var(--text-muted); }
.badge--sent { background: color-mix(in srgb, #2e7d32 18%, transparent); color: #2e7d32; }
.badge--changed { background: color-mix(in srgb, #f9a825 25%, transparent); color: #8a5a00; }

/* ───────────────────────────────────────────── treino ── */

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 5px solid var(--sport);
  padding: 14px 16px;
}

.hero__sport { font-weight: 700; color: var(--sport); }
.hero__facts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.hero__desc { margin: 10px 0 0; white-space: pre-wrap; }

.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.steps--inner { margin: 8px 0 0 8px; }

.step {
  background: var(--surface);
  border-radius: 10px;
  border-left: 5px solid var(--step, var(--border));
  padding: 8px 12px;
  box-shadow: var(--shadow);
}

.step--repeat {
  background: transparent;
  box-shadow: none;
  border: 2px dashed var(--border);
  border-left: 5px solid #6d4c41;
}

.step__head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.step__type { font-size: 0.8rem; color: var(--step); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.step__main { font-size: 1.05rem; font-weight: 600; }
.step__target { font-weight: 400; color: var(--text-muted); }
.step__target::before { content: "· "; }
.step__notes { color: var(--text-muted); font-size: 0.9rem; font-style: italic; }

.step__row { display: flex; align-items: center; gap: 8px; }
.step__info { flex: 1; min-width: 0; cursor: pointer; }

.step__tools { display: flex; gap: 2px; margin-left: auto; }
.step__tools button {
  border: 0;
  background: var(--bg);
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

/* ───────────────────────────────────────────── formulários ── */

.editor { display: grid; gap: 12px; }

.field { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  font-weight: 400;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  width: 100%;
  min-width: 0;
}
.field textarea { resize: vertical; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

.input-unit { display: flex; gap: 6px; align-items: center; }
.input-unit input { flex: 1; }
.field .input-unit select { width: 72px; flex: none; padding: 10px 6px; }
.unit { color: var(--text-muted); }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented__item {
  flex: 1;
  min-width: 90px;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 600;
}
.segmented__item.is-on { border-color: var(--sport); background: color-mix(in srgb, var(--sport) 14%, var(--surface)); color: var(--sport); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 600;
}
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }

.add-row { display: flex; flex-wrap: wrap; gap: 6px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--danger { color: var(--danger); }
.btn--small { padding: 6px 12px; font-size: 0.9rem; }
.btn--ghost { border-style: dashed; background: transparent; margin-top: 6px; }
.btn:disabled { opacity: 0.6; }

.actions { display: grid; gap: 10px; margin-top: 20px; }
.actions__row { display: flex; flex-wrap: wrap; gap: 8px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 16px 16px;
  margin-bottom: 14px;
}
.panel .section-title { margin-left: 0; }

.plain { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; }

/* ───────────────────────────────────────────── botões flutuantes ── */

.fabs {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 5;
}

.fab {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgb(0 0 0 / 25%);
}
.fab--ai { background: #6a1b9a; }

.install-btn {
  position: fixed;
  left: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 600;
  z-index: 5;
}

/* ───────────────────────────────────────────── folha, ocupado, aviso ── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.sheet {
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  display: grid;
  gap: 12px;
}
.sheet__title { margin: 0; font-size: 1.15rem; }
.sheet__body { display: grid; gap: 12px; }
.sheet__body p { margin: 0; }
.sheet__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.busy {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 40%);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 16px;
}
.busy__card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
}
.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  background: #222;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 50;
  box-shadow: 0 4px 14px rgb(0 0 0 / 30%);
}
