/* ==============================================
   DESIGN TOKENS
   ============================================== */
:root {
    /* Brand */
    --c-primary:        #274530;
    --c-primary-bg:     rgba(91,94,244,.10);

    /* Semantic */
    --c-green:          #059669;
    --c-green-bg:       rgba(5,150,105,.09);
    --c-warm:           #F97316;
    --c-warm-bg:        rgba(249,115,22,.10);
    --c-red:            #EF4444;
    --c-red-bg:         rgba(239,68,68,.08);

    /* Surface */
    --c-bg:             #F4F6FD;
    --c-surface:        #FFFFFF;
    --c-surface-2:      #F8FAFF;
    --c-border:         rgba(17,24,59,.08);
    --c-border-strong:  rgba(17,24,59,.14);

    /* Text */
    --c-text-1:         #0D1226;
    --c-text-2:         #4B5569;
    --c-text-3:         #9AA4BE;

    /* Shadow */
    --sh-xs:            0 1px 3px rgba(13,18,38,.06);
    --sh-sm:            0 2px 10px rgba(13,18,38,.07);
    --sh-md:            0 8px 24px rgba(13,18,38,.09);
    --sh-lg:            0 20px 48px rgba(13,18,38,.12);

    /* Radii */
    --r-s:  10px;
    --r-m:  16px;
    --r-l:  22px;
    --r-xl: 28px;
    --r-2xl:36px;
    --r-full: 9999px;

    /* Spacing */
    --px: 20px;

    /* Type */
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif;
    color: var(--c-text-1);
}

/* ==============================================
   BASE RESET
   ============================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

body {
    background: var(--c-bg);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body.slide-in-from-right .dashboard-shell,
body.slide-in-from-left .dashboard-shell {
    animation-duration: .28s;
    animation-timing-function: cubic-bezier(.2,.9,.2,1);
    animation-fill-mode: both;
}

body.slide-in-from-right .dashboard-shell {
    animation-name: slideInFromRight;
}

body.slide-in-from-left .dashboard-shell {
    animation-name: slideInFromLeft;
}

body.slide-out-to-left .dashboard-shell,
body.slide-out-to-right .dashboard-shell {
    animation-duration: .26s;
    animation-timing-function: cubic-bezier(.2,.9,.2,1);
    animation-fill-mode: both;
}

body.slide-out-to-left .dashboard-shell {
    animation-name: slideOutToLeft;
}

body.slide-out-to-right .dashboard-shell {
    animation-name: slideOutToRight;
}

/* ==============================================
   LOGIN SCREEN
   ============================================== */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(env(safe-area-inset-top), 32px) var(--px) max(env(safe-area-inset-bottom), 32px);
    background: var(--c-bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--c-surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-lg);
    padding: 36px 28px 32px;
    border: 1px solid var(--c-border);
}

/* App brand block at top of login */
.app-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.app-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: var(--r-m);
    background: var(--c-surface);
    border: 1px solid rgba(13,18,38,.08);
    box-shadow: var(--sh-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.app-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-brand-text .app-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--c-text-1);
}

.app-brand-text .app-subtitle {
    font-size: 0.8rem;
    color: var(--c-text-3);
    margin: 3px 0 0;
    font-weight: 400;
}

/* Standalone subtitle (outside brand block) */
.app-subtitle {
    font-size: 0.875rem;
    color: var(--c-text-2);
    line-height: 1.5;
}

/* ==============================================
   FORM ELEMENTS
   ============================================== */
form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-2);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--r-m);
    border: 1.5px solid var(--c-border-strong);
    background: var(--c-surface-2);
    font-size: 1rem;
    font-family: inherit;
    color: var(--c-text-1);
    transition: border-color .18s, box-shadow .18s, background .18s;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(91,94,244,.15);
    background: var(--c-surface);
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-2);
}

.field-block small {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--c-text-3);
}

.field-block input,
.field-block select,
.field-block textarea {
    width: 100%;
    padding: 13px 15px;
    border-radius: var(--r-m);
    border: 1.5px solid var(--c-border-strong);
    background: var(--c-surface-2);
    font-size: 0.975rem;
    font-family: inherit;
    color: var(--c-text-1);
    transition: border-color .18s, box-shadow .18s, background .18s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5;
}

.field-block textarea {
    resize: vertical;
    min-height: 90px;
}

.field-block select {
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 20 20" fill="none"%3E%3Cpath d="M5 7l5 5 5-5" stroke="%239AA4BE" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 42px;
    cursor: pointer;
}

.field-block input:focus,
.field-block select:focus,
.field-block textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(91,94,244,.15);
    background: var(--c-surface);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 2px;
}

.form-card .primary-button {
    width: 100%;
}

.form-feedback {
    min-height: 1.3em;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--c-primary);
    line-height: 1.4;
}

.form-feedback.is-error {
    color: var(--c-red);
}

/* Role selector */
.role-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.role-option {
    position: relative;
    border: 1.5px solid var(--c-border-strong);
    border-radius: var(--r-m);
    padding: 16px 48px 16px 18px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-2);
    background: var(--c-surface-2);
    transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    isolation: isolate;
    min-height: 64px;
    letter-spacing: .01em;
}

.role-option span {
    position: relative;
    z-index: 1;
}

.role-option input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.role-option::after {
    content: '';
    position: absolute;
    top: 16px;
    right: 16px;
    width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    border: 2px solid rgba(13,18,38,.18);
    background: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--c-primary);
    transition: all .15s ease;
    box-shadow: inset 0 2px 3px rgba(13,18,38,.08);
}

.role-option:hover,
.role-option:focus-within,
.role-option.is-focused {
    border-color: var(--c-primary);
    background: rgba(39,69,48,.05);
    box-shadow: 0 0 0 3px rgba(39,69,48,.15);
}

.role-option.is-selected {
    border-color: transparent;
    background: linear-gradient(135deg, #3e744d 0%, #274530 100%);
    color: #fff;
    box-shadow: var(--sh-md), 0 0 0 3px rgba(39,69,48,.25);
}

.role-option.is-selected::after {
    content: '✓';
    border-color: transparent;
    background: rgba(255,255,255,.2);
    color: #fff;
    box-shadow: inset 0 2px 4px rgba(0,0,0,.25);
}

/* ==============================================
   BUTTONS
   ============================================== */
.primary-button {
    border: none;
    padding: 15px 24px;
    border-radius: var(--r-full);
    background: var(--c-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: .01em;
    cursor: pointer;
    transition: transform .12s, opacity .12s;
    min-height: 52px;
}

.primary-button:hover  { opacity: .92; }
.primary-button:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(91,94,244,.25); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.ghost-button {
    border: 1.5px solid var(--c-border-strong);
    background: var(--c-surface);
    padding: 11px 18px;
    border-radius: var(--r-full);
    cursor: pointer;
    color: var(--c-text-2);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    transition: background .15s, border-color .15s;
    min-height: 44px;
    white-space: nowrap;
}

.ghost-button:hover  { background: var(--c-surface-2); border-color: rgba(17,24,59,.20); }
.ghost-button:active { background: rgba(17,24,59,.06); }

.ghost-button.is-danger {
    border-color: rgba(239,68,68,.25);
    color: var(--c-red);
    background: var(--c-red-bg);
}
.ghost-button.is-danger:hover {
    background: rgba(239,68,68,.14);
    border-color: rgba(239,68,68,.45);
}

.ghost-button.ghost-compact {
    padding: 7px 13px;
    font-size: 0.8rem;
    min-height: 34px;
}

/* ==============================================
   NOTICES
   ============================================== */
.notice {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-red);
    min-height: 1.2em;
    line-height: 1.4;
}

.system-error {
    margin-bottom: 16px;
    padding: 13px 16px;
    border-radius: var(--r-m);
    background: rgba(254,242,242,.9);
    color: #B91C1C;
    border: 1px solid rgba(239,68,68,.2);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
}

/* ==============================================
   DASHBOARD SHELL
   ============================================== */
.dashboard-shell {
    max-width: 680px;
    margin: 0 auto;
    padding-bottom: max(env(safe-area-inset-bottom), 40px);
}

/* ==============================================
   TOP APP BAR
   ============================================== */
.dashboard-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding:
        max(env(safe-area-inset-top), 14px)
        var(--px)
        14px;
    background: rgba(244,246,253,.88);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--c-border);
}

.dashboard-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dashboard-brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.dashboard-brand-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--r-l);
    overflow: hidden;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    flex-shrink: 0;
}

.dashboard-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dashboard-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--c-text-1);
}

.dashboard-header .app-subtitle {
    font-size: 0.75rem;
    color: var(--c-text-3);
    font-weight: 400;
}

.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.header-icon-link {
    text-decoration: none;
    font-size: 1rem;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}

.header-icon-link i {
    line-height: 1;
    font-size: 0.95rem;
}

.header-icon-link.is-help,
.header-icon-link.is-home {
    background: #2563eb;
}

.header-icon-link.is-logout {
    background: #ef4444;
}

.header-icon-link:hover {
    transform: translateY(-1px);
    filter: brightness(.95);
}

.header-icon-link:active {
    transform: translateY(0);
    filter: brightness(.9);
}

.header-icon-link:focus-visible {
    outline: 2px solid rgba(37,99,235,.35);
    outline-offset: 2px;
}

/* ==============================================
   HELP PAGE
   ============================================== */
.help-shell {
    max-width: 680px;
    margin: 0 auto;
    padding-bottom: max(env(safe-area-inset-bottom), 36px);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.help-shell > .dashboard-header {
    margin-bottom: 8px;
}

.help-shell > .card,
.help-shell > .help-column-list {
    margin: 14px var(--px) 0;
}

.help-column-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.help-column-list .card {
    margin: 0;
}

.help-card {
    gap: 12px;
}

.help-card.hero {
    background: linear-gradient(135deg, #F5FAFF 0%, #F3FFF4 100%);
    border: none;
    color: var(--c-text-1);
}

.help-card.hero h1 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.help-card.hero .help-subtitle {
    font-size: 0.9rem;
    color: var(--c-text-2);
}

.help-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    font-weight: 700;
    color: var(--c-text-3);
}

.help-subtitle {
    font-size: 0.9rem;
    color: var(--c-text-2);
    line-height: 1.6;
}

.help-card h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--c-text-1);
}

.help-step-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    color: var(--c-text-3);
}

.help-checklist,
.help-steps,
.help-tips {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--c-text-2);
    line-height: 1.5;
}

.help-checklist {
    list-style: disc;
}

.help-steps {
    list-style: decimal;
}

.help-tips {
    list-style: disc;
}

.help-tips strong,
.help-steps strong {
    color: var(--c-text-1);
}

.help-card.hero ul {
    color: rgba(4, 32, 24, .9);
}

.toc-card {
    gap: 0;
}

.toc-accordion summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--c-text-1);
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toc-accordion summary::-webkit-details-marker {
    display: none;
}

.toc-accordion summary::after {
    content: '＋';
    font-size: 1rem;
    color: var(--c-text-3);
    transition: transform .15s ease;
}

.toc-accordion[open] summary::after {
    content: '−';
}

.toc-list {
    margin: 10px 0 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.88rem;
}

.toc-list a {
    color: var(--c-text-2);
    text-decoration: none;
}

.toc-list a:hover {
    color: var(--c-primary);
    text-decoration: underline;
}

.toc-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows .24s ease, opacity .2s ease;
}

.toc-panel .toc-list {
    overflow: hidden;
}

.toc-accordion[open] .toc-panel {
    grid-template-rows: 1fr;
    opacity: 1;
}

.help-ui-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-stats-guide .stat-card {
    cursor: default;
}

.help-card .help-stats-guide {
    padding: 2px 0 0;
}

.preview-card {
    border: 1px solid var(--c-border);
    background: var(--c-surface-2);
    border-radius: var(--r-m);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preview-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--c-text-1);
}

.preview-line {
    font-size: 0.84rem;
    color: var(--c-text-2);
    line-height: 1.45;
}

.preview-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.preview-chips span {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--c-primary);
    background: rgba(39,69,48,.1);
    border: 1px solid rgba(39,69,48,.18);
    border-radius: var(--r-full);
    padding: 4px 9px;
}

/* ==============================================
   STATS GRID
   ============================================== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 20px var(--px) 0;
}

/* Hero card spans full width */
.stats-grid > .stat-card:first-child {
    grid-column: 1 / -1;
}

.stats-grid > .stat-card:nth-child(2) {
    background: linear-gradient(135deg, #E3F2FF 0%, #CDE9FF 50%, #B3E5FC 100%);
    border: none;
    box-shadow: 0 18px 35px rgba(79,156,205,.25);
}

.stats-grid > .stat-card:nth-child(2) .stat-label,
.stats-grid > .stat-card:nth-child(2) .stat-sub {
    color: rgba(15, 35, 51, .72);
}

.stats-grid > .stat-card:nth-child(3) {
    background: linear-gradient(135deg, #E3FFF5 0%, #C0F5E4 50%, #9EE9D6 100%);
    border: none;
    box-shadow: 0 18px 35px rgba(20,161,117,.2);
}

.stats-grid > .stat-card:nth-child(3) .stat-label,
.stats-grid > .stat-card:nth-child(3) .stat-sub {
    color: rgba(3, 63, 44, .72);
}

/* Warning card spans full width */
.stats-grid > .stat-card.warning {
    grid-column: 1 / -1;
}

.stat-card {
    border-radius: var(--r-l);
    padding: 16px 18px;
    background: var(--c-surface);
    box-shadow: var(--sh-xs);
    border: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-card.accent {
    background: var(--c-primary);
    color: #fff;
    border: none;
    padding: 22px 22px 20px;
}

.stat-card.warning {
    background: var(--c-warm);
    color: #fff;
    border: none;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
}

.stat-card.warning .stat-value {
    font-size: 1.6rem;
}

.stat-card.warning .stat-label,
.stat-card.warning .stat-sub {
    color: rgba(255,255,255,.78);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--c-text-3);
}

.stat-card.accent .stat-label {
    color: rgba(255,255,255,.72);
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 5px 0 2px;
}

.stat-card.accent .stat-value {
    font-size: 2.1rem;
    margin: 7px 0 3px;
}

.stat-sub {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--c-text-3);
}

.stat-card.accent .stat-sub {
    color: rgba(255,255,255,.72);
}

/* ==============================================
   CARD GRID
   ============================================== */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px var(--px) 0;
}

/* ==============================================
   CARD
   ============================================== */
.card {
    background: var(--c-surface);
    border-radius: var(--r-l);
    padding: 20px;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card.form-card.is-edit-target {
    animation: editTargetPulse 1.2s ease-in-out;
}

.card header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 14px;
}

.card h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--c-text-1);
    letter-spacing: -0.01em;
}

.card-caption {
    font-size: 0.78rem;
    color: var(--c-text-3);
    line-height: 1.4;
    font-weight: 400;
}

/* ==============================================
   HISTORY CARD
   ============================================== */
.history-card {
    margin: 14px var(--px) 0;
    background: var(--c-surface);
    border-radius: var(--r-l);
    padding: 20px;
    box-shadow: var(--sh-sm);
    border: 1px solid var(--c-border);
}

.history-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--c-border);
}

.history-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--c-text-1);
    letter-spacing: -0.01em;
}

.history-header .card-caption {
    font-size: 0.78rem;
    color: var(--c-text-3);
    margin-top: 2px;
}

.history-header > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* ==============================================
   SUMMARY LIST
   ============================================== */
.summary-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--c-border);
    border-radius: var(--r-s);
    padding: 12px 15px;
    background: var(--c-surface-2);
    transition: background .15s;
}

.summary-pill:hover { background: var(--c-bg); }

.summary-pill .month-label { font-size: 0.9rem; }
.summary-pill .month-hours { font-size: 0.78rem; margin-top: 1px; }

.summary-pill strong {
    font-size: 1rem;
    font-weight: 800;
    color: var(--c-text-1);
    letter-spacing: -0.02em;
}

/* ==============================================
   MONTHLY ACCORDION
   ============================================== */
.monthly-groups {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 15px;
}

.month-block {
    border: 1px solid var(--c-border);
    border-radius: var(--r-s);
    overflow: hidden;
    background: var(--c-surface);
}

.month-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    gap: 12px;
    width: 100%;
    border: none;
    background: transparent;
    padding: 14px 16px;
    font: inherit;
    color: inherit;
    text-align: left;
    min-height: 54px;
    transition: background .15s;
}

.month-summary:hover   { background: var(--c-surface-2); }
.month-summary:focus-visible { outline: 2px solid var(--c-primary); outline-offset: -2px; }

.month-toggle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--c-surface-2);
    border: 1.5px solid var(--c-border-strong);
    flex-shrink: 0;
    position: relative;
    transition: background .2s, border-color .2s;
}

.month-toggle::before,
.month-toggle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 1.5px;
    background: var(--c-text-3);
    transition: transform .2s ease, background .2s;
}

.month-toggle::before { transform: translate(-78%, -50%) rotate(45deg); }
.month-toggle::after  { transform: translate(-22%, -50%) rotate(-45deg); }

.month-block.is-open .month-toggle {
    background: var(--c-primary);
    border-color: var(--c-primary);
}

.month-block.is-open .month-toggle::before {
    background: #fff;
    transform: translate(-78%, -50%) rotate(-45deg);
}

.month-block.is-open .month-toggle::after {
    background: #fff;
    transform: translate(-22%, -50%) rotate(45deg);
}

.month-block .month-body {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.4,0,.2,1), padding .3s ease;
}

.month-block.is-open .month-body {
    padding: 0 16px 14px;
    border-top: 1px solid var(--c-border);
}

@media (prefers-reduced-motion: reduce) {
    .month-block .month-body { transition: none; }
}

.month-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--c-text-1);
    letter-spacing: -0.01em;
}

.month-hours {
    font-size: 0.78rem;
    color: var(--c-text-3);
    margin-top: 2px;
    font-weight: 500;
}

/* ==============================================
   DAILY ENTRY (WORK LOG)
   ============================================== */
.daily-entry {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid rgba(17,24,59,.05);
    animation: fadeSlide .3s ease both;
}

.daily-entry:first-of-type { border-top: none; padding-top: 10px; }

.daily-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.daily-meta {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-1);
}

.daily-notes {
    font-size: 0.84rem;
    color: var(--c-text-2);
    line-height: 1.45;
    overflow-wrap: break-word;
}

.daily-hours-tag {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--c-primary);
    white-space: nowrap;
    background: var(--c-primary-bg);
    padding: 4px 11px;
    border-radius: var(--r-full);
    flex-shrink: 0;
}

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

/* ==============================================
   PAYMENT / LOG ENTRY
   ============================================== */
.payment-entry,
.log-entry {
    padding: 13px 0;
    border-top: 1px solid rgba(17,24,59,.05);
    animation: fadeSlide .3s ease both;
}

.payment-entry:first-of-type,
.log-entry:first-of-type {
    border-top: none;
    padding-top: 6px;
}

.payment-meta,
.log-meta {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-1);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.payment-amount {
    font-weight: 800;
    font-size: 1rem;
    color: var(--c-green);
    letter-spacing: -0.02em;
}

.payment-note,
.log-note {
    margin-top: 4px;
    font-size: 0.84rem;
    color: var(--c-text-2);
    line-height: 1.45;
}

.log-note { white-space: pre-line; }

.payment-actions {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.payment-actions .action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.audit-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding-top: 10px;
}

.audit-tabs .ghost-button.is-active {
    background: rgba(39,69,48,.10);
    border-color: rgba(39,69,48,.30);
    color: var(--c-primary);
}

.audit-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.audit-action.action-create {
    color: #0f766e;
    background: rgba(13,148,136,.10);
    border-color: rgba(13,148,136,.25);
}

.audit-action.action-update {
    color: #b45309;
    background: rgba(245,158,11,.12);
    border-color: rgba(245,158,11,.28);
}

.audit-action.action-delete {
    color: #b91c1c;
    background: rgba(239,68,68,.11);
    border-color: rgba(239,68,68,.28);
}

/* ==============================================
   TAGS / META CHIPS
   ============================================== */
.entry-meta-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.tag-muted {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--c-surface-2);
    color: var(--c-text-3);
    border: 1px solid var(--c-border);
    letter-spacing: .01em;
}

/* ==============================================
   EMPTY STATE
   ============================================== */
.empty-state {
    padding: 28px 16px;
    border-radius: var(--r-m);
    background: var(--c-surface-2);
    color: var(--c-text-3);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1.5px dashed rgba(17,24,59,.10);
}

/* history-card: gap は 0 にして header の padding-bottom で分離 */
.card.history-card {
    gap: 0;
}

/* 管理者: card-grid の外にある summary-card に水平マージンを付与 */
.dashboard-shell > .card.summary-card {
    margin: 14px var(--px) 0;
}

/* スタッフ: 作業入力フォームの form-grid を 1カラム 2行に */
[data-staff-dashboard] .form-grid {
    grid-template-columns: 1fr;
}

/* 管理者: 支払登録フォームの form-grid を 1カラム 2行に */
[data-payment-card] .form-grid {
    grid-template-columns: 1fr;
}

.is-hidden { display: none !important; }

/* ==============================================
   LOADING OVERLAY
   ============================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,18,38,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.loading-overlay[hidden] { display: none !important; }

.loading-panel {
    background: var(--c-surface);
    border-radius: var(--r-xl);
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: var(--sh-lg);
}

.loading-panel p {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-2);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(91,94,244,.18);
    border-top-color: var(--c-primary);
    animation: spin .75s linear infinite;
}

/* ==============================================
   ANIMATIONS
   ============================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromRight {
    from { opacity: .82; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromLeft {
    from { opacity: .82; transform: translateX(-24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutToLeft {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: .78; transform: translateX(-24px); }
}

@keyframes slideOutToRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: .78; transform: translateX(24px); }
}

@keyframes editTargetPulse {
    0%, 100% {
        background: var(--c-surface);
        border-color: var(--c-border);
    }
    35%, 75% {
        background: rgba(239,68,68,.10);
        border-color: rgba(239,68,68,.35);
    }
}

/* ==============================================
   RESPONSIVE OVERRIDES
   ============================================== */
@media (min-width: 480px) {
    /* 3-column stats row on wider phones */
    .stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    /* Warning card reverts to auto (fills 1 of 3 columns) */
    .stats-grid > .stat-card.warning {
        grid-column: auto;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 16px 18px;
    }

    .stat-card.warning .stat-value { font-size: 1.55rem; }

    /* 2-column form grid */
    .card-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card.form-card.is-edit-target {
        animation: none;
        background: rgba(239,68,68,.10);
        border-color: rgba(239,68,68,.35);
    }
}

@media (min-width: 640px) {
    :root { --px: 28px; }

    .login-card { padding: 40px 36px 36px; }

    .dashboard-title { font-size: 1.25rem; }

    .card { padding: 24px; }
    .history-card { padding: 24px; }

    .stat-card.accent .stat-value { font-size: 2.4rem; }
}
