:root {
    color-scheme: dark;
    --bg: #08090d;
    --bg-2: #11131a;
    --panel: rgba(18, 21, 29, 0.92);
    --panel-2: rgba(24, 29, 38, 0.94);
    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.2);
    --text: #f5f7fb;
    --muted: #98a1b3;
    --muted-2: #c0c7d5;
    --danger: #ff4d68;
    --warning: #ffb547;
    --ok: #2cf296;
    --accent: #2cf296;
    --accent-2: #2cb5ff;
    --accent-3: #ff4d68;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    --radius: 8px;
    --radius-sm: 6px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8fb;
    --bg-2: #e8edf4;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-2: rgba(246, 249, 253, 0.96);
    --line: rgba(31, 40, 55, 0.12);
    --line-strong: rgba(31, 40, 55, 0.2);
    --text: #111827;
    --muted: #5e6677;
    --muted-2: #394152;
    --shadow: 0 18px 50px rgba(36, 47, 66, 0.12);
}

body[data-accent="green"] {
    --accent: #2cf296;
    --accent-2: #29d8ff;
    --accent-3: #ff4d68;
}

body[data-accent="blue"] {
    --accent: #2cb5ff;
    --accent-2: #48f2d6;
    --accent-3: #ff9a3d;
}

body[data-accent="red"] {
    --accent: #ff4d68;
    --accent-2: #ffd166;
    --accent-3: #2cb5ff;
}

body[data-accent="pink"] {
    --accent: #ff4fd8;
    --accent-2: #2cf296;
    --accent-3: #ffb547;
}

body[data-accent="orange"] {
    --accent: #ff9a3d;
    --accent-2: #2cb5ff;
    --accent-3: #2cf296;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(135deg, var(--bg), var(--bg-2));
    font-family: var(--font);
    letter-spacing: 0;
}

body[data-theme="light"] {
    background:
        linear-gradient(90deg, rgba(17, 24, 39, 0.045) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(0deg, rgba(17, 24, 39, 0.045) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(135deg, var(--bg), var(--bg-2));
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1560px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    position: sticky;
    top: 12px;
    z-index: 10;
    backdrop-filter: blur(18px);
}

.brand-block,
.topbar-controls,
.control-strip,
.theme-controls,
.summary-card,
.panel-heading,
.timeline-date,
.admin-user-main,
.admin-badges,
.status-row,
.toggle-group,
.accent-swatches {
    display: flex;
    align-items: center;
}

.brand-block {
    gap: 12px;
    min-width: 240px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 7px;
    border: 1px solid color-mix(in srgb, var(--accent), transparent 40%);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent), transparent 65%);
}

.brand-mark span {
    min-width: 0;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 16px var(--accent);
}

.brand-mark span:nth-child(1) {
    height: 55%;
    align-self: end;
}

.brand-mark span:nth-child(2) {
    height: 100%;
}

.brand-mark span:nth-child(3) {
    height: 72%;
    align-self: end;
    background: var(--accent-2);
    box-shadow: 0 0 16px var(--accent-2);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.2rem, 2vw, 1.75rem);
    line-height: 1.05;
}

h2 {
    font-size: 1rem;
    line-height: 1.2;
}

h3 {
    font-size: 0.95rem;
    line-height: 1.3;
}

.brand-block p,
.range-copy,
.muted,
.routine-meta,
.timeline-meta,
.chip small {
    color: var(--muted);
}

.topbar-controls {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    color: var(--muted-2);
    font-size: 0.76rem;
    line-height: 1;
}

.compact-field {
    width: min(220px, 40vw);
}

.date-field {
    width: 160px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--panel-2), transparent 10%);
    padding: 9px 10px;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 88px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
}

.segmented,
.toggle-group {
    min-height: 40px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
}

.segmented button,
.toggle-group button,
.text-button,
.primary-button,
.status-button {
    min-height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text);
    background: transparent;
    padding: 7px 11px;
    line-height: 1.1;
}

.segmented button.active,
.toggle-group button.active {
    color: #06100b;
    background: var(--accent);
    box-shadow: 0 0 18px color-mix(in srgb, var(--accent), transparent 50%);
}

.control-strip {
    justify-content: space-between;
    gap: 16px;
    padding: 18px 2px 14px;
    flex-wrap: wrap;
}

.range-copy {
    font-size: 0.95rem;
}

.theme-controls {
    gap: 12px;
    flex-wrap: wrap;
}

.accent-swatches {
    gap: 7px;
}

.accent-swatches button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: 0 0 16px color-mix(in srgb, var(--swatch), transparent 55%);
}

.accent-swatches button[data-accent="green"] {
    --swatch: #2cf296;
}

.accent-swatches button[data-accent="blue"] {
    --swatch: #2cb5ff;
}

.accent-swatches button[data-accent="red"] {
    --swatch: #ff4d68;
}

.accent-swatches button[data-accent="pink"] {
    --swatch: #ff4fd8;
}

.accent-swatches button[data-accent="orange"] {
    --swatch: #ff9a3d;
}

.accent-swatches button.active {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.summary-card,
.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.summary-card {
    min-height: 104px;
    align-items: stretch;
    justify-content: space-between;
    flex-direction: column;
    padding: 14px;
    overflow: hidden;
    position: relative;
}

.summary-card::after {
    content: "";
    position: absolute;
    inset: auto 12px 10px 12px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent-2));
    opacity: 0.85;
}

.summary-card span {
    color: var(--muted);
    font-size: 0.76rem;
}

.summary-card strong {
    display: block;
    font-size: clamp(1.45rem, 2vw, 2.1rem);
    line-height: 1;
    margin-top: 8px;
}

.summary-card small {
    color: var(--muted-2);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 12px;
    align-items: start;
}

.admin-panel {
    margin-bottom: 12px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-stat {
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.035);
}

.admin-stat span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    margin-bottom: 8px;
}

.admin-stat strong {
    font-size: 1.5rem;
    line-height: 1;
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: 12px;
    align-items: start;
}

.admin-user-list {
    display: grid;
    gap: 9px;
    max-height: 660px;
    overflow: auto;
    padding-right: 4px;
}

.admin-user-card,
.admin-editor {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel-2), transparent 4%);
    padding: 12px;
}

.admin-user-card {
    display: grid;
    gap: 10px;
}

.admin-user-main {
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.admin-badges {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-user-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.admin-user-metrics span {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted-2);
    padding: 4px 8px;
    font-size: 0.76rem;
}

.panel {
    padding: 14px;
    min-width: 0;
}

.planner-panel {
    grid-row: span 2;
}

.panel-heading {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.76rem;
    line-height: 1;
    margin-bottom: 5px;
}

.text-button {
    border: 1px solid var(--line);
    white-space: nowrap;
}

.text-button:hover,
.status-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.primary-button {
    width: 100%;
    margin-top: 12px;
    color: #06100b;
    background: var(--accent);
    font-weight: 700;
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent), transparent 55%);
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline-day {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel-2), transparent 4%);
    overflow: hidden;
}

.timeline-date {
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.timeline-date strong {
    font-size: 0.92rem;
}

.timeline-meta {
    font-size: 0.78rem;
}

.workout-list,
.routine-list,
.supplement-list,
.nutrition-list,
.metric-list {
    display: grid;
    gap: 9px;
}

.workout-item,
.routine-item,
.supplement-item,
.log-item {
    display: grid;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.035);
}

.workout-top,
.routine-top,
.supplement-top,
.log-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.routine-meta,
.timeline-meta,
.details-line,
.log-item p,
.supplement-item p {
    font-size: 0.82rem;
    line-height: 1.35;
}

.details-line {
    color: var(--muted-2);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted-2);
    padding: 3px 8px;
    font-size: 0.76rem;
    white-space: nowrap;
}

.badge.complete,
.badge.taken,
.badge.active,
.badge.admin {
    color: var(--ok);
    border-color: color-mix(in srgb, var(--ok), transparent 50%);
}

.badge.skipped,
.badge.stopped,
.badge.inactive {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger), transparent 50%);
}

.badge.planned,
.badge.member {
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning), transparent 50%);
}

.status-row {
    gap: 8px;
    flex-wrap: wrap;
}

.status-button {
    min-height: 30px;
    border: 1px solid var(--line);
    padding: 5px 8px;
    font-size: 0.78rem;
}

.status-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.danger-action {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger), transparent 55%);
}

.macro-list {
    display: grid;
    gap: 10px;
}

.macro-row {
    display: grid;
    gap: 6px;
}

.macro-copy {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.84rem;
}

.bar {
    height: 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    width: min(var(--value), 100%);
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 14px color-mix(in srgb, var(--accent), transparent 45%);
}

.forms-grid,
.library-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
    margin-top: 12px;
}

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

.form-panel {
    min-height: 100%;
}

.form-grid {
    display: grid;
    gap: 10px;
}

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

.field.wide {
    grid-column: 1 / -1;
}

.chip-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 430px;
    overflow: auto;
    padding-right: 4px;
}

.chip {
    display: inline-grid;
    gap: 2px;
    max-width: 240px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.035);
    font-size: 0.8rem;
}

.empty-state {
    min-height: 110px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    text-align: center;
    padding: 18px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    max-width: min(360px, calc(100vw - 36px));
    padding: 12px 14px;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1180px) {
    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .admin-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .workspace-grid,
    .forms-grid {
        grid-template-columns: 1fr 1fr;
    }

    .planner-panel {
        grid-row: auto;
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 20px, 720px);
        padding-top: 10px;
    }

    .topbar {
        position: static;
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-controls,
    .control-strip,
    .theme-controls {
        align-items: stretch;
        justify-content: stretch;
    }

    .topbar-controls > *,
    .compact-field,
    .date-field {
        width: 100%;
    }

    .segmented,
    .toggle-group {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .summary-grid,
    .admin-stats,
    .workspace-grid,
    .forms-grid,
    .library-grid {
        grid-template-columns: 1fr;
    }

    .form-grid.two {
        grid-template-columns: 1fr;
    }

    .workout-top,
    .routine-top,
    .supplement-top,
    .log-top,
    .admin-user-main,
    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-badges {
        justify-content: flex-start;
    }
}
