:root {
    --bg: #eef3fb;
    --surface: #ffffff;
    --surface-muted: #f7f9fd;
    --border: #d7e0ee;
    --text: #1f2937;
    --text-muted: #5c6b82;
    --primary: #1f4acc;
    --primary-soft: #eaf0ff;
    --primary-dark: #183b9e;
    --success: #15803d;
    --success-soft: #e7f8ee;
    --warning: #a16207;
    --warning-soft: #fff6db;
    --error: #b91c1c;
    --error-soft: #fff0f0;
    --shadow: 0 18px 50px rgba(36, 57, 99, 0.12);
    --radius-lg: 18px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at top left, rgba(31, 74, 204, 0.08), transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    font-family: "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

a {
    color: inherit;
}

.app-page {
    min-height: 100vh;
}

.app-shell {
    width: min(1280px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 16px 0 32px;
}

.app-header {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(215, 224, 238, 0.85);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.app-brand__title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.app-brand__subtitle {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.app-header__user {
    flex: 1;
    min-width: 0;
}

.app-header__user-name {
    font-size: 18px;
    font-weight: 800;
}

.app-header__user-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.app-header__label {
    font-weight: 700;
}

.app-role-list {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.app-role-chip,
.app-pill,
.status-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-weight: 700;
    line-height: 1;
}

.app-pill {
    padding: 6px 10px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.app-role-chip {
    padding: 5px 10px;
    background: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
}

.app-header__actions {
    flex: 0 0 auto;
}

.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    margin-top: 20px;
    align-items: start;
}

.app-menu {
    position: sticky;
    top: 20px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(215, 224, 238, 0.85);
    box-shadow: var(--shadow);
}

.app-menu__title {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-menu__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.app-menu__link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    color: var(--text);
    background: var(--surface-muted);
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-menu__link:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: rgba(31, 74, 204, 0.16);
}

.app-menu__link--active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: rgba(31, 74, 204, 0.16);
}

.app-menu__link--disabled {
    color: #8b96a8;
    background: #f4f6fa;
    border-color: #e5ebf3;
    cursor: not-allowed;
    opacity: 0.8;
}

.app-menu__link--disabled:hover {
    color: #8b96a8;
    background: #f4f6fa;
    border-color: #e5ebf3;
}

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

.card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(215, 224, 238, 0.85);
    box-shadow: var(--shadow);
}

.card h1,
.card h2,
.card h3 {
    margin: 0;
}

.card h1 {
    font-size: 26px;
}

.card h2 {
    font-size: 20px;
}

.card p {
    margin: 0;
}

.section-note {
    color: var(--text-muted);
    line-height: 1.8;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head__meta {
    color: var(--text-muted);
    line-height: 1.7;
}

.detail-list {
    margin: 0;
    display: grid;
    gap: 8px;
}

.detail-list__row {
    display: grid;
    grid-template-columns: 7em minmax(0, 1fr);
    gap: 12px;
}

.detail-list__row dt {
    color: var(--text-muted);
}

.detail-list__row dd {
    margin: 0;
}

/* 案件詳細専用。表の横スクロールを画面全体へ伝播させない。 */
.project-detail-page :is(.page-content, .project-detail__section, .table-wrap) {
    min-width: 0;
}

.project-detail-page .app-layout {
    grid-template-columns: 260px minmax(0, 1fr);
}

.project-detail-page .card.project-detail {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: none;
}

.project-detail__topbar,
.project-detail__title-row,
.project-detail__section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.project-detail__breadcrumb {
    display: flex;
    gap: 10px;
    color: var(--text-muted);
    font-size: 12px;
}

.project-detail__breadcrumb a {
    text-decoration: none;
}

.project-detail__breadcrumb a:hover {
    text-decoration: underline;
}

.project-detail :is(.button) {
    box-shadow: none;
}

.project-detail__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.project-detail__title h1 {
    font-size: 28px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.project-detail__id {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
}

.project-detail__badge {
    padding: 3px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 800;
}

.project-detail__badge.is-normal {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(21, 128, 61, 0.25);
}

.project-detail__badge.is-cancelled {
    background: var(--error-soft);
    color: var(--error);
    border-color: rgba(185, 28, 28, 0.25);
}

.project-detail__period {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid #d7e4ff;
    background: #f3f7ff;
    color: var(--primary-dark);
}

.project-detail__label {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.project-detail .project-detail__period-value {
    margin: 4px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 18px;
    font-weight: 800;
}

.project-detail__info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}

.project-detail__item {
    padding: 12px 0;
    border-bottom: 1px solid #edf1f7;
    min-width: 0;
}

.project-detail__item:nth-child(even) {
    padding-left: 24px;
    border-left: 1px solid #edf1f7;
}

.project-detail__item dt {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.project-detail__item dd {
    margin: 6px 0 0;
    line-height: 1.7;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.project-detail__value--strong {
    font-weight: 800;
}

.project-detail__notes {
    white-space: pre-wrap;
}

.project-detail__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 0;
    padding: 12px 20px;
    margin: 0 -20px -20px;
    border-radius: 0 0 12px 12px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 11px;
}

.project-detail-page .project-detail__meta {
    margin: 0 -20px -20px;
}

.project-detail__section {
    display: grid;
    gap: 4px;
}

.project-detail__section-head h2 {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0;
    flex-wrap: wrap;
    font-size: 16px;
}

.project-detail__count {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
}

.button.project-detail__add {
    min-height: 40px;
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #c5d5fb;
    box-shadow: none;
}

.button.project-detail__add:hover {
    background: #dbe6ff;
}

.project-detail__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 960px) {
    .project-detail-page .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .project-detail__info {
        grid-template-columns: minmax(0, 1fr);
    }

    .project-detail__item:nth-child(even) {
        padding-left: 0;
        border-left: 0;
    }

    .project-detail__title h1 {
        font-size: 24px;
    }

    .project-detail .project-detail__period-value {
        font-size: 16px;
        gap: 6px;
    }

    .project-detail__period {
        padding: 12px;
    }

    .project-detail__topbar {
        gap: 8px;
    }

    .project-detail__topbar .button {
        padding: 8px 10px;
        font-size: 12px;
    }
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 案件新規登録の任意の担当割当。既存の編集・追加画面へ適用しない。 */
.project-create-page .app-layout {
    grid-template-columns: 260px minmax(0, 1fr);
}
.project-create-page :is(.page-content, .field) { min-width: 0; }
.project-create__assignments {
    min-width: 0;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.project-create__assignments legend { font-weight: 700; }
.project-create__assignments legend small { color: var(--text-muted); font-weight: 400; }
.project-create__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.project-create__row > .field:first-child { grid-column: 1 / -1; }
.project-create__row > .button { grid-column: 1 / -1; justify-self: end; }
.project-create-page [hidden] { display: none !important; }
@media (max-width: 960px) {
    .project-create-page .app-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .project-create__row { grid-template-columns: minmax(0, 1fr); }
    .project-create__assignments { padding: 12px; }
}

.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.attendance-table-wrap {
    margin-top: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}

.attendance-table {
    min-width: 1280px;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.admin-table td {
    background: #fff;
}

.attendance-table td:nth-child(10) {
    max-width: 280px;
    word-break: break-word;
}

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

.schedule-calendar-page .page-head__meta {
    margin-top: 10px;
}

.schedule-calendar-page__actions {
    align-self: flex-start;
}

.schedule-calendar-page__notice {
    margin-top: 16px;
}

.schedule-calendar-filter {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.schedule-calendar-filter__summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}

.schedule-calendar-filter__summary::-webkit-details-marker {
    display: none;
}

.schedule-calendar-filter__summary::before {
    content: "▸";
    color: var(--primary-dark);
}

.schedule-calendar-filter[open] .schedule-calendar-filter__summary::before {
    content: "▾";
}

.schedule-calendar-filter__active {
    padding: 3px 8px;
    border-radius: 999px;
    background: #e5edff;
    color: var(--primary-dark);
    font-size: 12px;
}

.schedule-calendar-filter__body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
}

.schedule-calendar-filter__head {
    display: flex;
    align-items: flex-start;
}

.schedule-calendar-filter__head p {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.schedule-calendar-filter__pickers {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.schedule-calendar-filter__picker-field,
.schedule-calendar-filter__secondary-fields > .field {
    min-width: 0;
}

.schedule-calendar-filter__secondary-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.schedule-filter-picker {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.schedule-filter-picker__search {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.schedule-filter-picker__search:focus {
    outline: 2px solid rgba(31, 74, 204, 0.18);
    border-color: rgba(31, 74, 204, 0.45);
}

.schedule-filter-picker__chips {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
    gap: 7px;
}

.schedule-filter-chip {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 4px 6px 4px 10px;
    border: 1px solid rgba(31, 74, 204, 0.2);
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
}

.schedule-filter-chip__kind {
    flex: 0 0 auto;
    margin-right: 4px;
}

.schedule-filter-chip__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-filter-chip__remove {
    display: inline-grid;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin-left: 5px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(31, 74, 204, 0.14);
    color: var(--primary-dark);
    cursor: pointer;
    font: inherit;
    font-size: 16px;
    line-height: 1;
}

.schedule-filter-chip__remove:hover {
    background: rgba(31, 74, 204, 0.24);
}

.schedule-filter-picker__options {
    display: none;
    max-height: 148px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.schedule-filter-picker.is-open .schedule-filter-picker__options {
    display: grid;
}

.schedule-filter-picker__option {
    display: flex;
    gap: 7px;
    align-items: center;
    min-width: 0;
    padding: 9px 10px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    text-align: left;
}

.schedule-filter-picker__option[hidden] {
    display: none;
}

.schedule-filter-picker__option:last-child {
    border-bottom: 0;
}

.schedule-filter-picker__option:hover {
    background: var(--primary-soft);
}

.schedule-filter-picker__option > span:not(.schedule-filter-picker__kind):not(.schedule-filter-picker__status) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-filter-picker__kind,
.schedule-filter-picker__status {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eaf0ff;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 800;
}

.schedule-filter-picker__kind--external {
    background: #eef5ed;
    color: #346b3a;
}

.schedule-filter-picker__status {
    margin-left: auto;
    background: #fbeaea;
    color: #984747;
}

.schedule-calendar-filter__actions {
    margin-top: 14px;
}

.schedule-calendar-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 13px;
}

.schedule-calendar-legend > span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.schedule-calendar-legend__sample {
    width: 28px;
    height: 12px;
    border-radius: 4px;
    background: var(--primary);
}

.schedule-calendar-legend__sample--cancelled {
    background: repeating-linear-gradient(
        135deg,
        #9b6262,
        #9b6262 6px,
        #b97979 6px,
        #b97979 12px
    );
}

.schedule-calendar-wrap {
    overflow-x: auto;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.schedule-calendar {
    min-width: 840px;
}

.schedule-calendar__weekday-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    min-height: 42px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.schedule-calendar__weekday-row > div {
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 800;
}

.schedule-calendar__weekday-row > div:last-child {
    border-right: none;
}

.schedule-calendar__weekday-row .is-saturday {
    color: #315ea8;
}

.schedule-calendar__weekday-row .is-sunday {
    color: #ad3d3d;
}

.schedule-calendar__week {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    min-height: var(--schedule-calendar-week-height);
    border-bottom: 1px solid var(--border);
}

.schedule-calendar__week:last-child {
    border-bottom: none;
}

.schedule-calendar__day-cell {
    min-width: 0;
    padding: 8px;
    border-right: 1px solid #e7edf6;
    background: #fff;
}

.schedule-calendar__day-cell:last-of-type {
    border-right: none;
}

.schedule-calendar__day-cell.is-saturday {
    background: #f8faff;
}

.schedule-calendar__day-cell.is-sunday {
    background: #fffafa;
}

.schedule-calendar__day-cell.is-outside-month {
    background: #f7f8fb;
    color: #a1a9b6;
}

.schedule-calendar__date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
}

.schedule-calendar__day-cell.is-today .schedule-calendar__date {
    background: var(--primary);
    color: #fff;
}

.schedule-calendar__project-bars {
    position: absolute;
    z-index: 1;
    inset: 42px 0 6px;
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    grid-template-rows: repeat(var(--schedule-calendar-lanes), 28px);
    gap: 4px 0;
    pointer-events: none;
}

.schedule-calendar__project-bar {
    display: flex;
    gap: 5px;
    align-items: center;
    min-width: 0;
    margin: 0 3px;
    padding: 4px 8px;
    border: 1px solid rgba(24, 59, 158, 0.25);
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary) 0%, #426bde 100%);
    color: #fff;
    box-shadow: 0 2px 5px rgba(31, 74, 204, 0.18);
    font-size: 12px;
    text-decoration: none;
    pointer-events: auto;
}

.schedule-calendar__project-bar:hover {
    filter: brightness(1.08);
}

.schedule-calendar__project-bar.continues-before {
    margin-left: 0;
    border-left: none;
    border-radius: 0 6px 6px 0;
}

.schedule-calendar__project-bar.continues-after {
    margin-right: 0;
    border-right: none;
    border-radius: 6px 0 0 6px;
}

.schedule-calendar__project-bar.continues-before.continues-after {
    border-radius: 0;
}

.schedule-calendar__project-bar.is-cancelled {
    border-color: rgba(110, 45, 45, 0.35);
    background: repeating-linear-gradient(
        135deg,
        #8f5555,
        #8f5555 10px,
        #a96868 10px,
        #a96868 20px
    );
    box-shadow: 0 2px 5px rgba(110, 45, 45, 0.18);
}

.schedule-calendar__project-name {
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-calendar__project-status {
    flex: 0 0 auto;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 9px;
    font-weight: 800;
}

.schedule-calendar__continuation {
    flex: 0 0 auto;
    font-size: 11px;
}

.schedule-calendar-page__empty {
    margin-top: 14px;
}

.attendance-monthly__hero .page-head__meta {
    margin-top: 14px;
}

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

/* Keep the monthly layout independent of day-edit and approval screens. */
.attendance-monthly-page .app-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    width: 100%;
    min-width: 0;
}

.attendance-monthly-page .page-content {
    width: 100%;
    max-width: 100%;
}

.attendance-monthly-page .page-content,
.attendance-monthly-page .card,
.attendance-monthly-page .page-head > div {
    min-width: 0;
}

.attendance-monthly-page .page-head__meta,
.attendance-monthly-page .empty-state,
.attendance-monthly-page .alert {
    overflow-wrap: anywhere;
}

.attendance-monthly__controls {
    display: grid;
    gap: 12px;
    width: min(100%, 360px);
}

.attendance-monthly__actions {
    justify-content: flex-end;
    align-items: center;
}

.attendance-monthly__section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.attendance-monthly__table-hint {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
}

.attendance-monthly-page .attendance-table-wrap {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.attendance-monthly-page .attendance-table {
    min-width: 720px;
    table-layout: fixed;
    font-size: 13px;
}

.attendance-monthly-page .attendance-table th,
.attendance-monthly-page .attendance-table td {
    padding: 12px 8px;
    vertical-align: middle;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.attendance-monthly-page .attendance-table th:nth-child(1) {
    width: 64px;
}

.attendance-monthly-page .attendance-table th:nth-child(2) {
    width: 48px;
}

.attendance-monthly-page .attendance-table th:nth-child(3) {
    width: 140px;
}

.attendance-monthly-page .attendance-table th:nth-child(4),
.attendance-monthly-page .attendance-table th:nth-child(5),
.attendance-monthly-page .attendance-table th:nth-child(7),
.attendance-monthly-page .attendance-table th:nth-child(8) {
    width: 80px;
}

.attendance-monthly-page .attendance-table th:nth-child(6) {
    width: 72px;
}

.attendance-monthly-page .attendance-table th:nth-child(9) {
    width: 76px;
}

.attendance-monthly-page .attendance-row__edit-link {
    min-height: 44px;
}

.attendance-monthly-page .monthly-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.attendance-monthly-page :is(.button, .attendance-table-wrap):focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

.monthly-summary {
    width: min(100%, 760px);
    justify-self: start;
}

.monthly-summary__section + .monthly-summary__section {
    margin-top: 20px;
}

.monthly-summary__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.monthly-summary__section-head h3 {
    font-size: 16px;
}

.monthly-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr));
    gap: 12px;
    max-width: 640px;
}

.monthly-summary-card {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
    box-shadow: 0 8px 20px rgba(36, 57, 99, 0.06);
}

.monthly-summary-card-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.monthly-summary-card-value {
    margin-top: 8px;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
}

.monthly-summary-table-wrap {
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.monthly-summary-time-table {
    width: auto;
    max-width: 520px;
    border-collapse: collapse;
}

.monthly-summary-time-table th,
.monthly-summary-time-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.monthly-summary-time-table th {
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}

.monthly-summary-time-table td {
    background: #fff;
    text-align: right;
}

.monthly-summary-time-table tr:last-child th,
.monthly-summary-time-table tr:last-child td {
    border-bottom: none;
}

.monthly-summary-table__time {
    min-width: 110px;
}

.monthly-summary-table__decimal {
    min-width: 84px;
}

.monthly-summary-balance {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 8px 20px rgba(36, 57, 99, 0.06);
}

.monthly-summary-balance__label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.monthly-summary-balance__value {
    font-size: 22px;
    font-weight: 800;
}

@media (max-width: 640px) {
    .monthly-summary-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

@media (max-width: 420px) {
    .monthly-summary-grid {
        grid-template-columns: 1fr;
    }
}

.attendance-status {
    display: inline-flex;
    margin-left: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 800;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.detail-item {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.detail-item__label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.detail-item__value {
    margin-top: 8px;
    font-weight: 700;
    line-height: 1.7;
    word-break: break-word;
}

.inline-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
}

.text-link {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

.empty-state {
    margin-top: 16px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface-muted);
    color: var(--text-muted);
    border: 1px dashed var(--border);
    line-height: 1.7;
}

.summary-grid,
.feature-grid {
    display: grid;
    gap: 16px;
}

.summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

.summary-item {
    padding: 16px;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.summary-item__label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.summary-item__value {
    margin-top: 8px;
    font-size: 18px;
    font-weight: 800;
}

.tag-list,
.bullet-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.tag-list {
    margin-top: 12px;
}

.tag-list__item {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.tag-list__label {
    font-weight: 700;
}

.status-chip {
    padding: 6px 10px;
    font-size: 12px;
}

.status-chip--active {
    background: var(--success-soft);
    color: var(--success);
}

.status-chip--pending {
    background: var(--warning-soft);
    color: var(--warning);
}

.bullet-list {
    margin-top: 12px;
    padding-left: 18px;
    list-style: disc;
    gap: 8px;
    color: var(--text);
}

.bullet-list li {
    line-height: 1.7;
}

.message-stack {
    display: grid;
    gap: 12px;
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    line-height: 1.7;
}

.alert--error {
    color: var(--error);
    background: var(--error-soft);
    border-color: #f7c9c9;
}

.alert--success {
    color: var(--success);
    background: var(--success-soft);
    border-color: #cdeed8;
}

.alert--warning {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: #f6e0a7;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.auth-card {
    width: min(520px, 100%);
    padding: 32px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(215, 224, 238, 0.9);
    box-shadow: var(--shadow);
}

.auth-card__title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 800;
}

.auth-card__text {
    margin-bottom: 24px;
    color: var(--text-muted);
    line-height: 1.8;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.field input:focus {
    outline: 2px solid rgba(31, 74, 204, 0.18);
    border-color: rgba(31, 74, 204, 0.45);
}

.field input[readonly] {
    background: #f5f8fd;
    color: var(--text-muted);
}

.field select {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.field select:focus {
    outline: 2px solid rgba(31, 74, 204, 0.18);
    border-color: rgba(31, 74, 204, 0.45);
}

.field textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.field textarea:focus {
    outline: 2px solid rgba(31, 74, 204, 0.18);
    border-color: rgba(31, 74, 204, 0.45);
}

.field-note {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.field-error {
    margin-top: 6px;
    color: var(--error);
    font-size: 14px;
    line-height: 1.6;
}

.form-shell {
    margin-top: 20px;
}

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

.field--full {
    grid-column: 1 / -1;
}

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

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-muted);
    font-weight: 700;
}

.checkbox-item input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.checkbox-item--inline {
    display: inline-flex;
    width: auto;
    padding-inline: 14px;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.row-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.unlock-panel {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
    padding: 16px;
    border-radius: 16px;
    background: var(--warning-soft);
    border: 1px solid #f6e0a7;
}

.unlock-panel__title {
    font-weight: 800;
    color: var(--warning);
}

.unlock-panel__text {
    margin-top: 4px;
    color: var(--text);
    line-height: 1.7;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.planned-time-preset {
    display: inline-flex;
    align-items: stretch;
    max-width: 100%;
    border: 1px solid rgba(31, 74, 204, 0.12);
    border-radius: 999px;
    background: var(--primary-soft);
}

.planned-time-preset .planned-time-preset__apply,
.planned-time-preset .planned-time-preset__delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--primary-dark);
    cursor: pointer;
    font: inherit;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.planned-time-preset .planned-time-preset__apply {
    min-width: 0;
    padding: 8px 16px;
    border-radius: 999px 0 0 999px;
    overflow-wrap: anywhere;
    text-align: left;
    font-weight: 800;
}

.planned-time-preset .planned-time-preset__apply:hover {
    background: #dfe8ff;
}

.planned-time-preset .planned-time-preset__delete {
    flex: 0 0 44px;
    padding: 0;
    border-left: 1px solid rgba(31, 74, 204, 0.12);
    border-radius: 0 999px 999px 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.planned-time-preset .planned-time-preset__delete:hover {
    background: #fee4e2;
    color: #b42318;
}

.planned-time-preset .planned-time-preset__apply:focus-visible,
.planned-time-preset .planned-time-preset__delete:focus-visible {
    outline: 3px solid rgba(31, 74, 204, 0.35);
    outline-offset: 2px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 8px 20px rgba(31, 74, 204, 0.18);
}

.button:hover {
    background: #1840bf;
    transform: translateY(-1px);
}

.button--secondary {
    background: var(--primary-soft);
    color: var(--primary-dark);
    box-shadow: none;
    border-color: rgba(31, 74, 204, 0.12);
}

.button--secondary:hover {
    background: #dfe8ff;
    color: var(--primary-dark);
}

.button--ghost {
    background: #f3f6fb;
    color: var(--text);
    box-shadow: none;
    border-color: var(--border);
}

.button--ghost:hover {
    background: #e9eef7;
    color: var(--text);
}

.attendance-row__edit-link {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.attendance-row__edit-disabled {
    color: var(--text-muted);
    font-weight: 700;
}

.attendance-day__hero .page-head__meta {
    margin-top: 14px;
}

.attendance-day__hero .page-actions {
    align-self: flex-start;
}

.footer-note {
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.7;
}

/* CR-013: opt in only on general-user templates; CR-012 stays independent. */
.general-user-page .app-layout {
    grid-template-columns: 260px minmax(0, 1fr);
}

.general-user-page :is(.app-shell, .page-content, .card, .auth-card, .field,
    .page-head > div, .detail-item, .summary-item, .planned-time-preset) {
    min-width: 0;
}

.general-user-page :is(.app-brand, .app-header__user, .page-content, .auth-card) {
    overflow-wrap: anywhere;
}

.general-user-page :is(.field input, .field select, .field textarea) {
    min-width: 0;
    max-width: 100%;
}

.general-user-page :is(.table-wrap, .schedule-calendar-wrap) {
    min-width: 0;
    max-width: 100%;
}

.general-user-page .admin-table td {
    overflow-wrap: anywhere;
}

.general-user-page .schedule-assignment-table-wrap .admin-table {
    min-width: 640px;
    table-layout: fixed;
}

.general-user-page .schedule-assignment-table-wrap th:nth-child(2),
.general-user-page .schedule-assignment-table-wrap th:nth-child(3) {
    width: 180px;
}

.general-user-page .schedule-assignment-table-wrap th:nth-child(4) {
    width: 100px;
}

.general-user-page .schedule-date-time {
    white-space: nowrap;
}

.general-user-page :is(.button, .text-link) {
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
    padding-block: 8px;
    text-align: center;
}

.general-user-page .text-link {
    display: inline-flex;
    align-items: center;
}

.general-user-page .tag-list__item {
    flex-wrap: wrap;
}

.general-user-page :is(.button, .text-link, .table-wrap, .schedule-calendar-wrap,
    .app-menu__link):focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

@media (max-width: 960px) {
    .general-user-page .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .general-user-page .app-header {
        flex-wrap: wrap;
    }

    .general-user-page .app-brand {
        min-width: 0;
        flex: 1 1 280px;
    }

    .general-user-page .app-header__user {
        flex: 1 1 240px;
    }

    .general-user-page .app-menu {
        min-width: 0;
        padding: 14px;
    }

    .general-user-page .app-menu__list {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
    }

    .general-user-page .app-menu__item {
        flex: 0 0 auto;
    }

    .general-user-page .app-menu__link {
        white-space: nowrap;
    }

    .general-user-page .schedule-calendar {
        --schedule-calendar-lane-step: 48px;
    }

    .general-user-page .schedule-calendar__project-bars {
        grid-template-rows: repeat(var(--schedule-calendar-lanes), 44px);
    }

    .general-user-page :is(.schedule-filter-picker__search,
        .schedule-filter-picker__option, .schedule-filter-chip__remove) {
        min-height: 44px;
    }

    .general-user-page .schedule-filter-chip__remove {
        flex-basis: 44px;
        width: 44px;
    }
}

@media (max-width: 720px) {
    .general-user-page .app-shell {
        width: calc(100% - 24px);
        padding-top: 12px;
    }

    .general-user-page .app-header {
        padding: 16px;
        gap: 12px;
    }

    .general-user-page .app-brand__title {
        font-size: 18px;
    }

    .general-user-page :is(.app-brand, .app-header__user) {
        flex-basis: auto;
    }

    .general-user-page .app-header__actions {
        align-self: stretch;
    }

    .general-user-page .app-header__actions .button {
        width: 100%;
    }

    .general-user-page :is(.app-layout, .page-content) {
        gap: 12px;
    }

    .general-user-page :is(.card, .auth-card) {
        padding: 16px;
    }

    .general-user-page .page-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .general-user-page :is(.form-actions, .button-row) > .button {
        flex: 1 1 140px;
    }

    .general-user-page .form-grid > .button-row {
        grid-column: 1 / -1;
    }

    .general-user-page .detail-list__row {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }
}

@media (max-width: 960px) {
    .attendance-monthly-page .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .attendance-monthly-page .app-header {
        flex-wrap: wrap;
    }

    .attendance-monthly-page .app-brand,
    .attendance-monthly-page .app-header__user {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .attendance-monthly-page .app-menu {
        min-width: 0;
        padding: 14px;
    }

    .attendance-monthly-page .app-menu__list {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 6px;
    }

    .attendance-monthly-page .app-menu__item {
        flex: 0 0 auto;
    }

    .attendance-monthly-page .app-menu__link {
        white-space: nowrap;
    }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .app-menu {
        position: static;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .checkbox-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .attendance-monthly-page .app-shell {
        width: calc(100% - 24px);
        padding-top: 12px;
    }

    .attendance-monthly-page .app-header {
        padding: 16px;
        gap: 12px;
    }

    .attendance-monthly-page .app-brand__title {
        font-size: 18px;
    }

    .attendance-monthly-page .app-header__actions {
        align-self: stretch;
    }

    .attendance-monthly-page .app-header__actions .button {
        width: 100%;
    }

    .attendance-monthly-page .app-layout,
    .attendance-monthly-page .page-content {
        gap: 12px;
    }

    .attendance-monthly-page .card {
        padding: 16px;
    }

    .attendance-monthly__hero .page-head,
    .attendance-monthly__controls {
        width: 100%;
    }

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

    .attendance-monthly__actions .button {
        width: 100%;
        padding: 8px;
    }

    .attendance-monthly-page .monthly-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .attendance-monthly-page .monthly-summary-card {
        padding: 12px;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .app-header__actions {
        align-self: flex-start;
    }

    .auth-card,
    .card,
    .app-menu {
        padding: 20px;
    }

    .schedule-calendar-filter__head {
        flex-direction: column;
    }

    .schedule-calendar-filter__secondary-fields {
        grid-template-columns: 1fr;
    }
}
