:root {
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e2e5ea;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logout-link {
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: none;
}
.logout-link:hover { text-decoration: underline; }

.login-wrap {
    display: flex;
    justify-content: center;
    padding-top: 3rem;
}
.login-card {
    width: 100%;
    max-width: 340px;
}
.login-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.login-card label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.login-error {
    color: var(--danger);
    font-size: 0.9rem;
    margin: -0.5rem 0 0.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}
.brand-logo {
    height: 28px;
    width: auto;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

h1 { font-size: 1.6rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.1rem; margin-top: 0; }
h3 { font-size: 1rem; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1rem;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--muted);
    gap: 0.3rem;
}

.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 0.6rem; margin-top: 0.85rem; }
.form-grid .actions { grid-column: 1 / -1; margin-top: 0; }

input, textarea, select {
    font: inherit;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}

button {
    font: inherit;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    align-self: start;
    grid-column: 1 / -1;
    justify-self: start;
}
button:hover { background: var(--accent-dark); }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-dark); }

.button {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: 0.55rem 1rem;
    border-radius: 6px;
}
.button:hover { background: var(--accent-dark); }

.list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.list li {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}
.list a { color: var(--accent); text-decoration: none; font-weight: 600; }
.list a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 0.9rem; }

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.search-form input[type="search"] {
    min-width: 240px;
}
.search-form button { padding: 0.5rem 0.9rem; }
.button-link {
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: underline;
}

.exercise-table {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}
.exercise-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 0.8fr auto;
    gap: 0.5rem;
    align-items: center;
}
.superset-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
}
.exercise-head {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.row-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.row-actions button { grid-column: auto; padding: 0.4rem 0.55rem; font-size: 0.8rem; white-space: nowrap; }

/* Print view */
:root {
    --print-red: #ad3c2e;
    --print-red-tint: #f8ece9;
    --print-red-line: #e6cfc9;
}
.print-toolbar {
    padding: 1rem;
    display: flex;
    gap: 0.6rem;
    background: var(--bg);
}
.print-sheet {
    max-width: 720px;
    margin: 0 auto;
    padding: 2.5rem 2.75rem 3rem;
    background: #fff;
    border: 1px solid #eee;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.print-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--print-red);
}
.print-logo {
    height: 64px;
    width: auto;
    flex-shrink: 0;
}
.print-header h1 {
    margin: 0 0 0.4rem;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
    color: #1a1a1a;
}
.print-meta {
    margin: 0;
    line-height: 1.7;
    font-size: 0.92rem;
    color: #333;
}
.print-meta strong { color: var(--print-red); }
.print-section-title {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    background: var(--print-red);
    padding: 0.3rem 0.95rem;
    border-radius: 999px;
    margin: 1.6rem 0 0.65rem;
}
.print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}
.print-table th {
    background: var(--print-red-tint);
    color: var(--print-red);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    font-weight: 700;
    text-align: left;
    padding: 0.6rem 0.7rem;
    border-bottom: 2px solid var(--print-red);
}
.print-table td {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--print-red-line);
}
.print-table tbody tr:nth-child(even) { background: #fdf8f7; }
.print-target {
    display: block;
    font-size: 0.8rem;
    color: #777;
}
.print-superset-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.55rem;
    background: var(--print-red);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
.print-superset-hint {
    font-size: 0.8rem;
    color: #777;
    margin: 0.2rem 0 0.75rem;
    font-style: italic;
}
.print-log-table { table-layout: fixed; }
.print-log-table th {
    background: var(--print-red-tint);
    color: var(--print-red);
    border-bottom: 2px solid var(--print-red);
}
.print-log-table th, .print-log-table td { padding: 0.35rem 0.15rem; font-size: 0.7rem; text-align: center; overflow: hidden; border: 1px solid var(--print-red-line); }
.print-log-table td:first-child, .print-log-table th:first-child { text-align: left; font-size: 0.85rem; }
.print-log-date { text-align: center; }
.print-log-col { height: 1.7rem; }
.print-footer {
    margin-top: 2rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--print-red-line);
    font-size: 0.72rem;
    color: #999;
    text-align: center;
    letter-spacing: 0.02em;
}

@media print {
    .print-sheet { box-shadow: none; border: none; }
}
.print-sheet-blank { page-break-before: always; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .print-sheet { padding: 0; }
    .print-sheet-blank { page-break-before: always; }
}

.field { display: contents; }
.field-label { display: none; }

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .exercise-row {
        grid-template-columns: 1fr;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 0.85rem;
        margin-bottom: 0.6rem;
    }
    .exercise-head { display: none; }
    .field { display: block; margin-bottom: 0.6rem; }
    .field-label {
        display: block;
        font-size: 0.75rem;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-bottom: 0.2rem;
    }
    .row-actions { justify-content: flex-start; }
}
