:root {
    --bg: #f4f7f8;
    --panel: #ffffff;
    --panel-muted: #f8fafb;
    --text: #1f2d36;
    --subtle-text: #5e6f79;
    --line: #d6e0e5;
    --accent: #35556b;
    --accent-soft: #e9f0f4;
    --shadow: 0 10px 24px rgba(25, 46, 58, 0.08);
    --dialysis: #edf5fb;
    --icu: #eaf3f1;
    --surgery: #f5efe8;
    --ward: #f7f3e8;
    --outpatient: #eef0f7;
    --unassigned: #f3f4f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
    background: linear-gradient(180deg, #f7fafb 0%, #f1f5f7 100%);
    color: var(--text);
}

button,
input {
    font: inherit;
}

.page-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

.lead {
    margin: 10px 0 0;
    color: var(--subtle-text);
}

.content {
    display: grid;
    gap: 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.upload-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 14px;
}

.file-input-label {
    font-weight: 700;
}

input[type="file"] {
    flex: 1 1 280px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-muted);
}

button {
    border: 0;
    border-radius: 10px;
    padding: 11px 18px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

button:hover {
    background: #2d495c;
}

.hint,
.meta-text,
.table-panel-header p {
    color: var(--subtle-text);
}

.sample-block,
.error-panel pre {
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 12px;
    background: var(--panel-muted);
    border: 1px solid var(--line);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

.error-panel {
    border-color: #e0c7c7;
    background: #fffafb;
}

.table-wrapper {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    max-height: 72vh;
    background: #fff;
}

.assignment-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: max-content;
    width: 100%;
}

.assignment-table th,
.assignment-table td {
    min-width: 140px;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.assignment-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f7fbfd;
    font-weight: 700;
}

.assignment-table .date-header {
    cursor: pointer;
}

.assignment-table .date-header:hover,
.assignment-table .date-header:focus {
    background: var(--accent-soft);
    outline: none;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fbfdfe;
}

.assignment-table thead .sticky-col {
    z-index: 4;
}

.row-name {
    font-weight: 700;
}

.dept-dialysis {
    background: var(--dialysis);
}

.dept-icu {
    background: var(--icu);
}

.dept-surgery {
    background: var(--surgery);
}

.dept-ward {
    background: var(--ward);
}

.dept-outpatient {
    background: var(--outpatient);
}

.dept-unassigned {
    background: var(--unassigned);
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 45, 54, 0.12);
    z-index: 20;
}

.summary-popup {
    position: fixed;
    z-index: 21;
    width: min(420px, calc(100vw - 24px));
    max-height: min(70vh, 560px);
    overflow: auto;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(32, 49, 60, 0.14);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.popup-close {
    min-width: 40px;
    padding: 8px 12px;
    background: #eef3f6;
    color: var(--text);
}

.popup-content {
    display: grid;
    gap: 10px;
}

.summary-row {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fbfcfd;
}

.summary-row strong {
    display: block;
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .page-shell {
        padding: 16px;
    }

    .panel {
        padding: 16px;
        border-radius: 14px;
    }

    .assignment-table th,
    .assignment-table td {
        min-width: 122px;
        padding: 10px 12px;
    }
}
