:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #dde3ea;
  --text: #182230;
  --muted: #667085;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --green: #16a34a;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
  font-size: 15px;
}

a {
  text-decoration: none;
}

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(221, 227, 234, 0.9);
  backdrop-filter: blur(14px);
}

.app-nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}

.app-brand:hover {
  color: var(--primary);
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 0.88rem;
}

.app-toggler {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
}

.app-menu {
  gap: 4px;
}

.app-menu .nav-link {
  color: #465466;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 650;
}

.app-menu .nav-link:hover,
.app-menu .nav-link:focus {
  color: var(--primary);
  background: #eef4ff;
}

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  margin-right: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.btn-exit {
  border-color: var(--line);
}

.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card,
.content-card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 30px;
}

.content-card {
  padding: 22px;
}

.metric-card {
  padding: 20px;
  height: 100%;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1);
}

.metric-value {
  margin-top: 6px;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
}

h1,
h2,
h3,
.h3,
.h4,
.h5,
.h6 {
  font-weight: 800;
}

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

.btn {
  border-radius: 8px;
  font-weight: 700;
  min-height: 38px;
}

.btn-sm {
  min-height: 32px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: #b7cdfb;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--primary);
  border-color: var(--primary);
}

.form-label {
  color: #344054;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-control,
.form-select {
  border-color: #cfd8e3;
  border-radius: 8px;
  min-height: 42px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.table {
  color: var(--text);
}

.table thead th {
  background: #f4f6f9;
  color: #475467;
  font-size: 0.78rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.table td,
.table th {
  vertical-align: middle;
  padding: 12px;
}

.table-responsive {
  border-radius: 8px;
}

.alert {
  border-radius: 8px;
  border: 1px solid transparent;
}

.foto-thumb {
  width: 100%;
  max-width: 220px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef2f6;
}

.body-feature-badge,
.body-history-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.body-upload-card {
  display: block;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.body-upload-card:hover,
.body-upload-card:focus-within {
  border-color: #9bb8f4;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.body-upload-label {
  display: block;
  margin-bottom: 9px;
  color: #344054;
  font-weight: 800;
}

.body-upload-preview {
  display: grid;
  height: 220px;
  margin-bottom: 10px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #aebaca;
  border-radius: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #edf1f5 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f5 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
}

.body-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.body-upload-card.is-processing {
  border-color: #e2a72e;
  box-shadow: 0 0 0 4px rgba(226, 167, 46, 0.1);
}

.body-upload-card.is-ready {
  border-color: #36a663;
  box-shadow: 0 0 0 4px rgba(54, 166, 99, 0.1);
}

.body-upload-card.has-error {
  border-color: #d04a3a;
}

.body-process-status {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.body-process-status.is-processing {
  background: #fff7e6;
  color: #8b5c00;
}

.body-process-status.is-success {
  background: #eaf8ef;
  color: #137a3a;
}

.body-process-status.is-error {
  background: #fff0ee;
  color: var(--danger);
}

.body-history-list {
  display: grid;
  gap: 14px;
}

.body-history-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.body-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  background: #fbfcfe;
}

.body-history-summary::-webkit-details-marker {
  display: none;
}

.body-history-summary::after {
  content: "+";
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
}

.body-history-card[open] .body-history-summary::after {
  content: "−";
}

.body-history-summary > span:first-child {
  display: grid;
  gap: 2px;
}

.body-history-summary small {
  color: var(--muted);
  font-weight: 600;
}

.body-history-status {
  margin-left: auto;
  background: #f2f4f7;
  color: var(--muted);
}

.body-history-status.is-complete {
  background: #eaf8ef;
  color: #137a3a;
}

.body-history-content {
  padding: 20px;
  border-top: 1px solid var(--line);
}

.body-viewer {
  max-width: 720px;
  margin: 0 auto 24px;
}

.body-viewer-stage {
  position: relative;
  height: 510px;
  overflow: hidden;
  border: 1px solid #cfd8e3;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 45%, rgba(73, 113, 178, 0.2), transparent 35%),
    linear-gradient(180deg, #182230 0%, #0f1722 100%);
  perspective: 1150px;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.body-viewer-stage:active {
  cursor: grabbing;
}

.body-viewer-stage:focus-visible {
  outline: 4px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.body-viewer-stage::after {
  position: absolute;
  right: 12%;
  bottom: 16px;
  left: 12%;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  filter: blur(13px);
  content: "";
}

.body-viewer-rotor {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.body-viewer-rotor.is-dragging {
  transition: none;
}

.body-viewer-face {
  --viewer-depth: 190px;
  position: absolute;
  top: 24px;
  left: calc(50% - 145px);
  width: 290px;
  height: 445px;
  margin: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  transform: rotateY(var(--face-angle)) translateZ(var(--viewer-depth));
  backface-visibility: hidden;
}

.body-viewer-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.body-viewer-face figcaption {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(9, 14, 22, 0.78);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.body-viewer-toolbar {
  display: grid;
  grid-template-columns: 42px minmax(150px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  max-width: 390px;
  margin: 14px auto 8px;
}

.body-viewer-position {
  text-align: center;
  font-weight: 800;
}

.body-viewer-range {
  display: block;
  width: min(100%, 390px);
  margin: 0 auto;
  accent-color: var(--primary);
}

.body-viewer-help,
.body-viewer-disclaimer {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.body-viewer-help {
  margin: 7px 0 0;
}

.body-viewer-disclaimer {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.body-viewer-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.body-viewer-thumbs figure {
  margin: 0;
}

.body-viewer-thumbs img {
  width: 100%;
  height: 190px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #e7ecf2 25%, transparent 25%),
    linear-gradient(-45deg, #e7ecf2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7ecf2 75%),
    linear-gradient(-45deg, transparent 75%, #e7ecf2 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.body-viewer-thumbs figcaption {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.body-history-notes {
  margin: 18px 0;
}

.body-empty-state {
  display: grid;
  gap: 5px;
  padding: 36px 20px;
  border: 1px dashed #b8c3d1;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.body-empty-state strong {
  color: var(--text);
}

.diff-up {
  color: #0f7b4f;
  font-weight: 800;
}

.diff-down {
  color: var(--danger);
  font-weight: 800;
}

.diff-same {
  color: var(--muted);
  font-weight: 800;
}

.treino-builder {
  display: grid;
  gap: 16px;
}

.treino-dia {
  background: #fbfcfe;
  border-color: #cfd8e3 !important;
  box-shadow: inset 4px 0 0 var(--primary);
}

.treino-grupo {
  background: #fff;
  border-color: #e1e7ef !important;
}

.treino-grupo .table {
  min-width: 880px;
}

.treino-grupo input.form-control-sm {
  min-height: 36px;
}

@media (max-width: 991.98px) {
  .app-nav-inner {
    padding: 8px 12px;
  }

  .navbar-collapse {
    padding-top: 12px;
  }

  .nav-user {
    width: 100%;
    max-width: none;
    margin: 8px 0;
  }

  .btn-exit {
    width: 100%;
  }

  .page-shell {
    padding: 20px 12px 36px;
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 14px;
  }

  .auth-card,
  .content-card,
  .metric-card {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
  }

  .auth-card,
  .content-card {
    padding: 16px;
  }

  .d-flex.gap-2,
  .d-flex.gap-3 {
    flex-wrap: wrap;
  }

  .d-flex.gap-2 > .btn,
  .d-flex.gap-3 > .btn {
    flex: 1 1 auto;
  }

  .table td,
  .table th {
    padding: 10px;
  }

  .metric-value {
    font-size: 1.55rem;
  }

  .foto-thumb {
    max-width: none;
    height: 220px;
  }

  .body-upload-preview {
    height: 250px;
  }

  .body-history-content {
    padding: 12px;
  }

  .body-viewer-stage {
    height: 440px;
  }

  .body-viewer-face {
    --viewer-depth: 145px;
    top: 18px;
    left: calc(50% - 120px);
    width: 240px;
    height: 380px;
  }

  .body-viewer-thumbs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .body-viewer-thumbs img {
    height: 210px;
  }
}
