* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    --page-pattern-size: 360px;
    --page-pattern-opacity: 0.05;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f4f6fa;
    color: #1f2937;
    margin: 0;
    padding: 24px;
    line-height: 1.5;
    min-height: 100vh;
    position: relative;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url("assets/pattern_2x2.png");
    background-repeat: repeat;
    background-size: var(--page-pattern-size) auto;
    opacity: var(--page-pattern-opacity);
}
body > * {
    position: relative;
    z-index: 1;
}
.container { width: 100%; max-width: 880px; margin: 0 auto; }
.container.narrow { max-width: 460px; }
.container.wide { max-width: 1400px; }
body:has(.version-sidebar) .container.wide {
    padding-left: 62px;
    transition: padding-left .2s ease;
}
body:has(.version-sidebar:hover) .container.wide,
body:has(.version-sidebar:focus-within) .container.wide {
    padding-left: 292px;
}

h1 { margin: 0 0 4px; font-size: 26px; }
h3 { margin: 0 0 4px; font-size: 18px; }
.workbook-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.workbook-title small {
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
}

.page-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.page-head .right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.export-menu { position: relative; }
.export-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15,23,42,.12), 0 2px 6px rgba(15,23,42,.06);
    padding: 6px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.export-menu-options a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: #111827;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.export-menu-options a:hover { background: #eef2f7; }

.card {
    background: #fff; border-radius: 10px; padding: 20px;
    box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    margin-bottom: 16px;
}

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field small { font-weight: 400; color: #6b7280; }
.field input[type=text],
.field input[type=password],
.field input[type=date],
.field textarea {
    width: 100%; padding: 9px 11px; border: 1px solid #d1d5db;
    border-radius: 6px; font-size: 14px; font-family: inherit;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus {
    outline: none; border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.radio-row { display: flex; gap: 14px; flex-wrap: wrap; }
.radio { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.radio input { margin: 0; }

.range-list {
    display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px;
}
.range-row {
    display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
    padding: 10px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;
}
.range-cell {
    flex: 1 1 150px; min-width: 0; display: flex; flex-direction: column; gap: 4px;
}
.range-label {
    font-size: 12px; font-weight: 600; color: #6b7280;
    text-transform: uppercase; letter-spacing: .04em;
}
.range-row .btn-icon { align-self: flex-end; }
.range-owner {
    flex: 0 0 100%;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.range-display {
    margin: 4px 0 0; padding-left: 18px; display: flex;
    flex-direction: column; gap: 2px;
}
.range-display li { font-variant-numeric: tabular-nums; }

.btn {
    display: inline-block; padding: 9px 16px; border-radius: 6px;
    border: 1px solid transparent; font-size: 14px; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(.95); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: #2563eb; color: #fff; }
.btn-secondary { background: #fff; color: #1f2937; border-color: #d1d5db; }
.btn-success { background: #10b981; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.export-al-list-btn { background: #facc15; color: #fff; border-color: #eab308; }
.export-al-list-btn:hover { background: #eab308; color: #fff; }
.comp-map-btn { background: #facc15; color: #fff; border-color: #eab308; }
.comp-map-btn:hover { background: #eab308; color: #fff; }

.btn-icon {
    width: 32px; height: 32px; border-radius: 6px; border: 1px solid #d1d5db;
    background: #fff; cursor: pointer; font-size: 18px; line-height: 1;
    color: #6b7280;
}
.btn-icon:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }

.actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.flash {
    padding: 12px 14px; border-radius: 8px; margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.link { color: #2563eb; text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }
.muted { color: #6b7280; }
.small { font-size: 12px; }
.warn { color: #b45309; }

.tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs-row .tabs { margin-bottom: 0; }
.tabs-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}
.tab {
    padding: 8px 14px; border-radius: 8px; background: #fff;
    color: #4b5563; text-decoration: none; font-size: 14px;
    border: 1px solid #e5e7eb; display: inline-flex; gap: 8px; align-items: center;
    justify-content: center;
}
.tab:hover { background: #f9fafb; }
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.tab .badge {
    background: rgba(0,0,0,.08); color: inherit; padding: 1px 8px;
    border-radius: 999px; font-size: 12px;
}
.tab.active .badge { background: rgba(255,255,255,.25); }

.layout-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 20px 0 8px;
    flex-wrap: wrap;
}
.pagination .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.pagination-info {
    font-size: 14px;
    color: #4b5563;
    font-weight: 500;
}

.compact-table-wrap {
    width: 100%;
    overflow-x: auto;
    background: #fff;
    border: 2px solid #111827;
    border-radius: 4px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.compact-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 14px;
}
.compact-table th,
.compact-table td {
    border: 1px solid #374151;
    padding: 6px 8px;
    vertical-align: top;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.compact-table th {
    color: #dc2626;
    background: #fff;
    font-style: italic;
    text-transform: uppercase;
    text-align: left;
}
.compact-table .compact-title {
    background: #fbfba6;
    color: #0891b2;
    text-align: center;
    font-size: 20px;
    text-decoration: underline;
}
.compact-table tbody tr:nth-child(even) td {
    background: #f9fafb;
}
.compact-table tbody tr.compact-pending td {
    background: #ffff00;
}
.compact-table tbody tr.row-over-limit td,
.compact-table tbody tr.row-over-limit:nth-child(even) td {
    background: #fee2e2;
}
.table-action {
    width: 100%;
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid #b91c1c;
    border-radius: 4px;
    background: #ef4444;
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.table-action:hover { filter: brightness(.95); }

.workbook-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 6px 0;
    background: #f4f6fa;
}
.excel-toolbar {
    position: sticky;
    top: 48px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.excel-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}
.excel-toolbar input[type=color] {
    width: 38px;
    height: 34px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}
.excel-toolbar select {
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font: inherit;
}
.excel-wrap {
    width: 100%;
    overflow: auto;
    max-height: calc(100vh - 210px);
    background: #fff;
    border: 1px solid #9ca3af;
    -webkit-overflow-scrolling: touch;
}
.excel-grid {
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
    font-size: 12px;
}
.excel-grid td {
    min-width: 42px;
    height: 24px;
    padding: 2px 4px;
    border: 1px solid #d1d5db;
    vertical-align: middle;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.excel-grid td[contenteditable=true] {
    cursor: cell;
    min-height: 24px;
}
.excel-grid td[contenteditable=true]:focus,
.excel-grid .selected-cell {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}
.date-box-table td { position: relative; }
.row-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    line-height: 14px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 50%;
    background: #fff;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
.date-box-table tr:hover .row-delete { opacity: 1; }
.row-delete:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.date-box-table tr[data-extra] { cursor: grab; }
.date-box-table tr[data-extra] td { border-left: 3px solid #93c5fd; }
.date-box-table tr.dragging { opacity: 0.4; }
.add-row-btn {
    display: block;
    width: 100%;
    padding: 6px 8px;
    background: #f3f4f6;
    border: none;
    border-top: 1px solid #e5e7eb;
    color: #2563eb;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.add-row-btn:hover { background: #e5e7eb; }
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    @page {
        size: A4 landscape;
        margin: 8mm;
    }
    body { padding: 0; background: #fff; }
    .primary-nav, .month-switch, .layout-toggle, .excel-toolbar, .comp-panel,
    .add-row-btn, .row-delete, .page-head .right, .flash { display: none !important; }
    .page-head { margin-bottom: 8px !important; }
    .workbook-layout { grid-template-columns: 1fr !important; gap: 0 !important; }
    .calendar-weekdays { display: grid !important; }
    .date-box-grid { gap: 6px !important; }
    .date-box { break-inside: avoid; box-shadow: none !important; border-color: #d1d5db !important; }
    .date-box-today { outline: none !important; box-shadow: none !important; border-color: #d1d5db !important; }
    .date-box-past { opacity: 1 !important; filter: none !important; }
    .calendar-title { font-size: 22px; }
    .pdf-month-page {
        break-after: page;
        page-break-after: always;
    }
    .pdf-month-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    .pdf-comp-legend {
        break-inside: avoid;
        margin-top: 10px;
    }
    .pdf-comp-legend .comp-list {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }
    .pdf-comp-legend .comp-pair {
        padding: 5px 7px;
        font-size: 12px;
    }
    a { color: inherit !important; text-decoration: none !important; }
}
.primary-nav {
    display: inline-flex;
    gap: 4px;
    padding: 6px;
    background: #eef2f7;
    border-radius: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.primary-nav-item {
    padding: 10px 18px;
    border-radius: 10px;
    color: #6b7280;
    font-weight: 700;
    text-decoration: none;
    font-size: 15px;
    transition: background .15s, color .15s, box-shadow .15s;
}
.primary-nav-item:hover { color: #111827; }
.primary-nav-item.active {
    background: #ffffff;
    color: #111827;
    box-shadow: 0 1px 2px rgba(15,23,42,.08), 0 0 0 1px rgba(15,23,42,.04);
}
@media (max-width: 600px) {
    .primary-nav { width: 100%; justify-content: stretch; }
    .primary-nav-item { flex: 1; text-align: center; padding: 10px 8px; font-size: 14px; }
}
.fill-presets { display: inline-flex; gap: 4px; align-items: center; }
.comp-toolbar-palette {
    padding-left: 6px;
    border-left: 1px solid #d1d5db;
    flex-wrap: wrap;
    row-gap: 4px;
}
.fill-preset {
    width: 22px; height: 22px;
    min-width: 22px; min-height: 22px;
    flex: 0 0 22px;
    box-sizing: border-box;
    border: 1px solid #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.go-back-form { display: inline-block; margin: 0; }
.go-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
}
.go-back-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.go-back-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}
.go-back-count {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 999px;
    min-width: 16px;
    text-align: center;
}
.fill-preset:hover { outline: 2px solid #2563eb; outline-offset: 1px; }
.month-switch {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 4px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 14px;
    margin-bottom: 16px;
    overflow-x: auto;
}
.month-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-radius: 10px;
    text-decoration: none;
    color: #6b7280;
    transition: background .15s, color .15s, box-shadow .15s;
}
.month-pill:hover { color: #111827; }
.month-pill-name { font-size: 16px; font-weight: 700; line-height: 1.1; }
.month-pill-year { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.month-pill.active {
    background: #ffffff;
    color: #111827;
    box-shadow: 0 1px 2px rgba(15,23,42,.08), 0 0 0 1px rgba(15,23,42,.04);
}
.month-pill.active .month-pill-year { color: #6b7280; }
@media (max-width: 900px) {
    .month-switch { grid-template-columns: repeat(6, minmax(72px, 1fr)); }
}
@media (max-width: 480px) {
    .month-switch { grid-template-columns: repeat(2, minmax(72px, 1fr)); }
    .month-pill-name { font-size: 14px; }
}
.calendar-wrap { min-width: 0; }
.calendar-title {
    margin: 0 0 12px;
    font-size: 26px;
    font-weight: 700;
    color: #111827;
}
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}
.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
    padding: 6px 0;
}
.date-box-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}
.date-box-past {
    opacity: 0.65;
    filter: grayscale(0.3);
}
.date-box-today {
    border-color: #facc15 !important;
    outline: 3px solid #facc15;
    outline-offset: 0;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.35);
    position: relative;
    z-index: 1;
}
.date-box-today .date-box-head {
    background: #fef9c3 !important;
    color: #111827 !important;
}
.date-box-weekday {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-left: 4px;
}
@media (max-width: 1100px) {
    .date-box-grid:not(.pdf-date-grid) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .date-box-grid:not(.pdf-date-grid) .date-box { grid-column-start: auto !important; }
    .calendar-wrap:not(.pdf-month-page) .calendar-weekdays,
    body:not(.pdf-export) .calendar-weekdays { display: none; }
}
@media (max-width: 720px) {
    .date-box-grid:not(.pdf-date-grid) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .date-box-grid:not(.pdf-date-grid) .date-box { grid-column-start: auto !important; }
    .date-box-head { font-size: 14px; padding: 6px 8px; }
    .date-box-weekday { font-size: 11px; }
    .workbook-layout { grid-template-columns: 1fr; }
    .comp-panel { position: static; max-height: none; }
}
@media (max-width: 480px) {
    .date-box-grid:not(.pdf-date-grid) { grid-template-columns: 1fr; }
    .date-box-table { font-size: 11px; }
    .date-box-table td { padding: 3px 4px; }
}
.pdf-export .calendar-weekdays,
.pdf-month-page .calendar-weekdays {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}
.pdf-date-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}
.date-box {
    background: #fff;
    border: 1px solid #9ca3af;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.date-box-head {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid #9ca3af;
    background: #f9fafb;
}
.date-box-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid #d1d5db;
    background: #fff;
}
.comp-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid #9ca3af;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
}
.comp-chip-in { border-style: dashed; }
.comp-chip .comp-arrow { font-size: 11px; opacity: .8; }

.workbook-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: center;
}
.workbook-admin-shell {
    display: block;
}
.workbook-admin-main {
    min-width: 0;
}
.comp-panel {
    align-self: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 18px 20px;
    max-height: calc(100vh - 24px);
    overflow: auto;
}
.comp-panel h3 { margin: 0 0 14px; font-size: 17px; }
.version-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 62px;
    z-index: 80;
    display: grid;
    grid-template-columns: 62px 230px;
    background: #232b32;
    border: 1px solid #111820;
    border-left: 0;
    border-radius: 0;
    box-shadow: 0 10px 28px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.18);
    overflow: hidden;
    transition: width .2s ease;
}
.version-sidebar:hover,
.version-sidebar:focus-within {
    width: 292px;
}
.version-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 8px;
    background: #1b2228;
    border-right: 1px solid #34404a;
}
.version-rail-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #20a7db;
    box-shadow: inset 0 0 0 4px rgba(255,255,255,.28);
    color: #fff;
    font-weight: 800;
}
.version-rail-count {
    min-width: 28px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #111820;
    color: #d7e2ea;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.version-sidebar-panel {
    min-width: 0;
    padding: 0;
    overflow: auto;
    background: #232b32;
    color: #c9d3dc;
}
.version-sidebar h3 {
    margin: 0;
    padding: 14px 16px;
    background: #1b2228;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}
.version-current {
    position: relative;
    border: 0;
    background: #0f91c7;
    border-radius: 0;
    padding: 12px 16px;
    margin: 0;
}
.version-current::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 18px;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid #f4f6fa;
}
.version-kicker {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,.84);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.version-number {
    margin-top: 2px;
    font-size: 22px;
    font-weight: 800;
    color: #fff;
}
.version-current dl {
    display: grid;
    gap: 6px;
    margin: 8px 0 0;
}
.version-current dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.version-current dt {
    color: rgba(255,255,255,.72);
    font-size: 12px;
}
.version-current dd {
    margin: 0;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: right;
}
.version-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 0 12px;
}
.version-clear-form {
    margin: 0;
    padding: 12px 0 4px;
    display: flex;
    justify-content: center;
    border-top: 1px solid #e5e7eb;
}
.version-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px 0 8px;
    border-radius: 6px;
    border: 1px solid #fecaca;
    background: #fff;
    color: #b91c1c;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, transform .05s;
}
.version-clear-btn .version-clear-x {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}
.version-clear-btn .version-clear-label {
    white-space: nowrap;
}
.version-clear-btn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}
.version-clear-btn:active { transform: translateY(1px); }
.workbook-reset-form {
    padding-top: 8px;
    border-top: 0;
}
.workbook-reset-btn {
    border-color: #991b1b;
    background: #991b1b;
    color: #fff;
}
.workbook-reset-btn:hover {
    background: #7f1d1d;
    border-color: #7f1d1d;
}
.version-item {
    position: relative;
    border: 0;
    border-radius: 0;
    padding: 10px 34px 10px 18px;
    background: transparent;
    border-left: 3px solid transparent;
    color: #c9d3dc;
}
.version-item-current {
    border-left-color: #20a7db;
    background: #2f3942;
}
.version-item-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
}
.version-item-head strong {
    color: #fff;
}
.version-item-head span,
.version-meta,
.version-distance {
    color: #a9b6c0;
    font-size: 12px;
}
.version-meta {
    margin-top: 4px;
    text-transform: capitalize;
}
.version-distance {
    margin-top: 6px;
    font-weight: 700;
    color: #d7e2ea;
}
.version-restore-form {
    margin-top: 8px;
}
.version-restore-btn {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    background: #1b2228;
    color: #d7e2ea;
    border-color: #44515d;
}
.version-restore-btn:hover {
    background: #111820;
    color: #fff;
}
.version-delete-form {
    position: absolute;
    top: 7px;
    right: 8px;
    margin: 0;
}
.version-delete-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #44515d;
    border-radius: 4px;
    background: #1b2228;
    color: #a9b6c0;
    line-height: 18px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
}
.version-delete-btn:hover {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fff;
}
.comp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comp-pair {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 15px; padding: 8px 10px;
    border: 1px solid #e5e7eb; border-radius: 8px; background: #f9fafb;
}
.comp-pair-in { border-style: dashed; }
.comp-end { font-weight: 700; color: #111827; text-decoration: none; }
.comp-end:hover { text-decoration: underline; }
.comp-range {
    display: block;
    margin-top: 2px;
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
}
.comp-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 20px; padding: 0 6px;
    border: 1px solid #9ca3af; border-radius: 4px; font-weight: 700;
}
.comp-swatch {
    display: inline-block; width: 38px; height: 24px;
    border: 1px solid #9ca3af; border-radius: 5px;
}
.comp-eq { color: #6b7280; font-weight: 700; }
.comp-kind { margin-left: auto; font-size: 11px; color: #6b7280; }
.comp-form {
    display: grid;
    gap: 8px;
    padding: 10px;
    margin-bottom: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}
.comp-form label {
    display: grid;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #4b5563;
}
.comp-form input[type=text],
.comp-form input[type=date] {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font: inherit;
}
.comp-form input[type=color] {
    width: 100%;
    height: 34px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}
.al-comp-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 999px;
    background: #1f2937;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    max-width: calc(100vw - 32px);
    text-align: center;
    pointer-events: none;
}
.al-comp-selected {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}
.comp-template-toggle { width: 100%; margin-top: 10px; margin-bottom: 16px; }
.comp-template-panel {
    margin-top: 10px;
    padding: 12px;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    background: #f9fafb;
}
.comp-template-panel .comp-form { gap: 8px; }
.comp-template-panel select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
}
.comp-color-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.comp-color-form input[type=color] {
    width: 34px;
    height: 30px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}
.comp-color-form .btn {
    padding: 5px 8px;
    font-size: 12px;
}
.comp-fill-preset {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.55);
}
.comp-map-modal[hidden] { display: none; }
.comp-map-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15,23,42,.45);
}
.comp-map-dialog {
    width: min(860px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 48px rgba(15,23,42,.24), 0 8px 18px rgba(15,23,42,.12);
}
.comp-map-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
}
.comp-map-head h3 {
    margin: 0;
    font-size: 18px;
}
.comp-map-close {
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 22px;
    line-height: 26px;
    cursor: pointer;
}
.comp-map-body {
    overflow: auto;
    padding: 16px 18px 18px;
}
.comp-map-add-form {
    grid-template-columns: minmax(180px, 1.3fr) repeat(2, minmax(130px, .8fr)) 96px auto;
    align-items: end;
}
.comp-map-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.comp-map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.comp-map-table th,
.comp-map-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}
.comp-map-table th {
    background: #f9fafb;
    color: #4b5563;
    font-size: 12px;
    text-transform: uppercase;
}
.comp-slot-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center !important;
}
.comp-map-table tr:last-child td { border-bottom: 0; }
.comp-delete-form { margin: 0; }
.comp-delete-form .btn {
    min-height: 30px;
    padding: 5px 10px;
    font-size: 12px;
}
.pdf-export-sheets {
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.pdf-month-page {
    background: #fff;
}
.pdf-comp-legend {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}
.pdf-comp-legend h3 {
    margin: 0 0 10px;
    font-size: 16px;
}
@media (max-width: 900px) {
    .workbook-layout { grid-template-columns: 1fr; }
    .workbook-admin-shell { grid-template-columns: 1fr; }
    body:has(.version-sidebar) .container.wide,
    body:has(.version-sidebar:hover) .container.wide,
    body:has(.version-sidebar:focus-within) .container.wide {
        padding-left: 62px;
    }
    .comp-panel { position: static; max-height: none; }
    .version-sidebar {
        top: 0;
        bottom: 0;
        width: 62px;
        max-width: calc(100vw - 24px);
    }
    .version-sidebar:hover,
    .version-sidebar:focus-within {
        width: min(292px, calc(100vw - 24px));
    }
}
.date-box-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}
.date-box-table td {
    height: 28px;
    min-height: 28px;
    padding: 5px 7px;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.date-box-table td:empty::before {
    content: '\00a0';
    display: inline-block;
    pointer-events: none;
}
.date-box [contenteditable=true] {
    cursor: cell;
    min-height: 28px;
}
.al-suggest-popup {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(15,23,42,.15), 0 2px 6px rgba(15,23,42,.08);
    min-width: 140px;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    display: none;
    font-size: 13px;
}
.al-suggest-item {
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    color: #111827;
}
.al-suggest-item:hover,
.al-suggest-item.active {
    background: #dbeafe;
    color: #1e3a8a;
}
.date-box [contenteditable=true]:focus,
.date-box .selected-cell {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

.request-card .request-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.request-card-approved { background: #d1fae5; }
.request-card-pending { background: #fef3c7; }
.request-card-rejected { background: #fee2e2; }
.request-card .request-head > div:first-child { min-width: 0; }
.request-card h3 { overflow-wrap: anywhere; }
.request-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
    padding: 3px 9px; border-radius: 999px; font-size: 13px;
    font-weight: 700; letter-spacing: .04em;
}
.tag-add { background: #dbeafe; color: #1e40af; }
.tag-cancel { background: #fee2e2; color: #991b1b; }
.tag-swap { background: #ede9fe; color: #5b21b6; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.tag-period { background: #e0f2fe; color: #075985; }

.request-body { font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.request-body, .admin-remark, .range-display { overflow-wrap: anywhere; }
.admin-remark {
    background: #f9fafb; padding: 8px 10px; border-radius: 6px;
    border-left: 3px solid #2563eb;
}

.request-actions {
    margin-top: 14px; padding-top: 14px; border-top: 1px solid #e5e7eb;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.request-actions input[type=text] {
    flex: 1 1 220px; min-width: 0; padding: 8px 10px;
    border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}

.empty { text-align: center; color: #6b7280; padding: 40px 20px; }
code {
    background: #f3f4f6; padding: 2px 6px; border-radius: 4px;
    font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 640px) {
    body { padding: 12px; }
    h1 { font-size: 22px; }
    h3 { font-size: 16px; }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .page-head .right {
        width: 100%;
        justify-content: flex-start;
        gap: 8px 12px;
    }

    .card {
        border-radius: 8px;
        padding: 14px;
        margin-bottom: 12px;
    }

    .field { margin-bottom: 14px; }
    .field input[type=text],
    .field input[type=password],
    .field input[type=date],
    .field textarea {
        font-size: 16px;
        min-height: 44px;
    }

    .radio-row {
        flex-direction: column;
        gap: 10px;
    }
    .radio {
        min-height: 32px;
    }

    .range-row {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: end;
        gap: 10px;
        padding: 10px;
    }
    .range-cell {
        grid-column: 1 / -1;
        width: 100%;
    }
    .range-row .btn-icon {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }
    .range-owner {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
    }

    .actions,
    .request-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .btn,
    .request-actions input[type=text] {
        width: 100%;
        min-height: 44px;
        text-align: center;
    }

    .tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .tabs-row {
        align-items: stretch;
    }
    .tabs-row .tabs,
    .tabs-actions {
        width: 100%;
    }
    .tabs-actions {
        display: grid;
        grid-template-columns: 1fr;
        margin-left: 0;
    }
    .tab {
        min-width: 0;
        padding: 9px 10px;
    }

    .request-head {
        flex-direction: column;
        align-items: stretch;
    }
    .request-tags {
        width: 100%;
    }
    .tag {
        font-size: 12px;
    }

    .layout-toggle {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .excel-toolbar {
        position: static;
        align-items: stretch;
        gap: 6px;
        padding: 8px;
    }
    .excel-toolbar .btn,
    .excel-toolbar select,
    .excel-toolbar label {
        width: 100%;
        justify-content: center;
    }
    .fill-presets {
        width: 100%;
        justify-content: center;
    }
    .comp-map-modal {
        align-items: stretch;
        padding: 10px;
    }
    .comp-map-dialog {
        max-height: calc(100vh - 20px);
    }
    .comp-map-add-form {
        grid-template-columns: 1fr;
    }
    .workbook-tabs {
        position: static;
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
    }
    .workbook-tabs .tab {
        flex: 0 0 auto;
        min-width: 72px;
    }
    .excel-wrap {
        max-height: 70vh;
    }
    .excel-grid {
        font-size: 11px;
    }
    .excel-grid td {
        min-width: 54px;
        height: 30px;
    }
    .date-box-head {
        font-size: 16px;
    }
    .compact-table-wrap {
        margin-left: -2px;
        margin-right: -2px;
    }
    .compact-table {
        min-width: 720px;
        font-size: 13px;
    }
    .compact-table th,
    .compact-table td {
        padding: 5px 6px;
    }
    .compact-table .compact-title {
        font-size: 18px;
    }
}

@media (max-width: 380px) {
    body { padding: 8px; }
    body:has(.version-sidebar) .container.wide,
    body:has(.version-sidebar:hover) .container.wide,
    body:has(.version-sidebar:focus-within) .container.wide {
        padding-left: 56px;
    }
    .version-sidebar {
        width: 56px;
        max-width: calc(100vw - 8px);
        grid-template-columns: 56px 224px;
    }
    .version-sidebar:hover,
    .version-sidebar:focus-within {
        width: min(280px, calc(100vw - 8px));
    }
    .version-rail-icon {
        width: 32px;
        height: 32px;
    }
    .tabs { grid-template-columns: 1fr; }
    .layout-toggle { grid-template-columns: 1fr; }
    .card { padding: 12px; }
}
