:root {
    --primary: #0056b3;
    --primary-light: #e6f0fb;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --bg: #f4f7f6;
    --card: #ffffff;
    --text: #333;
    --text-muted: #666;
    --border: #e0e0e0;
    --accent: #e9ecef;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Helvetica Neue', 'Hiragino Sans', 'Yu Gothic', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ==== Login ==== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card);
    padding: 28px 24px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 360px;
}
.login-card h1 {
    margin: 0 0 6px 0;
    font-size: 22px;
    color: var(--primary);
    text-align: center;
}
.login-card .sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 22px;
}

/* ==== Header ==== */
.app-header {
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header h1 { font-size: 16px; margin: 0; font-weight: bold; }
.app-header nav { display: flex; gap: 4px; align-items: center; }
.app-header nav a, .app-header nav button {
    color: #fff;
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    border: none;
    text-decoration: none;
}
.app-header nav a:hover, .app-header nav button:hover { background: rgba(255,255,255,0.25); }
.app-header .me { font-size: 12px; margin-right: 8px; opacity: 0.85; }

/* ==== Layout ==== */
.app {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.panel {
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    padding: 14px;
}
.panel h2 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==== Forms ==== */
label { display: block; font-size: 12px; font-weight: bold; color: var(--text-muted); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fafafa;
    color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
textarea { min-height: 70px; resize: vertical; }

.form-row { margin-bottom: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid-2.full { grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }

.btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background: var(--primary);
}
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-warning { background: var(--warning); color: #333; }
.btn-ghost   { background: var(--accent); color: var(--text); }
.btn-block { width: 100%; padding: 14px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ==== Calendar ==== */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.cal-title { font-weight: bold; font-size: 16px; color: var(--primary); }
.cal-views { display: flex; gap: 4px; }
.cal-views button {
    padding: 6px 10px;
    border: 1px solid var(--primary);
    background: #fff;
    color: var(--primary);
    border-radius: 6px;
    font-size: 12px;
}
.cal-views button.active { background: var(--primary); color: #fff; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.cal-dow {
    background: var(--accent);
    text-align: center;
    padding: 6px 0;
    font-weight: bold;
    font-size: 12px;
    color: var(--text-muted);
}
.cal-dow.sun { color: var(--danger); }
.cal-dow.sat { color: var(--primary); }
.cal-cell {
    background: #fff;
    min-height: 80px;
    padding: 4px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}
.cal-cell:hover { background: var(--primary-light); }
.cal-cell.other-month { background: #f8f9fa; color: #ccc; }
.cal-cell.today { background: #fff7e6; }
.cal-cell .date {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 3px;
}
.cal-cell .date.sun { color: var(--danger); }
.cal-cell .date.sat { color: var(--primary); }
.cal-event {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
}
.cal-event.status-done { opacity: 0.55; text-decoration: line-through; }
.cal-event.status-canceled { opacity: 0.4; text-decoration: line-through; }
.cal-event.status-in_progress { box-shadow: inset 0 0 0 2px #fff; }
/* 複数担当: 文字の輪郭を付けて読みやすく */
.cal-event.multi-staff {
    text-shadow: 0 0 2px rgba(0,0,0,0.55), 0 0 1px rgba(0,0,0,0.7);
    font-weight: 600;
}

/* 担当者ミニチップ（day-list 用） */
.staff-chips-row {
    display: inline-flex;
    gap: 3px;
    flex-wrap: wrap;
    vertical-align: middle;
}
.staff-mini-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 1px rgba(0,0,0,0.4);
    line-height: 1.5;
    white-space: nowrap;
}
.day-list .day-event.multi-staff { border-left-width: 4px; border-left-style: solid; }

/* Day/Week list view */
.day-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.day-list .day-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}
.day-list .day-section h4 {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: var(--text-muted);
}
.day-list .day-event {
    background: var(--card);
    border-left: 4px solid var(--primary);
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.day-list .day-event small { color: var(--text-muted); display: block; font-size: 11px; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    margin-right: 4px;
}
.badge.planned     { background: #e3f2fd; color: var(--primary); }
.badge.in_progress { background: #fff3cd; color: #856404; }
.badge.done        { background: #d4edda; color: #155724; }
.badge.canceled    { background: #f8d7da; color: #721c24; }

/* ==== Tree (sidebar) ==== */
.tree-root {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 460px;
    overflow-y: auto;
}
.tree-parent {
    background: var(--accent);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    border-left: 4px solid var(--primary);
}
.tree-parent.active { background: var(--primary-light); border-left-color: var(--success); }
.tree-parent .title { font-weight: bold; font-size: 13px; }
.tree-parent .meta { font-size: 11px; color: var(--text-muted); }
.tree-children {
    margin-left: 14px;
    margin-top: 4px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tree-child {
    font-size: 12px;
    padding: 3px 6px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* ==== Modal ==== */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 12px;
}
.modal-bg.show { display: flex; }
.modal {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal.modal-wide { max-width: 720px; }
.modal h3 { margin: 0 0 12px 0; color: var(--primary); }
.modal .close-x {
    float: right;
    font-size: 22px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
}

/* 1画面構成のセクション */
.modal-section {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.modal-section .section-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: bold;
    color: var(--primary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.modal-section.section-actions {
    background: #fff8e6;
    border-color: #ffe0a3;
}
.modal-section.section-actions .section-title {
    color: #b8860b;
    border-bottom-color: #ffe0a3;
}
.modal-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 2px solid var(--border);
    margin-top: 6px;
    position: sticky;
    bottom: -20px;
    background: var(--card);
    padding-bottom: 4px;
    margin-bottom: -10px;
}

/* ==== Tables ==== */
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; }
table.list th { background: var(--accent); color: var(--text-muted); font-weight: bold; font-size: 12px; }

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* ==== Misc ==== */
.flash {
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}
.flash.error { background: #f8d7da; color: #721c24; }
.flash.success { background: #d4edda; color: #155724; }

.muted { color: var(--text-muted); font-size: 12px; }

.tab-group { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-group button {
    padding: 8px 14px;
    background: var(--accent);
    color: var(--text);
    border: none;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    font-weight: bold;
}
.tab-group button.active { background: var(--card); color: var(--primary); border-bottom: 2px solid var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.diff-warn {
    background: #fff3cd;
    color: #856404;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 6px;
}

/* ==== Event Kind Tabs (仕事/休み/個人予定) ==== */
.event-kind-tabs {
    display: flex;
    gap: 4px;
    background: var(--accent);
    border-radius: 10px;
    padding: 4px;
}
.event-kind-tabs label {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    color: var(--text-muted);
    transition: 0.15s;
    margin: 0;
}
.event-kind-tabs label:has(input:checked) {
    background: var(--card);
    color: var(--primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.event-kind-tabs label:has(input[value="off"]:checked) { color: #6c757d; }
.event-kind-tabs label:has(input[value="private"]:checked) { color: #d63384; }
.event-kind-tabs input[type="radio"] { display: none; }

/* ==== Calendar holiday/off/private styling ==== */
.cal-cell.holiday { background: #fff5f5; }
.cal-cell .holiday-name {
    font-size: 9px;
    color: var(--danger);
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1.1;
}
.cal-cell .date.holiday-date { color: var(--danger); }

/* 休み・個人予定はインラインstyleで担当スタッフ色を反映するため、
   ここでは共通の文字色のみ指定 */
.cal-event.kind-off {
    color: #222;
    background-color: #fff; /* 斜線の隙間を白く（インラインstyleで上書きされる） */
    text-shadow: 0 0 2px #fff, 0 0 4px #fff;
    font-weight: bold;
    font-size: 11px;
}
.cal-event.kind-private {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-weight: bold;
}
/* 完了ジョブの取り消し線は外す（チェックマークで表現するため） */
.cal-event.status-done {
    opacity: 0.65;
    text-decoration: none;
}

.day-event.kind-off {
    background: repeating-linear-gradient(
        45deg, #f8f9fa, #f8f9fa 6px, #e9ecef 6px, #e9ecef 12px);
}
.day-event.kind-private {
    background: #f5edff;
    border-right: 2px solid #6f42c1;
}

/* ==== Photos ==== */
.photo-section { margin-bottom: 16px; }
.photo-section-title {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.photo-count {
    background: var(--accent);
    color: var(--text-muted);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: bold;
}
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    min-height: 30px;
}
.photo-item {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
    cursor: zoom-in;
}
.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.photo-item .photo-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.photo-item:hover .photo-actions { opacity: 1; }
.photo-item .photo-actions button {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 12px;
    cursor: pointer;
}
.photo-item .photo-actions button:hover { background: rgba(220,53,69,0.9); }
.photo-grid .photo-empty {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px;
    text-align: center;
    background: #fafafa;
    border-radius: 6px;
}

/* ==== Staff chip list（担当スタッフ複数選択） ==== */
.staff-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.staff-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 18px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: 0.12s;
}
.staff-chip input[type="checkbox"] { display: none; }
.staff-chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
}
.staff-chip:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,86,179,0.15);
}

/* ==========================================================
   Mobile (≤768px) — iOS カレンダー風コンパクト表示
   ========================================================== */
@media (max-width: 768px) {
    body { background: #fff; }

    /* ---- Header をコンパクトに ---- */
    .app-header {
        padding: 8px 10px;
        background: #fff;
        color: #111;
        box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    }
    .app-header h1 {
        font-size: 18px;
        color: #111;
        font-weight: 800;
        letter-spacing: 0.5px;
    }
    .app-header nav { gap: 2px; }
    .app-header nav a,
    .app-header nav button {
        background: #f1f3f5;
        color: #333;
        padding: 5px 9px;
        font-size: 11px;
        border-radius: 14px;
    }
    .app-header .me { display: none; }

    /* ---- レイアウト ---- */
    .app {
        padding: 0;
        gap: 0;
        max-width: 100%;
    }
    .panel {
        border-radius: 0;
        box-shadow: none;
        padding: 8px 10px 12px;
    }

    /* ---- カレンダーツールバー（年月＋フィルタ） ---- */
    .cal-toolbar {
        position: sticky;
        top: 40px;
        background: #fff;
        z-index: 50;
        margin: 0 -10px 6px;
        padding: 6px 12px;
        border-bottom: 1px solid #eee;
    }
    .cal-title {
        font-size: 22px;
        font-weight: 800;
        color: #111;
    }
    .cal-toolbar > div:first-child {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .cal-views {
        background: #f1f3f5;
        border-radius: 18px;
        padding: 3px;
    }
    .cal-views button {
        border: none;
        background: transparent;
        color: #555;
        padding: 5px 12px;
        font-size: 12px;
        font-weight: 600;
        border-radius: 14px;
    }
    .cal-views button.active {
        background: #fff;
        color: #111;
        box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    }
    #cal-prev, #cal-next, #cal-today {
        background: transparent;
        color: #111;
        font-size: 16px;
        padding: 4px 8px;
    }

    /* ---- カレンダー本体（罫線なし・余白詰め） ---- */
    .cal-grid {
        gap: 0;
        background: transparent;
        border: none;
        border-radius: 0;
    }
    .cal-dow {
        background: transparent;
        font-size: 10px;
        font-weight: 600;
        padding: 3px 0 5px;
        color: #888;
        border-bottom: 1px solid #ececec;
    }
    .cal-cell {
        min-height: 78px;
        padding: 2px 2px 3px;
        border-bottom: 1px solid #f0f0f0;
        border-right: 1px solid #f0f0f0;
        overflow: hidden;
    }
    .cal-cell:nth-child(7n) { border-right: none; }
    .cal-cell:hover { background: transparent; }
    .cal-cell.other-month { background: #fafafa; color: #ccc; }
    .cal-cell.today { background: transparent; }
    .cal-cell.today .date {
        background: var(--danger);
        color: #fff;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 11px;
    }
    .cal-cell .date {
        font-size: 12px;
        font-weight: 700;
        color: #222;
        margin-bottom: 1px;
        line-height: 1.2;
    }
    .cal-cell .holiday-name {
        font-size: 8px;
        line-height: 1.05;
        margin-bottom: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .cal-event {
        font-size: 9px;
        padding: 1px 3px;
        border-radius: 2px;
        margin-bottom: 1px;
        line-height: 1.25;
        font-weight: 600;
        letter-spacing: -0.2px;
    }
    .cal-event.kind-off {
        font-size: 9px;
        text-shadow: 0 0 1px #fff;
    }

    /* ---- ジョブ一覧（カレンダーの下） ---- */
    aside .panel h2 {
        font-size: 13px;
        margin-bottom: 8px;
    }
    .tree-root { max-height: none; }
    .tree-parent { padding: 8px 10px; }
    .tree-parent .title { font-size: 14px; }
    .tree-children { margin-left: 8px; }
    .tree-child { font-size: 12px; padding: 6px 8px; }

    /* 「＋ 新規」をフローティング化 */
    aside .panel h2 #btn-new-parent {
        position: fixed;
        right: 16px;
        bottom: 16px;
        z-index: 200;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        font-size: 0;
        padding: 0;
        box-shadow: 0 4px 14px rgba(0,86,179,0.35);
    }
    aside .panel h2 #btn-new-parent::before {
        content: "＋";
        font-size: 26px;
        font-weight: 300;
        color: #fff;
    }

    /* ---- モーダル：スマホは全画面 ---- */
    .modal-bg { padding: 0; align-items: stretch; }
    .modal,
    .modal.modal-wide {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 14px 14px 80px;
    }
    .modal h3 { font-size: 16px; }
    .modal-section {
        padding: 10px 12px;
        margin-bottom: 10px;
        border-radius: 8px;
    }
    .modal-section .section-title {
        font-size: 13px;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-row { margin-bottom: 10px; }
    input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
    input[type="number"], input[type="date"], input[type="datetime-local"],
    select, textarea {
        font-size: 16px; /* iOS のズーム抑止 */
        padding: 9px 10px;
    }
    .modal-footer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding: 10px 14px env(safe-area-inset-bottom);
        background: #fff;
        border-top: 1px solid var(--border);
        z-index: 10;
    }
    .modal .close-x {
        position: absolute;
        top: 8px;
        right: 10px;
        font-size: 28px;
        line-height: 1;
        z-index: 5;
    }

    /* ---- 「この日の予定」モーダルを下からシート風に ---- */
    #modal-day .modal {
        max-width: 100%;
        margin-top: auto;
        border-radius: 14px 14px 0 0;
        max-height: 80vh;
        padding: 14px;
    }
    #modal-day { align-items: flex-end; }

    /* ---- 写真グリッド：3列固定 ---- */
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    /* イベント種別タブ */
    .event-kind-tabs label {
        font-size: 12px;
        padding: 8px 4px;
    }
}

/* さらに狭い画面（≤380px iPhone SE 等）向け微調整 */
@media (max-width: 380px) {
    .cal-cell { min-height: 68px; }
    .cal-event { font-size: 8.5px; }
    .cal-cell .date { font-size: 11px; }
    .cal-title { font-size: 19px; }
}

/* ホームダッシュボード */
.home-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.home-summary-cards .card {
    background: var(--card);
    padding: 14px 12px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-top: 4px solid var(--primary);
    text-align: center;
}
.home-summary-cards .card h4 { margin: 0 0 6px 0; font-size: 12px; color: var(--text-muted); font-weight: bold; }
.home-summary-cards .card p { margin: 0; font-size: 18px; font-weight: bold; }

/* 顧客一覧 */
.cust-list { display: flex; flex-direction: column; gap: 8px; }
.cust-row {
    background: var(--card);
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: 0.15s;
    border-left: 4px solid var(--primary);
}
.cust-row:hover { transform: translateX(2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.cust-row .name { font-weight: bold; font-size: 15px; margin-bottom: 4px; }
.cust-row .meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.cust-row .meta .badge-count { background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }

/* スマホ下部固定ナビ */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 90;
    justify-content: space-around;
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
}
.bottom-nav-btn .ico { font-size: 22px; line-height: 1; }
.bottom-nav-btn.active { color: var(--primary); }
.bottom-nav-btn.bottom-nav-fab {
    position: relative;
}
.bottom-nav-btn.bottom-nav-fab .ico {
    background: var(--primary);
    color: #fff;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-top: -14px;
    box-shadow: 0 4px 10px rgba(0,86,179,0.35);
    font-size: 24px;
}
@media (max-width: 768px) {
    .bottom-nav { display: flex; }
    body { padding-bottom: 64px; }
}

/* スタッフ別カレンダーフィルタ */
.cal-staff-filter {
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
    flex-wrap: wrap;
    align-items: center;
}
.cal-staff-filter .cal-staff-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: #fff;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    color: var(--text);
    transition: 0.15s;
}
.cal-staff-filter .cal-staff-chip:hover { border-color: var(--primary); }
.cal-staff-filter .cal-staff-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cal-staff-filter .cal-staff-chip .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary);
    border: 1px solid rgba(0,0,0,0.1);
}

/* ============================================================
   売上管理 / 経費 / PL（経営）パート(旧 pikauriage を統合)
   ============================================================ */

/* ページタブ */
.page-tabs {
    display: flex;
    gap: 0;
    padding: 0 15px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 50px;
    z-index: 50;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.page-tab {
    background: transparent;
    border: none;
    padding: 14px 18px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    font-size: 14px;
    transition: 0.15s;
    white-space: nowrap;
}
.page-tab:hover { color: var(--primary); background: rgba(0,86,179,0.04); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.page-content { display: block; }

/* 売上管理ページのコンテナ */
.page-content > .container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 80px;
}
.page-content h2 { font-size: 18px; margin-top: 0; margin-bottom: 15px; text-align: center; color: var(--primary); }
.page-content h3 { font-size: 15px; color: var(--text-muted); margin: 20px 0 12px 0; }

/* 経費入力(折りたたみ) */
.expense-input { background: var(--card); padding: 14px 18px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); margin-bottom: 22px; }
.expense-input summary { cursor: pointer; font-weight: bold; color: var(--danger); font-size: 15px; user-select: none; }
.expense-input[open] summary { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
@media (min-width: 600px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
.form-group label { display: block; font-weight: bold; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }
.form-group input, .form-group select { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; box-sizing: border-box; font-size: 16px; background-color: #fafafa; appearance: none; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); background: #fff; }

.shortcut-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.shortcut-tag { background: #f8f9fa; color: var(--danger); padding: 8px 12px; border-radius: 18px; font-size: 13px; font-weight: bold; cursor: pointer; border: 1px solid #f5c6cb; user-select: none; transition: 0.2s; }
.shortcut-tag.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.clear-tag { background: #e2e3e5; color: #383d41; border-color: #d6d8db; margin-left: auto; }

.expense-type-toggle { display: flex; gap: 10px; }
.expense-type-toggle label { flex: 1; text-align: center; padding: 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 14px; background: #fff; }
.expense-type-toggle input[type="radio"] { display: none; }
.expense-type-toggle input[type="radio"]:checked + label { background: var(--primary); color: #fff; border-color: var(--primary); }

.save-btn { background-color: var(--primary); color: #fff; border: none; padding: 14px; border-radius: 10px; font-size: 15px; width: 100%; font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.08); }
.save-btn:active { transform: translateY(2px); }
.cancel-btn { background-color: #6c757d; color: #fff; border: none; padding: 12px; border-radius: 10px; font-size: 14px; width: 100%; font-weight: bold; cursor: pointer; margin-top: 10px; display: none; }

/* ダッシュボード */
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.dashboard-header h3 { margin: 0; }
.period-selector { display: flex; gap: 5px; align-items: center; }
.period-selector input[type="month"] { padding: 6px 10px; border: 2px solid var(--primary); border-radius: 6px; font-size: 14px; font-weight: bold; color: var(--primary); outline: none; }

.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.summary-cards .card { background: var(--card); padding: 14px 10px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-top: 4px solid var(--primary); text-align: center; }
.summary-cards .card h4 { margin: 0 0 5px 0; font-size: 12px; color: var(--text-muted); font-weight: bold; }
.summary-cards .card p { margin: 0; font-size: 17px; font-weight: bold; }

/* 集客元別カード */
.channel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 22px; }
.channel-card { background: var(--card); padding: 14px 16px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-left: 4px solid var(--primary); }
.channel-card.direct { border-left-color: #28a745; }
.channel-card.kurama { border-left-color: #fd7e14; }
.channel-card.mitsumore { border-left-color: #17a2b8; }
.channel-card.coop { border-left-color: #dc3545; }
.channel-card h4 { margin: 0 0 10px 0; font-size: 14px; color: var(--text); border-bottom: 1px solid #eee; padding-bottom: 6px; }
.channel-stat { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; color: var(--text-muted); }
.channel-stat .val { font-weight: bold; color: var(--text); }
.channel-stat .val.profit { color: var(--success); }
.channel-stat .val.rate { color: var(--primary); }

/* PL(損益計算書) */
.pl-section { background: linear-gradient(180deg, #f0f9ff, #fff); border: 2px solid #17a2b8; border-radius: 12px; padding: 18px; margin-bottom: 22px; }
.pl-section > h3 { margin: 0 0 12px 0; color: #17a2b8; }
.pl-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.pl-period-tabs { display: flex; gap: 4px; background: #fff; border-radius: 8px; padding: 3px; border: 1px solid var(--border); }
.pl-period-tabs button { background: transparent; border: none; padding: 6px 14px; border-radius: 6px; font-weight: bold; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.pl-period-tabs button.active { background: #17a2b8; color: #fff; }
.pl-rate-controls { background: #fff; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.pl-rate-controls input[type="number"] { width: 70px; padding: 4px 8px; font-size: 14px; }
.pl-matrix-wrap { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); margin-bottom: 14px; }
.pl-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.pl-matrix th, .pl-matrix td { border-bottom: 1px solid #f0f0f0; padding: 8px 10px; text-align: right; white-space: nowrap; font-family: 'Helvetica Neue', monospace; }
.pl-matrix th { background: #f8f9fa; font-weight: bold; color: var(--text-muted); position: sticky; top: 0; }
.pl-matrix th:first-child, .pl-matrix td:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 130px; font-family: inherit; }
.pl-matrix tr.pl-section-row td:first-child { background: #f8f9fa; }
.pl-matrix th.dow-sun { color: var(--danger); }
.pl-matrix th.dow-sat { color: var(--primary); }
.pl-matrix th.total-col, .pl-matrix td.total-col { background: #e8f7fa; border-left: 2px solid #17a2b8; font-weight: bold; }
.pl-matrix th.mtd-col, .pl-matrix td.mtd-col { background: #fff3cd; border-left: 2px solid #ffc107; font-weight: bold; }
.pl-matrix tr.pl-row-sub td { color: var(--text-muted); padding-left: 24px; font-size: 11px; }
.pl-matrix tr.pl-row-bold td { background: #fafbfc; font-weight: bold; }
.pl-matrix tr.pl-row-bold td:first-child { background: #fafbfc; }
.pl-matrix tr.pl-row-final td { background: #e6f7e9; font-weight: bold; border-top: 2px double var(--success); }
.pl-matrix tr.pl-row-final td:first-child { background: #e6f7e9; color: var(--success); }
.pl-matrix tr.pl-row-final.loss td { background: #fde8ea; }
.pl-matrix tr.pl-row-final.loss td:first-child { background: #fde8ea; color: var(--danger); }
.pl-matrix .amt.minus { color: var(--danger); }
.pl-matrix .amt.zero { color: #ccc; }

.pl-table-grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); margin-bottom: 14px; }
.pl-table-grid td { padding: 8px 14px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.pl-table-grid td.amt { text-align: right; font-weight: bold; font-family: 'Helvetica Neue', monospace; }
.pl-table-grid td.amt.minus { color: var(--danger); }
.pl-table-grid td.amt.plus  { color: var(--success); }
.pl-table-grid td.amt.total { font-size: 16px; }
.pl-table-grid tr.pl-line td { background: #fafbfc; }
.pl-table-grid tr.pl-sub td { padding-left: 30px; color: var(--text-muted); font-size: 12px; }
.pl-table-grid tr.pl-bordered td { border-top: 2px solid #17a2b8; background: #e8f7fa; font-weight: bold; }
.pl-table-grid tr.pl-final td { border-top: 3px double var(--success); background: #e6f7e9; font-weight: bold; padding: 12px 14px; }
.pl-table-grid tr.pl-final td.amt.total { font-size: 18px; color: var(--success); }
.pl-table-grid tr.pl-final.loss td.amt.total { color: var(--danger); }

.pl-cost-section { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.pl-cost-section summary { font-weight: bold; cursor: pointer; user-select: none; padding: 4px 0; }
.pl-cost-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f0f0; align-items: center; font-size: 13px; }
.pl-cost-row .cost-name { font-weight: bold; }
.pl-cost-row .cost-date { color: var(--text-muted); font-size: 11px; }
.pl-cost-row .cost-amount { font-weight: bold; color: var(--danger); }
.pl-cost-row .delete-btn { padding: 4px 8px; font-size: 11px; }
.pl-add-form { display: grid; grid-template-columns: 1.5fr 1fr 1fr auto; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.pl-add-form.pl-fixed-add { grid-template-columns: 1.5fr 1fr 1fr 1fr auto; }
.pl-add-form input { padding: 8px; font-size: 13px; }
@media (max-width: 600px) {
    .pl-add-form, .pl-add-form.pl-fixed-add { grid-template-columns: 1fr; }
}
.pl-fixed-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; align-items: center; font-size: 13px; }
.pl-fixed-row .name { font-weight: bold; }
.pl-fixed-row .amount { font-weight: bold; color: var(--danger); text-align: right; }
.pl-fixed-row .period { color: var(--text-muted); font-size: 11px; }
.pl-fixed-row .actions { display: flex; gap: 4px; }
.pl-fixed-row .actions button { padding: 4px 8px; font-size: 11px; }
@media (max-width: 600px) {
    .pl-fixed-row { grid-template-columns: 1fr; gap: 4px; padding: 10px 0; }
}

/* 人件費(管理者のみ) */
.labor-section { background: linear-gradient(180deg, #fff9e6, #fff); border: 2px solid var(--warning); border-radius: 12px; padding: 18px; margin-bottom: 22px; }
.labor-section > h3 { margin: 0 0 12px 0; color: #b8860b; }
.labor-row { display: grid; grid-template-columns: 100px 1fr auto; gap: 10px; padding: 12px; border-bottom: 1px solid #ffe082; align-items: start; font-size: 13px; }
.labor-row .breakdown-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.labor-row .breakdown-detail .item { display: flex; justify-content: space-between; }
.labor-row .breakdown-detail .item.minus { color: var(--danger); }
.labor-row .breakdown-detail .item.final { font-weight: bold; color: var(--text); border-top: 1px solid #ffe082; padding-top: 4px; margin-top: 2px; }
.labor-row .name { font-weight: bold; font-size: 15px; }
.labor-row .breakdown { color: var(--text-muted); }
.labor-row .pay { font-weight: bold; font-size: 16px; color: var(--primary); }
.labor-row.owner { background: rgba(255,193,7,0.12); border-radius: 8px; margin-top: 6px; border-bottom: none; }
.labor-row.owner .pay { color: var(--success); font-size: 18px; }

/* スタッフ別実績カード */
.staff-summary { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.staff-card { flex: 1; min-width: 130px; background: var(--card); padding: 12px 15px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-left: 4px solid #17a2b8; }
.staff-card h4 { margin: 0 0 10px 0; font-size: 15px; color: var(--text); border-bottom: 1px solid #eee; padding-bottom: 6px; }
.staff-card .stat-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; color: var(--text-muted); }
.staff-card .stat-val { font-weight: bold; color: var(--text); font-size: 14px; }
.staff-card .stat-val.cash { color: #d35400; }
.staff-card .stat-val.net { color: var(--primary); }

/* 売上一覧テーブル */
.table-section { background: var(--card); padding: 15px; border-radius: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); overflow-x: auto; }
.filter-buttons { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.filter-buttons::-webkit-scrollbar { height: 4px; }
.filter-buttons::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.filter-btn { flex-shrink: 0; padding: 6px 14px; border: 2px solid var(--primary); background: #fff; color: var(--primary); border-radius: 20px; font-size: 12px; font-weight: bold; cursor: pointer; }
.filter-btn.active { background: var(--primary); color: #fff; }

.sales-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.sales-table th, .sales-table td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: left; }
.sales-table th { background-color: #f8f9fa; font-weight: bold; color: var(--text-muted); }
.sales-table th.sortable { cursor: pointer; position: relative; padding-right: 18px; user-select: none; }
.sales-table th.sortable:hover { background-color: #e9ecef; }
.sales-table th.sortable::after { content: '↕'; position: absolute; right: 4px; font-size: 11px; color: #ccc; }
.sales-table th.sortable.asc::after { content: '↑'; color: var(--primary); }
.sales-table th.sortable.desc::after { content: '↓'; color: var(--primary); }

.badge-sale { background-color: var(--primary); color: #fff; padding: 4px 8px; border-radius: 12px; font-size: 10px; font-weight: bold; display: inline-block; margin-bottom: 2px; }
.badge-exp-comp { background-color: var(--danger); color: #fff; padding: 4px 8px; border-radius: 12px; font-size: 10px; font-weight: bold; display: inline-block; margin-bottom: 2px; }
.badge-exp-pers { background-color: #fd7e14; color: #fff; padding: 4px 8px; border-radius: 12px; font-size: 10px; font-weight: bold; display: inline-block; margin-bottom: 2px; }
.badge-mirror { background-color: #6f42c1; color: #fff; padding: 3px 6px; border-radius: 10px; font-size: 9px; font-weight: bold; display: inline-block; }

.edit-btn { background-color: var(--success); color: white; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: bold; margin-right: 4px; margin-bottom: 2px; }
.delete-btn { background-color: var(--danger); color: white; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: bold; margin-bottom: 2px; }
.action-btns { display: flex; flex-wrap: wrap; gap: 2px; }

/* 未読バッジ（追加・変更通知） */
.unread-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    margin-right: 4px;
    vertical-align: middle;
    animation: unread-pulse 1.6s ease-in-out infinite;
}
.unread-badge.new { background: #dc3545; }
.unread-badge.updated { background: #fd7e14; }
@keyframes unread-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220,53,69,0.55); }
    50%      { transform: scale(1.08); box-shadow: 0 0 0 5px rgba(220,53,69,0); }
}
.unread-row { background: #fff7e6 !important; }
.unread-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #dc3545;
    margin-right: 4px;
    animation: unread-pulse 1.6s ease-in-out infinite;
}
.unread-dot.updated { background: #fd7e14; }

/* 通知モーダル内の行 */
#modal-notif-list .notif-row {
    display: block;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
}
#modal-notif-list .notif-row:hover { background: #f8f9fa; }
#modal-notif-list .notif-row .notif-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
