:root {
    --brand-50: #edf5ff;
    --brand-100: #d7e9ff;
    --brand-300: #6ca8eb;
    --brand-500: #1f70d4;
    --brand-600: #185db3;
    --accent-500: #159a82;
    --surface-0: #f4f7fb;
    --surface-1: #ffffff;
    --surface-2: #e8eef6;
    --text-strong: #1b2940;
    --text-muted: #62748c;
    --border-soft: rgba(27, 41, 64, 0.14);
    --shadow-soft: 0 10px 26px rgba(19, 31, 48, 0.09);
    --shadow-lift: 0 16px 34px rgba(19, 31, 48, 0.14);
    --radius-sm: 0.7rem;
    --radius-md: 1rem;
    --radius-lg: 1.25rem;
    --bs-primary: #1f70d4;
    --bs-primary-rgb: 31, 112, 212;
    --bs-secondary: #576883;
    --bs-secondary-rgb: 87, 104, 131;
    --bs-success: #159a82;
    --bs-success-rgb: 21, 154, 130;
    --bs-info: #1f8cc1;
    --bs-info-rgb: 31, 140, 193;
    --bs-warning: #c88c2b;
    --bs-warning-rgb: 200, 140, 43;
    --bs-danger: #cb4c4c;
    --bs-danger-rgb: 203, 76, 76;
    --bs-light: #f4f7fb;
    --bs-light-rgb: 244, 247, 251;
    --bs-dark: #1f2e45;
    --bs-dark-rgb: 31, 46, 69;
    --bs-body-bg: transparent;
    --bs-body-color: #1b2940;
    --bs-border-color: rgba(27, 41, 64, 0.14);
}

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

html,
body {
    min-height: 100%;
}

body.app-shell {
    font-family: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--text-strong);
    background:
        radial-gradient(1100px 520px at -15% -22%, #d9e9ff 0%, transparent 60%),
        radial-gradient(900px 480px at 110% -18%, #d8f3ed 0%, transparent 58%),
        var(--surface-0);
    position: relative;
    overflow-x: hidden;
}

body.app-shell::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    opacity: 0.14;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
    background-size: 36px 36px;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    letter-spacing: -0.01em;
}

.app-navbar {
    background: linear-gradient(120deg, rgba(15, 31, 56, 0.94), rgba(20, 45, 79, 0.9));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 28px rgba(15, 31, 56, 0.24);
    backdrop-filter: blur(8px);
}

.app-navbar .navbar-brand {
    color: #f6f9ff;
    font-weight: 700;
    font-size: 1.2rem;
}

.app-navbar .navbar-brand:hover,
.app-navbar .navbar-brand:focus {
    color: #ffffff;
}

.app-navbar .navbar-nav .nav-link {
    color: rgba(239, 246, 255, 0.86);
    border-radius: 0.7rem;
    padding: 0.45rem 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.app-navbar .navbar-nav .nav-link:hover,
.app-navbar .navbar-nav .nav-link:focus {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.app-navbar .navbar-nav .nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.app-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(225, 236, 255, 0.3);
}

.app-main {
    max-width: 1240px;
    padding-bottom: 2.5rem;
    animation: page-enter 0.35s ease-out;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-footer {
    background: transparent;
    border-top: 1px solid var(--border-soft);
}

.app-footer .text-muted {
    color: #70849f;
}

a {
    color: var(--brand-500);
}

a:hover {
    color: var(--brand-600);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem 1rem;
}

.page-header > div:first-child {
    min-width: 0;
    flex: 1 1 320px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}

.page-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.page-actions form {
    margin: 0;
}

.workout-runner .workout-exercise-card .card-body {
    padding: 1rem 1rem 0.85rem;
}

.workout-runner .card-title {
    font-size: 1.02rem;
}

.workout-runner .input-group-text {
    min-width: 5.9rem;
    justify-content: center;
    font-weight: 600;
    font-size: 0.84rem;
}

.workout-runner .set-input {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.workout-runner .set-input.active-rep-input {
    border-color: rgba(31, 112, 212, 0.62);
    background: rgba(223, 238, 255, 0.55);
    box-shadow: 0 0 0 0.18rem rgba(31, 112, 212, 0.15);
}

.workout-runner .workout-status {
    margin-bottom: 0.85rem;
}

.workout-runner .plate-config {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: rgba(245, 249, 255, 0.72);
    padding: 0.75rem;
}

.workout-runner .plate-config p:last-child,
.workout-runner .plate-config .small > div:last-child {
    margin-bottom: 0;
}

.workout-actions {
    position: sticky;
    bottom: 0.75rem;
    z-index: 1020;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 0.9rem;
    padding: 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

.workout-runner .workout-form {
    padding-bottom: 7rem;
}

.workout-actions__prompt {
    flex: 1 1 270px;
    min-width: 210px;
}

.workout-actions__prompt .fw-semibold {
    line-height: 1.3;
}

.workout-actions__progress {
    width: 100%;
    height: 0.42rem;
    border-radius: 999px;
    background: rgba(120, 140, 170, 0.22);
    overflow: hidden;
}

.workout-actions__progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2a7de4, #1eab90);
    transition: width 0.22s ease;
}

.workout-actions__rep-controls,
.workout-actions__submit {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.workout-actions__rep-controls .btn {
    min-width: 7rem;
}

.workout-actions__session {
    flex: 0 1 13.5rem;
    min-width: 12rem;
    margin-left: auto;
}

.workout-actions__session summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.52rem 0.78rem;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: rgba(245, 249, 255, 0.74);
    color: #3f566f;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.workout-actions__session summary::-webkit-details-marker {
    display: none;
}

.workout-actions__session[open] summary {
    border-color: rgba(31, 112, 212, 0.35);
    background: rgba(227, 238, 255, 0.86);
    color: #244f83;
}

.workout-actions__session .workout-actions__submit {
    justify-content: flex-end;
}

.workout-actions form {
    margin: 0;
}

.workout-runner-v2 {
    max-width: 940px;
    margin: 0 auto;
}

.coach-workout-form {
    margin-bottom: 1rem;
}

.coach-card .card-body {
    padding: 1.05rem 1.05rem 1.15rem;
}

.coach-card__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.7rem 1rem;
}

.coach-card__kicker {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #59718f;
    font-weight: 700;
    margin-bottom: 0.22rem;
}

.coach-card__target {
    border: 1px dashed rgba(84, 107, 137, 0.34);
    border-radius: 0.78rem;
    background: rgba(246, 250, 255, 0.74);
    padding: 0.62rem 0.7rem;
    color: #355072;
    font-size: 0.89rem;
    font-weight: 600;
}

.coach-inline-alert {
    margin-bottom: 0;
}

.coach-stage {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: rgba(247, 251, 255, 0.78);
    padding: 0.85rem;
}

.coach-stage__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coach-stage__actions .btn {
    width: 100%;
}

.coach-stage__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.coach-set-label {
    font-weight: 700;
    color: #334f71;
    margin-bottom: 0.42rem;
}

.coach-rest__time {
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #22518f;
    font-variant-numeric: tabular-nums;
}

.coach-plate-preview {
    border: 1px solid rgba(84, 107, 137, 0.25);
    border-radius: 0.72rem;
    padding: 0.62rem 0.72rem;
    background: rgba(236, 244, 255, 0.7);
}

.coach-session-card .card-body {
    padding-top: 0.88rem;
}

.coach-log-exercise {
    border: 1px solid rgba(76, 101, 131, 0.2);
    border-radius: 0.78rem;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.76);
}

.coach-log-exercise + .coach-log-exercise {
    margin-top: 0.75rem;
}

.coach-log-exercise.is-active {
    border-color: rgba(31, 112, 212, 0.4);
    background: rgba(233, 242, 255, 0.64);
}

.coach-log-exercise__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.55rem;
}

.coach-log-exercise__title {
    font-weight: 700;
    color: #324c6e;
}

.coach-log-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.62rem;
}

.coach-log-pill {
    border: 1px solid rgba(78, 103, 133, 0.28);
    border-radius: 999px;
    background: rgba(247, 251, 255, 0.96);
    color: #3f5877;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.coach-log-pill.is-pending {
    opacity: 0.85;
}

.coach-log-pill.is-hit {
    border-color: rgba(22, 153, 130, 0.42);
    background: rgba(218, 245, 237, 0.9);
    color: #1c6f5e;
}

.coach-log-pill.is-above {
    border-color: rgba(31, 140, 193, 0.4);
    background: rgba(219, 241, 252, 0.9);
    color: #145a7c;
}

.coach-log-pill.is-below {
    border-color: rgba(200, 140, 43, 0.42);
    background: rgba(251, 241, 223, 0.95);
    color: #8a5a14;
}

.coach-log-pill.is-active {
    border-color: rgba(31, 112, 212, 0.58);
    background: rgba(225, 238, 255, 0.96);
    color: #1d4f8c;
}

.coach-cancel-form {
    margin-bottom: 0.35rem;
}

.btn {
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
    transform: translateY(-1px);
}

.btn:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(31, 112, 212, 0.2);
}

.btn-primary {
    background: linear-gradient(180deg, #2a7de4, #1f70d4);
    border-color: #1f70d4;
    box-shadow: 0 8px 18px rgba(31, 112, 212, 0.25);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(180deg, #2675d7, #1b64bd);
    border-color: #1b64bd;
    box-shadow: 0 10px 20px rgba(31, 112, 212, 0.3);
}

.btn-success {
    background: linear-gradient(180deg, #1eab90, #159a82);
    border-color: #159a82;
}

.btn-info {
    color: #fff;
    background: linear-gradient(180deg, #2c9ccf, #1f8cc1);
    border-color: #1f8cc1;
}

.btn-outline-secondary,
.btn-secondary {
    border-color: rgba(69, 89, 117, 0.25);
}

.btn-outline-secondary:hover {
    background: rgba(69, 89, 117, 0.1);
    color: #304663;
    border-color: rgba(69, 89, 117, 0.4);
}

.card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    background: rgba(255, 255, 255, 0.94);
    overflow: hidden;
    transition: transform 0.24s ease, box-shadow 0.24s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
}

.card-header {
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(180deg, rgba(251, 253, 255, 0.96), rgba(241, 247, 255, 0.92));
}

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

.table-responsive {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.88);
}

.table {
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-strong);
    --bs-table-striped-bg: rgba(30, 57, 95, 0.03);
    --bs-table-hover-bg: rgba(31, 112, 212, 0.06);
    --bs-table-border-color: rgba(27, 41, 64, 0.12);
}

.table > :not(caption) > * > * {
    padding: 0.78rem 0.75rem;
    vertical-align: middle;
}

.table thead th {
    color: #5c6f88;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom-width: 1px;
}

.badge {
    border-radius: 999px;
    font-weight: 600;
    padding: 0.4em 0.7em;
}

.badge.bg-light {
    color: #405571;
    background: #edf3fa;
    border: 1px solid rgba(64, 85, 113, 0.18);
}

.form-label {
    color: #566a86;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select,
.form-check-input {
    border-radius: 0.72rem;
    border-color: rgba(49, 69, 98, 0.22);
    background-color: rgba(255, 255, 255, 0.94);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: rgba(31, 112, 212, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(31, 112, 212, 0.15);
}

.form-check-input:checked {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
}

.list-group-item {
    border-color: rgba(41, 59, 85, 0.12);
    background: transparent;
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    background: rgba(31, 112, 212, 0.06);
}

.alert {
    border-radius: var(--radius-sm);
    border-width: 1px;
    box-shadow: 0 6px 18px rgba(20, 35, 56, 0.08);
}

.alert-primary {
    background: rgba(31, 112, 212, 0.12);
    border-color: rgba(31, 112, 212, 0.28);
    color: #154f98;
}

.alert-success {
    background: rgba(21, 154, 130, 0.12);
    border-color: rgba(21, 154, 130, 0.28);
    color: #0f6f5d;
}

.alert-warning {
    background: rgba(200, 140, 43, 0.13);
    border-color: rgba(200, 140, 43, 0.3);
    color: #7f5618;
}

.alert-danger,
.alert-error {
    background: rgba(203, 76, 76, 0.12);
    border-color: rgba(203, 76, 76, 0.28);
    color: #8f3232;
}

.alert-info {
    background: rgba(31, 140, 193, 0.11);
    border-color: rgba(31, 140, 193, 0.28);
    color: #115b7c;
}

.modal-content {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lift);
}

.modal-header,
.modal-footer {
    border-color: rgba(27, 41, 64, 0.12);
}

.pagination {
    gap: 0.15rem;
}

.pagination .page-link {
    border-radius: 0.6rem;
    color: #4f637f;
    border-color: rgba(47, 65, 93, 0.2);
}

.pagination .page-link:hover {
    color: #1f70d4;
    background: rgba(31, 112, 212, 0.08);
    border-color: rgba(31, 112, 212, 0.3);
}

.pagination .active > .page-link {
    background: var(--brand-500);
    border-color: var(--brand-500);
}

.pagination .disabled > .page-link {
    color: #8ea0b8;
    background: rgba(236, 241, 247, 0.8);
}

pre,
code {
    border-radius: 0.5rem;
}

.visually-hidden-focusable:focus {
    z-index: 1081;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

@media (max-width: 991.98px) {
    .app-main {
        margin-top: 0.75rem;
    }

    .app-navbar .navbar-nav .nav-link {
        margin-top: 0.15rem;
        margin-bottom: 0.15rem;
    }
}

@media (max-width: 767.98px) {
    .page-header {
        align-items: stretch;
    }

    .page-header > div:first-child {
        flex-basis: 100%;
    }

    .page-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }

    .page-actions > .btn,
    .page-actions > a.btn,
    .page-actions > button.btn,
    .page-actions > form,
    .page-actions > .btn-group {
        width: 100%;
    }

    .page-actions > form .btn {
        width: 100%;
    }

    .page-actions > .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
    }

    .page-actions > .btn-group .btn {
        width: 100%;
    }

    .filter-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        width: 100%;
    }

    .filter-group .btn {
        flex: 1 1 calc(50% - 0.35rem);
        min-width: 108px;
    }

    .filter-group.btn-group > .btn,
    .filter-group.btn-group > .btn-group {
        margin-left: 0;
        border-radius: 999px !important;
    }

    .filter-group.filter-group-compact .btn {
        flex: 1 1 calc(33.333% - 0.35rem);
        min-width: 92px;
    }

    .workout-runner-v2 {
        max-width: 100%;
    }

    .coach-card .card-body {
        padding: 0.9rem 0.82rem 0.95rem;
    }

    .coach-card__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.52rem;
    }

    .coach-card__target,
    .coach-stage {
        padding: 0.76rem;
    }

    .coach-rest__time {
        font-size: 1.75rem;
    }

    .coach-stage__quick {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
    }

    .coach-stage__quick .btn {
        width: 100%;
    }

    #coachLogZeroBtn {
        grid-column: 1 / -1;
    }

    .coach-stage__actions .btn,
    .coach-cancel-form .btn {
        min-height: 2.8rem;
    }

    .coach-log-exercise {
        padding: 0.56rem;
    }

    .coach-log-exercise__head {
        flex-direction: column;
        align-items: stretch;
    }

    .coach-log-exercise__head .btn {
        width: 100%;
    }

    .coach-log-pill {
        flex: 1 1 calc(50% - 0.45rem);
        text-align: center;
    }

    .workout-runner .workout-exercise-card .card-body {
        padding: 0.85rem 0.8rem 0.8rem;
    }

    .workout-runner .input-group-text {
        min-width: 4.95rem;
        font-size: 0.78rem;
        padding-left: 0.45rem;
        padding-right: 0.45rem;
    }

    .workout-runner .set-input,
    .workout-runner input[type="number"] {
        min-height: 2.72rem;
        font-size: 1rem;
    }

    .workout-runner .workout-form {
        padding-bottom: 16rem;
    }

    .workout-actions {
        bottom: max(0.55rem, env(safe-area-inset-bottom));
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }

    .workout-actions__prompt,
    .workout-actions__rep-controls,
    .workout-actions__submit,
    .workout-actions__session {
        width: 100%;
    }

    .workout-actions__rep-controls,
    .workout-actions__submit {
        flex-direction: column;
        align-items: stretch;
    }

    .workout-actions__rep-controls .btn,
    .workout-actions__submit .btn,
    .workout-actions__submit form,
    .workout-actions__submit form .btn {
        width: 100%;
    }

    .workout-actions__session {
        min-width: 0;
        margin-left: 0;
    }

    .workout-actions__session summary {
        min-height: 2.6rem;
    }

    .workout-actions.is-editing .workout-actions__session {
        display: none;
    }

    .workout-actions .btn {
        min-height: 2.85rem;
    }

    .card:hover,
    .btn:hover {
        transform: none;
    }

    .table > :not(caption) > * > * {
        padding: 0.66rem 0.62rem;
    }
}
