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

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-width: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
a,
button,
input,
select,
textarea,
label,
strong,
small,
td,
th {
  overflow-wrap: break-word;
}

img,
svg,
canvas,
video,
iframe {
  max-width: 100%;
}

input,
select,
textarea {
  min-width: 0;
}

.app-shell,
.app-content,
.app-container,
.app-card,
.auth-app-card,
.admin-card,
.workout-tile,
.exercise-app-card,
.history-item,
.profile-hero,
.settings-card,
.cardio-card,
.motivation-card {
  min-width: 0;
  max-width: 100%;
}

.app-content {
  overflow-x: hidden;
}

.app-container {
  width: 100%;
}

.app-card,
.auth-app-card,
.admin-card {
  height: auto;
}

.btn-app,
.btn-admin-primary,
.btn-admin-success,
.btn-admin-danger,
.btn-admin-neutral,
.btn,
button,
[type="submit"],
[type="button"] {
  min-height: 48px;
  border-radius: 999px;
  text-align: center;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  white-space: normal;
}

.btn-app,
.btn-admin-primary,
.btn-admin-success,
.btn-admin-danger,
.btn-admin-neutral {
  display: inline-flex;
  gap: 8px;
  padding: 0 18px;
}

.app-form,
.auth-form,
.admin-form-card form {
  width: 100%;
}

.app-form input,
.app-form select,
.app-form textarea,
.auth-form input,
.admin-filter-form input,
.admin-filter-form select,
.admin-form-grid input,
.admin-form-grid select,
.admin-form-grid textarea {
  width: 100%;
  max-width: 100%;
}

.bottom-nav {
  max-width: 100vw;
}

.bottom-nav a {
  min-width: 0;
}

.bottom-nav .label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desktop-sidebar {
  min-width: 0;
}

.desktop-nav a {
  min-width: 0;
}

.desktop-nav .label,
.brand strong,
.brand small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-grid,
.workout-list,
.history-timeline,
.exercise-stack,
.admin-grid {
  min-width: 0;
}

.section-row {
  min-width: 0;
}

.section-row > * {
  min-width: 0;
}

.badge-row {
  min-width: 0;
}

.badge {
  max-width: 100%;
}

.admin-card-actions a,
.admin-card-actions button,
.admin-card-actions form {
  min-width: 0;
}

.table-responsive {
  max-width: 100%;
  overflow-x: auto;
}

.app-table {
  max-width: 100%;
}

.cardio-page .app-shell {
  display: block;
  height: 100dvh;
}

.cardio-page .app-content {
  width: 100%;
  max-width: none;
  height: 100dvh;
  padding: 0 !important;
}

.cardio-page .desktop-sidebar,
.cardio-page .bottom-nav {
  display: none !important;
}

.cardio-content {
  width: 100%;
  height: 100dvh !important;
  overflow: hidden;
}

#map {
  min-height: 300px;
  height: clamp(300px, 46dvh, 520px) !important;
}

.tracking-dashboard {
  max-height: 58dvh;
  overflow-y: auto;
}

.tracking-header {
  min-width: 0;
}

.tracking-header h1,
.gps-status {
  min-width: 0;
}

.exercise-progress-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.exercise-progress-hint span {
  border-radius: 999px;
  background: var(--surface-container);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.exercise-progress-form,
.checkin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.exercise-progress-form input,
.checkin-grid input,
.checkin-grid select,
.checkin-grid textarea,
.timer-custom input {
  width: 100%;
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid var(--surface-container);
  background: var(--background);
  color: var(--text-primary);
  padding: 0 12px;
}

.checkin-grid textarea {
  min-height: 90px;
  padding: 12px;
}

.checkin-card,
.rest-timer {
  background: var(--surface-container);
  border-radius: 24px;
  padding: 18px;
  margin: 18px 0;
}

.rest-timer {
  display: grid;
  gap: 14px;
}

.rest-timer h3 {
  margin: 4px 0 0;
  font-size: 38px;
  line-height: 1;
  color: var(--text-primary);
}

.timer-presets,
.timer-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.timer-presets button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 900;
  padding: 0 16px;
}

.timer-custom input {
  max-width: 110px;
}

.progress-photo-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-photo-row img {
  width: 86px;
  height: 86px;
  border-radius: 18px;
  object-fit: cover;
}

.notification-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.notification-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-radius: 18px;
  background: var(--surface-container);
  padding: 0 14px;
  font-weight: 800;
}

.notification-grid input {
  width: auto;
}

@media (max-width: 919px) {
  .app-content {
    width: 100%;
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-topbar {
    align-items: flex-start;
  }

  .app-topbar h1,
  .admin-page-header h1 {
    font-size: clamp(30px, 8vw, 42px);
  }

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

  .admin-card-actions,
  .card-actions,
  .tile-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-card,
  .admin-card,
  .admin-filter-card,
  .admin-form-card,
  .auth-app-card {
    border-radius: 22px;
    padding: 18px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .section-row,
  .motivation-card,
  .cardio-card,
  .profile-hero,
  .history-item {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-app,
  .btn-admin-primary,
  .btn-admin-success,
  .btn-admin-danger,
  .btn-admin-neutral {
    width: 100%;
  }

  .admin-card-header {
    align-items: flex-start;
  }

  .admin-card-actions {
    flex-direction: column;
  }

  .admin-filter-form {
    grid-template-columns: 1fr !important;
  }

  .tracking-header {
    left: 10px;
    right: 10px;
    gap: 8px;
  }

  .tracking-header h1 {
    font-size: 1rem;
  }

  .gps-status {
    font-size: 0.72rem;
  }

  #btn-test-gps {
    display: none;
  }

  .tracking-dashboard {
    padding: 24px 16px 96px !important;
    border-radius: 26px 26px 0 0 !important;
  }

  .metric-main .metric-value {
    font-size: clamp(2.8rem, 16vw, 4.5rem) !important;
  }

  .metric-value {
    font-size: clamp(1.45rem, 7vw, 2.5rem) !important;
  }

  .controls {
    gap: 12px;
  }

  .btn-control {
    width: 72px !important;
    height: 72px !important;
    min-height: 72px;
  }

  .timer-custom,
  .timer-custom .btn-app {
    width: 100%;
  }

  .timer-custom input {
    max-width: none;
  }
}
