/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e4eb;
    --brand-color: #e63946;
    --accent: #e63946;
    --accent-hover: #c1121f;
    --accent-light: rgba(230, 57, 70, 0.08);
    --bg-main: #f5f6fa;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f1f5;
    --border: #e2e4eb;
    --text-primary: #14161c;
    --text-secondary: #4b4f58;
    --text-muted: #8a8f99;
    --success: #2e7d32;
    --success-bg: rgba(46, 125, 50, 0.08);
    --warning: #ef6c00;
    --warning-bg: rgba(239, 108, 0, 0.08);
    --info: #1565c0;
    --info-bg: rgba(21, 101, 192, 0.08);
    --danger: #c62828;
    --danger-bg: rgba(198, 40, 40, 0.08);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(20, 22, 28, 0.08);
    --transition: 0.2s ease;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--bg-main);
    color: var(--text-primary);
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition);
    overflow: hidden;
    z-index: 100;
}

.layout.sidebar-collapsed .sidebar {
    width: 64px;
}
.layout.sidebar-collapsed .sidebar span,
.layout.sidebar-collapsed .sidebar-footer span {
    display: none;
}
.layout.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0 0 0 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand span {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.brand-icon {
    color: var(--brand-color);
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 2px 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav a i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav a.active i {
    color: var(--accent);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--sidebar-border);
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.status-dot {
    color: var(--success);
    font-size: 8px;
}

/* ===== Main ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ===== Topbar ===== */
.topbar {
    height: 60px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.badge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Content ===== */
.content {
    flex: 1;
    padding: 28px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--accent);
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.upload-zone:hover .upload-icon {
    color: var(--accent);
}

.upload-zone p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 6px;
}

.upload-zone small {
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger {
    background: rgba(198, 40, 40, 0.08);
    color: var(--danger);
    border: 1px solid rgba(198, 40, 40, 0.3);
}
.btn-danger:hover {
    background: rgba(198, 40, 40, 0.16);
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(67, 160, 71, 0.3);
}
.btn-success:hover {
    background: rgba(67, 160, 71, 0.25);
}

.btn-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(30, 136, 229, 0.3);
}
.btn-info:hover {
    background: rgba(30, 136, 229, 0.25);
}

/* ===== File List / Table ===== */
.file-table {
    width: 100%;
    border-collapse: collapse;
}

.file-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.file-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    vertical-align: middle;
}

.file-table tr:last-child td {
    border-bottom: none;
}

.file-table tr:hover td {
    background: var(--bg-card-hover);
    cursor: pointer;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 500;
}

.file-name i {
    color: var(--accent);
    font-size: 16px;
}

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

.rename-form {
    align-items: center;
    gap: 8px;
}

.rename-form input {
    min-width: 180px;
    max-width: 260px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    padding: 7px 10px;
    outline: none;
}

.rename-form input:focus {
    border-color: var(--accent);
}

/* ===== Image Grid ===== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.image-item {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    group: true;
    transition: border-color var(--transition);
}

.image-item:hover {
    border-color: var(--accent);
}

.image-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.image-item-info {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}

.image-item-name {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-item-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: #ef5350;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity var(--transition);
}

.image-item:hover .image-item-delete {
    opacity: 1;
}

/* ===== Alert messages ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(67, 160, 71, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(198, 40, 40, 0.08);
    border: 1px solid rgba(198, 40, 40, 0.3);
    color: var(--danger);
}

.alert-info {
    background: var(--info-bg);
    border: 1px solid rgba(30, 136, 229, 0.3);
    color: var(--info);
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== Dashboard stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.red { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Preview modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
}

/* A4 preview frame */
.a4-frame-wrapper {
    width: 100%;
    overflow: auto;
    display: flex;
    justify-content: center;
}

.a4-frame {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    box-shadow: 0 4px 32px rgba(20,22,28,0.15);
    border-radius: 2px;
    overflow: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Tooltip ===== */
[data-tip] {
    position: relative;
}
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
[data-tip]:hover::after { opacity: 1; }

/* ===== Loader ===== */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PDF Builder Wizard ===== */
.pdf-builder-wizard {
    display: grid;
    gap: 20px;
}

.wizard-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.wizard-step {
    min-height: 64px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.wizard-step span {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 700;
    flex-shrink: 0;
}

.wizard-step strong {
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wizard-step.active {
    border-color: rgba(230, 57, 70, 0.45);
    background: var(--accent-light);
    color: var(--text-primary);
}

.wizard-step.active span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.wizard-card {
    margin-bottom: 0;
}

.wizard-card-meta {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

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

.wizard-single {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.wizard-panel {
    min-height: 430px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wizard-panel-wide {
    min-height: 0;
}

.wizard-panel.is-disabled {
    opacity: 0.62;
}

.wizard-panel-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.wizard-panel-index {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.wizard-panel h2 {
    font-size: 14px;
    font-weight: 650;
    color: var(--text-primary);
    line-height: 1.25;
}

.wizard-panel p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.wizard-field {
    display: grid;
    gap: 8px;
}

.wizard-field span {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 650;
}

.wizard-field select,
.wizard-field input {
    min-height: 44px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0 12px;
    font: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.wizard-field select:focus,
.wizard-field input:focus {
    border-color: rgba(230, 57, 70, 0.6);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.12);
}

.progression-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.progression-filter-keyword {
    grid-column: 1 / -1;
}

.progression-filter-toggle {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.progression-filter-toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.progression-filter-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.autosave-status {
    min-height: 18px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.autosave-status.is-error {
    color: var(--danger);
}

.check-list {
    display: grid;
    gap: 10px;
    align-content: start;
}

.check-tile {
    min-height: 48px;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.check-tile:hover {
    border-color: rgba(230, 57, 70, 0.5);
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.check-tile input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.check-mark {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    background: var(--sidebar-bg);
    transition: all var(--transition);
    flex-shrink: 0;
}

.check-mark i {
    font-size: 11px;
}

.check-tile input:checked + .check-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.check-tile:has(input:checked) {
    border-color: rgba(230, 57, 70, 0.65);
    background: var(--accent-light);
    color: var(--text-primary);
}

.check-tile strong {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.35;
}

.check-tile small,
.check-tile em {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: normal;
    line-height: 1.4;
}

.progression-tile {
    min-height: 86px;
}

.progression-tile em {
    color: var(--text-secondary);
}

.progression-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.progression-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
}

.progression-table th,
.progression-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 11px;
    line-height: 1.35;
}

.progression-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    font-weight: 700;
}

.progression-table td {
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.progression-table tr:last-child td {
    border-bottom: 0;
}

.progression-table tr:hover td {
    background: var(--bg-card-hover);
}

.progression-table th:nth-child(2),
.progression-table td:nth-child(2) {
    width: 70px;
}

.progression-table th:nth-child(3),
.progression-table td:nth-child(3) {
    width: 24%;
}

.progression-table th:nth-child(4),
.progression-table td:nth-child(4) {
    width: 20%;
}

.progression-table th:nth-child(5),
.progression-table td:nth-child(5) {
    width: auto;
}

.select-column {
    width: 54px;
    text-align: center;
}

.table-check {
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.table-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.table-check input:checked + .check-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.selected-progression-list {
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #e6ebf0;
}

.selected-progression-card {
    display: block;
    gap: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.pdf-page-card {
    position: relative;
}

.step-two-toolbar {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.selected-progression-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(230, 57, 70, 0.2);
    border-radius: var(--radius-sm);
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(27, 38, 44, 0.08);
    cursor: pointer;
    list-style: none;
    appearance: none;
    -webkit-appearance: none;
}

.selected-progression-head::-webkit-details-marker {
    display: none;
}

.selected-progression-head::marker {
    content: '';
}

.selected-progression-card[open] > .selected-progression-head {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: none;
}

.page-order-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.selected-progression-head span,
.template-assignment-status span {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
}

.selected-progression-head [data-page-title] {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
}

.selected-progression-head strong,
.template-assignment-status strong {
    display: block;
    margin-top: 3px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

.selected-progression-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.selected-progression-body {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid rgba(230, 57, 70, 0.2);
    border-top: 0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--bg-card);
    box-shadow: 0 10px 24px rgba(27, 38, 44, 0.08);
}

.opgave-grid-panel {
    display: grid;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    padding: 12px;
}

.opgave-grid-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.opgave-grid-panel-head span {
    display: block;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.opgave-grid-panel-head p {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

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

.opgave-grid-field {
    display: grid;
    gap: 6px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 10px;
}

.opgave-grid-field span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.35;
    word-break: break-word;
}

.opgave-grid-field textarea {
    width: 100%;
    min-height: 72px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-sm) - 2px);
    background: #fff;
    color: var(--text-secondary);
    padding: 9px 10px;
    resize: vertical;
    font: inherit;
    font-size: 12px;
    line-height: 1.45;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.opgave-grid-field textarea:focus {
    border-color: rgba(230, 57, 70, 0.6);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.12);
}

.opgave-grid-empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-muted);
    padding: 12px;
    font-size: 12px;
    line-height: 1.4;
}

.selected-progression-field {
    min-height: 96px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    padding: 12px;
    display: grid;
    gap: 8px;
}

.selected-progression-field span {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.selected-progression-field textarea {
    min-height: 88px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 10px;
    resize: vertical;
    font: inherit;
    font-size: 12px;
    line-height: 1.5;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.selected-progression-field textarea:focus {
    border-color: rgba(230, 57, 70, 0.6);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.12);
}

.selected-progression-prompt {
    grid-column: 1 / -1;
}

.selected-progression-prompt textarea {
    min-height: 120px;
}

.template-assignment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    padding: 12px;
}

.template-assignment-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.ai-fill-status {
    min-height: 18px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.ai-queue-summary,
.ai-queue-status {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    color: var(--text-secondary);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.4;
}

.ai-queue-status.is-error {
    color: var(--danger);
    border-color: rgba(220, 53, 69, 0.35);
    background: var(--danger-bg);
}

.ai-revision-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.ai-revision-panel[hidden] {
    display: none;
}

.ai-revision-panel .selected-progression-field {
    min-height: 0;
}

.ai-revision-panel textarea {
    min-height: 72px;
}

.template-picker-dialog {
    max-width: min(1320px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
}

.template-picker-body {
    display: block;
    padding: 16px;
}

.template-picker-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.template-picker-toolbar .wizard-field {
    max-width: 340px;
}

.template-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.template-preview-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    overflow: hidden;
}

.template-preview-head {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.template-preview-head strong {
    display: block;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.template-preview-head span {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.template-preview-frame {
    height: 420px;
    overflow: hidden;
    background: #e8eceb;
}

.template-preview-frame iframe {
    width: 210mm;
    height: 297mm;
    border: 0;
    background: #fff;
    transform: scale(0.47);
    transform-origin: top left;
    pointer-events: none;
}

.wizard-empty,
.wizard-loading {
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.wizard-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wizard-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.wizard-actions .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pdf-combined-preview-panel {
    gap: 16px;
}

.combined-preview-toolbar {
    display: flex;
    justify-content: flex-end;
}

.combined-preview-frame {
    width: 100%;
    height: min(82vh, 980px);
    min-height: 620px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #dfe5e9;
}

.pdf-generate-panel {
    gap: 16px;
}

.pdf-mode-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.pdf-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.pdf-mode-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

.pdf-mode-option input {
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.pdf-mode-option strong {
    display: block;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.2;
}

.pdf-mode-option em {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
    font-style: normal;
    line-height: 1.25;
}

.wizard-status-success {
    border-color: rgba(67, 160, 71, 0.35) !important;
    background: var(--success-bg) !important;
    color: var(--success) !important;
}

.wizard-status-success a {
    color: var(--success);
    font-weight: 600;
}

.wizard-status-error {
    border-color: rgba(198, 40, 40, 0.35) !important;
    background: rgba(198, 40, 40, 0.08) !important;
    color: var(--danger) !important;
}

@media (max-width: 760px) {
    .pdf-mode-choice {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1180px) {
    .wizard-grid {
        grid-template-columns: 1fr;
    }

    .wizard-single {
        grid-template-columns: 1fr;
    }

    .progression-filters {
        grid-template-columns: 1fr;
    }

    .wizard-panel {
        min-height: 0;
    }
}

@media (max-width: 760px) {
    .wizard-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .selected-progression-grid,
    .opgave-grid,
    .template-assignment {
        grid-template-columns: 1fr;
    }

    .template-assignment {
        display: grid;
    }

    .ai-revision-panel {
        grid-template-columns: 1fr;
    }

    .template-assignment-actions {
        justify-content: stretch;
    }

.template-assignment-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .wizard-actions {
        flex-direction: column-reverse;
    }

    .wizard-actions .btn {
        justify-content: center;
        width: 100%;
    }
}
