:root {
    --bg: #f7f3ef;
    --surface: #ffffff;
    --ink: #241b18;
    --muted: #766b66;
    --line: #e9dfd8;
    --accent: #ff385c;
    --accent-dark: #d91e48;
    --ok: #0f8a5f;
    --soft: #fff0f3;
    --shadow: 0 18px 55px rgba(36, 27, 24, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    position: sticky;
    top: 0;
    width: 270px;
    height: 100vh;
    padding: 24px;
    background: rgba(255, 255, 255, .78);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.brand small {
    display: block;
    color: var(--muted);
}

nav {
    display: grid;
    gap: 8px;
}

nav a,
.button,
button {
    border: 0;
    border-radius: 10px;
    padding: 11px 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    border: 1px solid var(--line);
}

nav a:hover,
.button:hover,
button:hover {
    border-color: #f5b4c0;
}

.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 750;
}

.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.danger {
    color: #fff;
    background: #b42318;
    border-color: #b42318;
}

.danger-text {
    color: #b42318;
}

.ghost {
    border: 0;
    background: transparent;
    padding: 6px 0;
}

.logout {
    margin-top: auto;
}

.logout button {
    width: 100%;
}

.content {
    width: 100%;
    padding: 34px;
}

.login-content {
    width: 100%;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel,
.course-row,
.module,
.lesson-card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 430px);
    padding: 28px;
}

.login-hero {
    margin-bottom: 22px;
}

.login-hero h1,
.page-head h1 {
    margin: 14px 0 8px;
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1;
    letter-spacing: 0;
}

.login-hero p,
.page-head p,
.course-summary {
    color: var(--muted);
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.page-actions,
.report-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 12px;
}

.stack,
.form-grid,
.compact-form,
.lesson-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    color: #3b302d;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(255, 56, 92, .12);
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff3cd;
    border: 1px solid #ffe69c;
    margin-bottom: 16px;
}

.course-list {
    display: grid;
    gap: 12px;
    max-width: 1180px;
}

.course-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 22px;
    padding: 18px 20px;
    box-shadow: 0 10px 30px rgba(36, 27, 24, .055);
}

.module-head,
.lesson-card summary,
.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.status {
    background: var(--soft);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.course-title-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 7px;
}

.course-title-line h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: 0;
}

.course-title-line a:hover {
    color: var(--accent-dark);
}

.course-summary {
    max-width: 760px;
    margin: 0;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.course-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(86px, 1fr));
    gap: 8px;
}

.stat-chip {
    min-width: 86px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    background: #fffaf7;
    font-size: 13px;
}

.stat-chip strong {
    display: block;
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
    margin-bottom: 3px;
}

.course-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.course-actions .button {
    white-space: nowrap;
}

.ghost-link {
    background: transparent;
}

.panel {
    padding: 20px;
    margin-bottom: 18px;
}

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

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

.lesson-basics {
    grid-template-columns: 1fr;
}

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

.compact-form {
    grid-template-columns: 90px 1fr auto;
}

.module-list {
    display: grid;
    gap: 18px;
}

.module-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 10px 30px rgba(36, 27, 24, .045);
}

.module-row .module-head {
    align-items: flex-start;
}

.module-link {
    min-width: 0;
}

.module-link h2 {
    margin: 4px 0 0;
    font-size: 21px;
}

.module-link:hover h2,
.module-open:hover,
.back-link:hover {
    color: var(--accent-dark);
}

.module-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.module-open {
    margin-left: auto;
    color: var(--accent-dark);
    font-weight: 750;
}

.module {
    padding: 22px;
}

.module h2 {
    margin: 4px 0 0;
}

.module-order {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

details {
    margin-top: 14px;
}

summary {
    cursor: pointer;
    font-weight: 750;
}

.lessons {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.lesson-card {
    padding: 14px 16px;
    box-shadow: none;
}

.platforms {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.platforms b,
.pill {
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
}

.platforms b {
    background: #f3eee9;
}

.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.pill.done {
    color: var(--ok);
    background: #eaf8f0;
}

.pill.muted {
    color: var(--muted);
    background: #f6f1ec;
}

.pill.status-recorded.done,
.status-card.status-recorded .status-toggle strong {
    color: #1769aa;
}

.pill.status-recorded.done { background: #e6f3ff; }
.pill.status-edited.done,
.status-card.status-edited .status-toggle strong { color: #9a6700; }
.pill.status-edited.done { background: #fff4d6; }
.pill.status-published.done,
.status-card.status-published .status-toggle strong { color: #0f8a5f; }
.pill.status-published.done { background: #eaf8f0; }
.pill.status-removed.done,
.status-card.status-removed .status-toggle strong { color: #b42318; }
.pill.status-removed.done { background: #fff0ee; }
.pill.status-refreshed.done,
.status-card.status-refreshed .status-toggle strong { color: #7057b8; }
.pill.status-refreshed.done { background: #f0ecff; }
.pill.status-pending.done,
.status-card.status-pending .status-toggle strong { color: #667085; }
.pill.status-pending.done { background: #eef1f5; }

.lesson-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.check {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 43px;
}

.check input {
    width: auto;
}

.form-section {
    min-width: 0;
    margin: 0;
    padding: 16px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.form-section legend {
    padding: 0;
    font-weight: 800;
    font-size: 17px;
}

.form-hint {
    margin: 4px 0 14px;
    color: var(--muted);
    font-size: 13px;
}

.status-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.status-card,
.platform-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fffaf7;
}

.status-card {
    display: grid;
    gap: 12px;
    padding: 12px;
    border-top: 3px solid currentColor;
}

.status-card.status-recorded { color: #1769aa; }
.status-card.status-edited { color: #9a6700; }
.status-card.status-published { color: #0f8a5f; }
.status-card.status-removed { color: #b42318; }
.status-card.status-refreshed { color: #7057b8; }
.status-card.status-pending { color: #667085; }

.status-toggle,
.platform-card {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: var(--ink);
    cursor: pointer;
}

.status-toggle input,
.platform-card input {
    width: auto;
    margin-top: 3px;
    accent-color: currentColor;
}

.status-toggle span,
.platform-card span {
    display: grid;
    gap: 3px;
}

.status-toggle strong,
.platform-card strong {
    font-size: 14px;
}

.status-toggle small,
.platform-card small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.status-date {
    color: var(--muted);
    font-size: 11px;
}

.status-date input {
    margin-top: 4px;
    padding: 8px;
    font-size: 12px;
}

.platform-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.platform-card {
    min-height: 72px;
    padding: 14px;
    border-left: 3px solid var(--line);
}

.platform-course { border-left-color: #1769aa; }
.platform-youtube { border-left-color: #ff385c; }
.platform-other { border-left-color: #7057b8; }

.other-platform-field {
    max-width: 520px;
    margin-top: 13px;
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 15px;
}

.section-head h2 {
    margin: 3px 0 0;
}

.lesson-editor .lesson-form {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.lesson-table-panel {
    padding: 0;
    overflow: hidden;
}

.lesson-table-panel > .section-head,
.lesson-table-panel > .empty-state {
    margin: 20px;
}

.table-scroll {
    overflow-x: auto;
}

.lesson-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    text-align: left;
}

.lesson-table th,
.lesson-table td {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    vertical-align: top;
}

.lesson-table tbody tr[draggable="true"] {
    cursor: grab;
}

.lesson-table tbody tr[draggable="true"]:active {
    cursor: grabbing;
}

.lesson-table tbody tr.is-dragging {
    opacity: .45;
    background: #fff5f7;
}

.drag-handle {
    display: inline-block;
    margin-right: 8px;
    color: var(--muted);
    font-size: 21px;
    line-height: .7;
    vertical-align: -2px;
    cursor: grab;
}

.sort-feedback {
    min-height: 20px;
    margin: 0 20px 4px;
    color: var(--ok);
    font-size: 13px;
    font-weight: 700;
}

.sort-feedback.error {
    color: #b42318;
}

.lesson-table th {
    background: #fffaf7;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.lesson-table td strong {
    display: block;
    min-width: 180px;
}

.lesson-table td small {
    display: block;
    max-width: 240px;
    margin-top: 5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-order {
    width: 58px;
    color: var(--accent-dark);
    font-weight: 800;
}

.table-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 170px;
}

.table-pills .pill {
    white-space: nowrap;
}

.table-platforms {
    min-width: 110px;
}

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

.table-dates {
    display: grid;
    gap: 4px;
    min-width: 150px;
    font-size: 12px;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.small-button {
    padding: 7px 10px;
    font-size: 13px;
}

.report-page {
    max-width: 1180px;
    margin: 0 auto;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 28px;
    padding: 14px 0 26px;
    border-bottom: 2px solid var(--ink);
}

.report-header h1 {
    max-width: 850px;
    margin: 8px 0 10px;
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.08;
}

.report-description {
    max-width: 900px;
    margin: 0;
    color: var(--muted);
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--line);
    margin-bottom: 26px;
}

.report-summary div {
    display: grid;
    gap: 3px;
    padding: 18px 20px;
    border-right: 1px solid var(--line);
}

.report-summary div:first-child {
    padding-left: 0;
}

.report-summary div:last-child {
    border-right: 0;
}

.report-summary strong {
    font-size: 26px;
    line-height: 1;
}

.report-summary span,
.report-module-count,
.report-footer {
    color: var(--muted);
    font-size: 13px;
}

.report-module {
    margin-bottom: 30px;
    break-inside: avoid;
}

.report-module-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}

.report-module-head h2 {
    margin: 4px 0 0;
    font-size: 22px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.report-table th,
.report-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.report-table th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.report-table td strong {
    display: block;
    min-width: 190px;
}

.report-table td small {
    display: block;
    max-width: 280px;
    margin-top: 4px;
    color: var(--muted);
}

.report-dates {
    display: grid;
    gap: 3px;
    min-width: 150px;
    color: var(--muted);
    font-size: 12px;
}

.report-empty {
    padding: 15px 0;
    color: var(--muted);
}

.report-footer {
    padding: 18px 0 4px;
    border-top: 1px solid var(--line);
}

@media print {
    @page {
        margin: 16mm;
    }

    body {
        background: #fff;
    }

    .sidebar,
    .no-print {
        display: none !important;
    }

    .content {
        padding: 0;
    }

    .report-page {
        max-width: none;
    }

    .report-header {
        padding-top: 0;
    }

    .report-module {
        break-inside: avoid;
    }

    .report-table {
        font-size: 10px;
    }

    .report-table th,
    .report-table td {
        padding: 7px 6px;
    }
}

@media (max-width: 850px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: auto;
        height: auto;
    }

    .content {
        padding: 22px;
    }

    .page-head,
    .course-row,
    .module-head,
    .lesson-card summary,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions,
    .report-actions {
        width: 100%;
    }

    .report-header {
        flex-direction: column;
    }

    .report-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .report-summary div:nth-child(2) {
        border-right: 0;
    }

    .report-summary div:nth-child(3),
    .report-summary div:nth-child(4) {
        border-top: 1px solid var(--line);
    }

    .course-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .course-title-line,
    .course-actions {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .module-summary {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .module-open {
        width: 100%;
        margin-left: 0;
    }

    .form-grid,
    .form-grid.small,
    .compact-form {
        grid-template-columns: 1fr;
    }

    .status-card-grid,
    .platform-card-grid {
        grid-template-columns: 1fr;
    }
}
