:root {
    color-scheme: light;
    --bg: #f3efe8;
    --panel: #fffdfa;
    --line: #d9cfbf;
    --text: #2e251b;
    --muted: #6a5b4c;
    --accent: #1d6b52;
    --accent-soft: #e3f1eb;
    --secondary: #8c6433;
    --danger: #a63f33;
    --danger-soft: #fff0ec;
    --danger-line: #e3bbb3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Yu Gothic UI", "Meiryo", sans-serif;
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(29, 107, 82, 0.12), transparent 30%),
        linear-gradient(180deg, #faf6ef 0%, var(--bg) 100%);
}

.container {
    width: min(1380px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.app-shell {
    width: min(1480px, calc(100% - 32px));
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(720px, 100%);
}

.page-header,
.panel-head,
.filter-form,
.grid,
.section-head {
    display: flex;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

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

.eyebrow {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

h1, h2, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(28px, 4vw, 42px);
}

.subtitle {
    margin-bottom: 0;
    color: var(--muted);
}

.date-card,
.panel,
.flash-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(44, 36, 27, 0.05);
}

.date-card {
    min-width: 190px;
    padding: 16px 18px;
}

.date-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.date-card strong {
    font-size: 22px;
}

.role-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.admin-badge {
    background: #ffe7c2;
    color: #8c6433;
}

.user-badge {
    background: #e3f1eb;
    color: var(--accent);
}

.flash-list {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.flash-item {
    padding: 14px 16px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}

.admin-mode-banner {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid #f0c98b;
    border-radius: 16px;
    background: #fff4df;
    color: #8c6433;
    box-shadow: 0 10px 30px rgba(44, 36, 27, 0.04);
}

.admin-mode-banner strong {
    padding: 5px 10px;
    border-radius: 999px;
    background: #ffe7c2;
}

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

.panel-head {
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head p {
    color: var(--muted);
}

.filter-panel .filter-form {
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-form > * {
    flex: 1 1 180px;
}

.filter-form label,
.edit-form label {
    display: grid;
    gap: 6px;
}

.filter-form span,
.edit-form span {
    font-size: 13px;
    color: var(--muted);
}

.employee-form,
.actions-column,
.summary-list,
.edit-form {
    display: grid;
}

.employee-form {
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="month"],
select {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 16px;
}

button,
.button-link {
    border: 0;
    border-radius: 12px;
    min-height: 48px;
    padding: 12px 16px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

button.secondary {
    background: var(--secondary);
}

button.break-button {
    background: #2f6f8f;
}

button.action-primary {
    background: var(--accent);
}

button.danger {
    background: var(--danger);
}

button.danger-outline {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger-line);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.grid {
    gap: 20px;
    align-items: start;
}

.dashboard-grid {
    align-items: start;
}

.main-column,
.side-column {
    display: grid;
    gap: 20px;
}

.main-panel {
    flex: 1 1 auto;
}

.side-panel {
    width: min(320px, 100%);
    flex: 0 0 320px;
}

.main-column {
    flex: 1 1 auto;
}

.side-column {
    width: min(520px, 100%);
    flex: 0 0 520px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

tbody tr:nth-child(even) {
    background: rgba(227, 241, 235, 0.25);
}

tbody tr:hover {
    background: rgba(29, 107, 82, 0.06);
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.employee-cell {
    min-width: 140px;
}

.status-cell {
    min-width: 230px;
    color: var(--muted);
    line-height: 1.6;
}

.edit-form {
    min-width: 280px;
    gap: 10px;
    padding: 14px;
    border: 1px solid #cfe0d8;
    border-radius: 14px;
    background: #f7fbf9;
}

.wide-form {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    align-items: end;
}

.time-compact-input {
    font-size: 20px;
    letter-spacing: 0.12em;
    font-weight: 700;
    text-align: center;
}

.input-error {
    border-color: var(--danger) !important;
    background: var(--danger-soft) !important;
}

.time-input-error {
    grid-column: 1 / -1;
    min-height: 18px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
}

.admin-form {
    grid-template-columns: 1fr;
}

.edit-form-header {
    display: grid;
    gap: 2px;
}

.edit-form-header strong {
    font-size: 14px;
}

.edit-form-header span {
    font-size: 12px;
    color: var(--muted);
}

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

.actions-column {
    min-width: 160px;
    gap: 8px;
}

.daily-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.status-card {
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.status-card span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.status-card strong {
    font-size: 18px;
}

.note-card strong {
    font-size: 16px;
    line-height: 1.5;
}

.actual-card {
    border-color: #bad7cb;
    background: var(--accent-soft);
}

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

.daily-actions form {
    flex: 1 1 180px;
}

.summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 10px;
}

.summary-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.summary-total-card {
    margin-bottom: 12px;
    padding: 14px;
    border-radius: 14px;
    background: var(--accent-soft);
    border: 1px solid #c7dfd4;
}

.summary-total-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.summary-total-card strong {
    font-size: 22px;
    color: var(--accent);
}

.summary-total-card.compact {
    margin-bottom: 0;
    min-width: 220px;
}

.summary-item-text {
    display: grid;
    gap: 3px;
}

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

.summary-item-text small {
    color: var(--muted);
}

.empty-state {
    margin-bottom: 0;
    color: var(--muted);
}

.full-width {
    width: 100%;
}

.inline-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
}

.inline-note {
    display: inline-block;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 13px;
}

.subtle-link {
    background: #fff;
    color: var(--accent);
    border: 1px solid #c7dfd4;
}

.auth-panel {
    margin-top: 18px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-note {
    margin-top: 12px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-sub-actions {
    max-width: 420px;
}

.auth-bootstrap-form {
    grid-template-columns: 1fr;
}

.monthly-table th,
.monthly-table td {
    min-width: 110px;
}

@media (max-width: 1024px) {
    .grid {
        flex-direction: column;
    }

    .side-panel,
    .side-column {
        width: 100%;
        flex-basis: auto;
    }

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

    .dashboard-grid {
        gap: 16px;
    }
}

@media (max-width: 720px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .container {
        width: min(100%, calc(100% - 12px));
        margin-top: 8px;
        margin-bottom: 16px;
    }

    .page-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }

    h1 {
        margin-bottom: 4px;
        font-size: 24px;
    }

    h2 {
        font-size: 18px;
        margin-bottom: 2px;
    }

    .eyebrow {
        margin-bottom: 4px;
    }

    .page-header .subtitle {
        display: none;
    }

    .date-card {
        width: 100%;
        min-width: 0;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .date-card strong {
        font-size: 18px;
    }

    .employee-form {
        grid-template-columns: 1fr;
    }

    .wide-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 12px;
        border-radius: 14px;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: stretch;
    }

    .header-actions .date-card {
        grid-column: 1 / -1;
    }

    .header-actions form,
    .header-actions .button-link,
    .header-actions button {
        width: 100%;
    }

    .daily-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .panel {
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 14px;
    }

    .dashboard-grid,
    .main-column,
    .panel,
    .filter-panel {
        min-width: 0;
        max-width: 100%;
    }

    .filter-panel {
        overflow-x: hidden;
    }

    .panel-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 13px;
    }

    .summary-total-card.compact {
        width: 100%;
        min-width: 0;
        padding: 10px 12px;
    }

    .summary-total-card {
        margin-bottom: 8px;
        padding: 10px 12px;
    }

    .summary-total-card strong {
        font-size: 18px;
    }

    .auth-card {
        width: 100%;
    }

    .filter-panel .filter-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .filter-form > * {
        flex: none;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    .filter-form label {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .filter-form button {
        grid-column: auto;
    }

    .filter-form input[type="date"],
    .filter-form input[type="month"] {
        display: block;
        box-sizing: border-box;
        inline-size: 100%;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        -webkit-appearance: none;
        appearance: none;
    }

    .daily-summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }

    .note-card {
        grid-column: 1 / -1;
    }

    .status-card {
        padding: 10px 12px;
        border-radius: 12px;
    }

    .status-card span {
        margin-bottom: 4px;
    }

    .daily-actions form {
        min-width: 0;
        flex: none;
    }

    .daily-actions form:last-child {
        grid-column: 1 / -1;
    }

    .daily-actions form:last-child button {
        min-height: 42px;
        font-size: 13px;
    }

    input[type="text"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="month"],
    select,
    button,
    .button-link {
        min-height: 44px;
        max-width: 100%;
        padding: 10px 12px;
        border-radius: 11px;
        font-size: 15px;
    }

    .time-compact-input {
        min-height: 48px;
        font-size: 22px;
        letter-spacing: 0.16em;
    }

    .note-field,
    .time-input-error,
    .sticky-save-button {
        grid-column: 1 / -1;
    }

    .edit-form label {
        gap: 3px;
    }

    .edit-form span,
    .filter-form span {
        font-size: 12px;
    }

    .sticky-save-button {
        position: sticky;
        bottom: 8px;
        z-index: 2;
        box-shadow: 0 8px 18px rgba(29, 107, 82, 0.18);
    }

    .admin-mode-banner,
    .flash-list {
        margin-bottom: 10px;
    }

    .admin-mode-banner {
        padding: 10px 12px;
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .monthly-table,
    .monthly-table tbody,
    .monthly-table tr,
    .monthly-table td {
        display: block;
        width: 100%;
    }

    .monthly-table thead {
        display: none;
    }

    .monthly-table tr {
        margin-bottom: 8px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        overflow: hidden;
    }

    .monthly-table td {
        min-width: 0;
        display: grid;
        grid-template-columns: 92px 1fr;
        gap: 8px;
        align-items: start;
        padding: 10px 12px;
        border-bottom: 1px solid rgba(217, 207, 191, 0.7);
    }

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

    .monthly-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

    .inline-link {
        width: 100%;
    }

    .status-card strong {
        font-size: 16px;
        word-break: break-word;
    }
}
