/* ============================================================
   ELSYS 営業管理 — 共通スタイル（Nocturne 調・ライトメイン v2）
   design_handoff_ui_v2 / README.md に準拠
   トークン名は極力維持し、値のみ差し替え（互換確保）
   ============================================================ */

:root {
    /* ── サイドバー（ダーク・グラデーション） ── */
    --sb-bg-top:    #252842;
    --sb-bg-mid:    #1b1d2e;
    --sb-bg-bottom: #161826;
    --sb-border:    #3f424d;
    --sb-text:      #e9e9ed;
    --sb-muted:     #b2b6ca;
    --sb-label:     #75798c;
    --sb-hover:     #2b2e42;
    --sb-active:    #2f3249;

    /* ── メイン（ライト・ニュートラル階調） ── */
    --bg:          #e4e7f5;    /* ページ地。main に軽いグラデーションを重ねる */
    --surface:     #f3f5fe;    /* カード */
    --surface-2:   #f8f9fe;    /* 入力・ボタン・リスト行 */
    --fill:        #e9ebf5;    /* 情報ブロック・合計行 */
    --border:      #cfd3e5;
    --border-soft: #d8dbe9;
    --text:        #292b31;
    --text-2:      #595d6c;
    --muted:       #75798c;
    --faint:       #9397ab;

    /* ── アクセント（Nocturne blurple） ── */
    --accent:        #9184d9;   /* バー / マーク / スコア塗り */
    --accent-text:   #796cbf;   /* リンク・ボタン枠・アイコン */
    --accent-strong: #5d5294;   /* 強調文字・アクティブタブ塗り */
    --accent-deep:   #423a6a;
    --accent-100:    #f5f4ff;
    --accent-200:    #e7e5fe;
    --accent-300:    #d2cefd;
    --accent-400:    #b5abfc;

    /* ── 形状 ── */
    --radius:    8px;
    --radius-lg: 14px;

    /* ── 影 ── */
    --shadow-sm: 0 0 0 1px #d8dbe9;
    --shadow-md: 0 0 0 1px #cfd3e5, 0 8px 22px rgba(41,43,49,.10);
    --lift:      0 5px 14px rgba(41,43,49,.16);

    /* ── 状態色（ステータス badge / alert 継続用） ── */
    --ok:    #27500A;  --ok-bg:   #EAF3DE;
    --warn:  #633806;  --warn-bg: #FEF3CD;
    --ng:    #791F1F;  --ng-bg:   #FCEBEB;
    --gray-t:#5F5E5A;  --gray-bg: #F1EFE8;

    /* ── レガシー別名（既存クラスからの参照を維持） ── */
    --navy:       var(--accent-deep);
    --blue:       var(--accent);
    --blue-lt:    var(--accent-200);
    --sidebar:    var(--sb-bg-mid);
    --primary:    var(--accent-text);
    --primary-hv: var(--accent-strong);

    /* ── 数値・電話番号などに使うヘッディング系フォント ── */
    --font-heading: "Inter", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { color: var(--accent-text); text-decoration: underline; }

/* ------------------------------------------------------------
   アプリ全体レイアウト
   ------------------------------------------------------------ */
.app {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, #eef0f9 0%, var(--bg) 100%);
}

/* ------------------------------------------------------------
   サイドバー（ダーク・グラデーション）
   ------------------------------------------------------------ */
.sidebar {
    width: 270px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sb-bg-top) 0%, var(--sb-bg-mid) 45%, var(--sb-bg-bottom) 100%);
    border-right: 1px solid var(--sb-border);
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
}

/* ── ブランド（ロゴ行） ── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.sidebar-brand:hover { text-decoration: none; color: inherit; }
.sidebar-brand-mark {
    width: 32px; height: 32px; flex: none;
    border-radius: 8px;
    border: 1px solid var(--accent-text);
    display: grid; place-items: center;
    color: var(--accent-text);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: .04em;
    background: transparent;
    overflow: hidden;
}
.sidebar-brand-mark img {
    display: block;
    width: 100%; height: 100%;
    object-fit: contain;
    filter: brightness(1.7) contrast(1.05);
}
.sidebar-brand-text {
    display: flex; flex-direction: column; line-height: 1.15;
}
.sidebar-brand-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 15px;
    letter-spacing: .02em;
    color: var(--sb-text);
}
.sidebar-logo-sub {
    font-size: 11px;
    color: var(--faint);
}

/* ── ナビゲーション ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* セクション（グループ） */
.nav-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 6px;
}
.nav-section-label {
    font-size: 11px;
    letter-spacing: .08em;
    color: var(--sb-label);
    padding: 12px 12px 6px;
    text-transform: none;
}

/* ナビ項目 */
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 10px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 16px;
    line-height: 1.2;
    color: var(--sb-muted);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease;
}
.nav-link:hover {
    background: var(--sb-hover);
    color: var(--sb-text);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    text-decoration: none;
}
.nav-link.is-active {
    background: var(--sb-active);
    color: var(--sb-text);
}
.nav-mark {
    width: 3px; height: 16px;
    border-radius: 2px;
    flex: none;
    background: transparent;
}
.nav-link.is-active .nav-mark {
    background: var(--accent);
}
.nav-link i.ph {
    font-size: 20px;
    flex: none;
    opacity: .9;
}
.nav-link .nav-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-admin-tag {
    font-size: 10px;
    letter-spacing: .06em;
    color: var(--sb-label);
    border: 1px solid var(--sb-border);
    border-radius: 4px;
    padding: 0 5px;
    line-height: 16px;
}

/* ── ユーザー行（サイドバー下部） ── */
.sidebar-user {
    padding: 12px 14px;
    border-top: 1px solid var(--sb-border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent-deep);
    color: var(--accent-100);
    display: grid; place-items: center;
    font-size: 12px;
    font-weight: 600;
    flex: none;
}
.sidebar-user-meta {
    flex: 1; min-width: 0; line-height: 1.2;
}
.sidebar-user-name {
    font-size: 13px;
    color: var(--sb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: var(--faint);
}
.sidebar-user-logout {
    color: var(--faint);
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    text-decoration: none;
    transition: background .12s ease, color .12s ease;
}
.sidebar-user-logout:hover {
    background: var(--sb-hover);
    color: var(--sb-text);
    text-decoration: none;
}
.sidebar-user-logout i.ph { font-size: 18px; }

/* ------------------------------------------------------------
   ページ本文
   ------------------------------------------------------------ */
.content {
    padding: 24px 28px 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

/* ── ページヘッダー（旧トップバー廃止・ページ冒頭に配置） ── */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 24px;
    font-weight: 500;
    margin: 0;
    line-height: 1.2;
    letter-spacing: .01em;
}
.page-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--muted);
}
.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── フッター ── */
.footer {
    padding: 16px 28px;
    color: var(--muted);
    background: transparent;
    font-size: 12px;
}

/* ------------------------------------------------------------
   ボタン（新: .btn / .btn-primary / .btn-secondary / .btn-ghost）
   既存: .btn-outline / .btn-danger も継続サポート
   ------------------------------------------------------------ */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-outline,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font: 500 14px/1.2 "Inter", inherit;
    background: var(--surface-2);
    border: 1px solid transparent;
    color: var(--text);
    box-shadow: 0 1px 2px rgba(41,43,49,.08);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-outline:hover,
.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: var(--lift);
    text-decoration: none;
}
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-outline:active,
.btn-danger:active {
    transform: none;
    box-shadow: 0 1px 2px rgba(41,43,49,.10);
}
.btn i.ph,
.btn-primary i.ph, .btn-secondary i.ph, .btn-ghost i.ph,
.btn-outline i.ph, .btn-danger i.ph {
    font-size: 16px;
}
/* primary — 塗りなし・アクセント枠 */
.btn-primary {
    color: var(--accent-text);
    border-color: var(--accent-text);
    background: var(--surface-2);
}
.btn-primary:hover { background: #efedfd; color: var(--accent-text); }
/* filled: 主要行動を強調したい時（例: ＋追加 ▾）。塗りつぶし + 太字 + 大きめ */
.btn-primary.is-filled,
.btn-filled {
    background: var(--accent-text);
    color: #fff;
    border-color: var(--accent-text);
    font-weight: 700;
    min-height: 40px;
    padding: 8px 16px;
    box-shadow: 0 2px 6px rgba(121,108,191,.30);
}
.btn-primary.is-filled:hover,
.btn-filled:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
    box-shadow: 0 6px 16px rgba(121,108,191,.40);
}
.btn-primary.is-filled:active,
.btn-filled:active {
    background: var(--accent-deep);
    box-shadow: 0 1px 3px rgba(121,108,191,.30);
}
/* secondary — 通常枠 */
.btn-secondary,
.btn-outline {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface-2);
}
.btn-secondary:hover,
.btn-outline:hover { background: var(--fill); color: var(--text); }
/* ghost — 影・背景なし */
.btn-ghost {
    background: transparent;
    box-shadow: none;
    color: var(--accent-text);
}
.btn-ghost:hover {
    background: var(--accent-200);
    transform: none;
    box-shadow: none;
    color: var(--accent-strong);
}
/* danger — 削除等の破壊操作 */
.btn-danger {
    color: var(--ng);
    border-color: #E3B7B7;
    background: var(--surface-2);
}
.btn-danger:hover { background: var(--ng-bg); color: var(--ng); }
/* アイコン単独ボタン */
.btn-icon { width: 32px; height: 32px; padding: 0; min-height: 32px; }
.btn:disabled,
.btn-primary:disabled, .btn-secondary:disabled, .btn-ghost:disabled,
.btn-outline:disabled, .btn-danger:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 2px rgba(41,43,49,.08);
}

/* ------------------------------------------------------------
   タグ（旧 .badge）
   ------------------------------------------------------------ */
.tag, .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    letter-spacing: .02em;
    padding: 3px 10px;
    border-radius: 6px;
    white-space: nowrap;
    flex: none;
    background: var(--fill);
    color: var(--text-2);
    border: 1px solid transparent;
}
.tag-accent    { background: var(--accent-200); color: var(--accent-strong); }
.tag-accent-2  { background: var(--accent-300); color: var(--accent-deep); }
.tag-neutral   { background: var(--bg);         color: #3f424d; }
.tag-outline   { background: transparent; border-color: var(--accent-text); color: var(--accent-strong); }

/* 管理者バッジ（トップバーからサイドバー用途に転用） */
.badge-admin {
    background: var(--accent-deep);
    color: var(--accent-100);
    font-size: 10px;
}

/* ── ステータス badge → 新カラー ── */
.status-未架電   { background: var(--bg);          color: #3f424d; }
.status-再コール { background: var(--accent-200);  color: var(--accent-strong); }
.status-アポ獲得 { background: transparent;        color: var(--accent-strong); border: 1px solid var(--accent-text); }
.status-契約     { background: var(--accent-300);  color: var(--accent-deep); }
.status-断り     { background: var(--bg);          color: #3f424d; }
.status-不要     { background: var(--bg);          color: #3f424d; }

/* スコアバー */
.score-bar { background: var(--border-soft); border-radius: 4px; height: 6px; width: 64px; display: inline-block; vertical-align: middle; overflow: hidden; }
.score-bar > span { display: block; height: 100%; background: var(--accent); }

/* 見込ランクバッジ */
.lead-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.2;
    letter-spacing: 0.5px;
}
.lead-rank-A { background: #FEE2E2; color: #991B1B; border: 1px solid #DC2626; }
.lead-rank-B { background: #FEF3C7; color: #92400E; border: 1px solid #D97706; }
.lead-rank-C { background: var(--accent-200); color: var(--accent-strong); border: 1px solid var(--accent-text); }
.lead-rank-D { background: var(--fill); color: var(--text-2); border: 1px solid var(--border); }

/* ------------------------------------------------------------
   カード
   ------------------------------------------------------------ */
.card {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    margin-bottom: 0;   /* .content の gap で調整 */
    display: block;
}
.card + .card { margin-top: 0; }
.card-title {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 12px;
    color: var(--text);
    line-height: 1.3;
}
.card-title .btn,
.card-title .btn-primary,
.card-title .btn-outline,
.card-title .btn-secondary,
.card-title .btn-ghost {
    font-size: 12px;
    min-height: 30px;
    padding: 4px 10px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.stat {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value {
    font-family: var(--font-heading);
    font-size: 30px;
    line-height: 1;
    font-weight: 500;
    color: var(--text);
}
.stat-sub  { font-size: 11px; color: var(--text-2); }

/* ------------------------------------------------------------
   テーブル
   ------------------------------------------------------------ */
.table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    font-size: 13px;
}
.table thead th {
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 8px 10px;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.sort-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    letter-spacing: inherit;
    text-transform: inherit;
}
.sort-link:hover { color: var(--accent-text); text-decoration: none; }
.table tbody td {
    padding: 9px 10px;
    border-top: 1px solid var(--border-soft);
    vertical-align: middle;
}
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-family: var(--font-heading); }
.table .total-row td { background: var(--fill); font-weight: 500; }
/* 一覧テーブルの主名称列（企業名・顧客名など）を強調 */
.table .col-name { font-size: 15px; font-weight: 500; white-space: nowrap; }
.table .col-name a { color: var(--text); }
.table .col-name a:hover { color: var(--accent-strong); text-decoration: none; }

/* クリック可能行（行→詳細ページへ遷移） */
tr.row-link { cursor: pointer; position: relative; transition: box-shadow .12s ease, transform .12s ease; }
tr.row-link:hover {
    background: var(--surface-2);
    box-shadow: 0 4px 12px rgba(41,43,49,.12);
    transform: translateY(-1px);
}
tr.row-link:hover td { background: transparent; }

/* ------------------------------------------------------------
   フォーム / 入力
   ------------------------------------------------------------ */
.form-row { margin-bottom: 14px; }
.form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 4px;
}
.form-control, .input {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:hover, .input:hover { border-color: var(--faint); }
.form-control:focus, .input:focus {
    outline: 2px solid var(--accent-text);
    outline-offset: 0;
    border-color: var(--accent-text);
}
textarea.form-control, textarea.input { resize: vertical; min-height: 76px; padding: 8px 10px; }

/* 絞り込みバー（フレックスのまま許容。グリッドは各ページで導入） */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 0;
}
.filter-bar .form-row { margin-bottom: 0; }
/* グリッド版の絞り込みフォーム（v2 一覧ページ用） */
.filter-grid { display: grid; gap: 10px; align-items: end; }
@media (max-width: 1180px) {
    .filter-grid { grid-template-columns: minmax(200px, 1.4fr) repeat(2, minmax(0, 1fr)) auto !important; }
}
@media (max-width: 820px) {
    .filter-grid { grid-template-columns: 1fr !important; }
}

/* セグメント切替 */
.seg {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    overflow: hidden;
}
.seg-opt {
    padding: 7px 12px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-2);
    line-height: 1;
    transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.seg-opt:hover { background: var(--accent-200); color: var(--accent-strong); text-decoration: none; }
.seg-opt.is-active {
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent-text);
}

/* ------------------------------------------------------------
   アラート
   ------------------------------------------------------------ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-error   { background: var(--ng-bg);       color: var(--ng);            border-color: #E3B7B7; }
.alert-success { background: var(--ok-bg);       color: var(--ok);            border-color: #C3D9A0; }
.alert-info    { background: var(--accent-200);  color: var(--accent-strong); border-color: var(--accent-300); }

/* ------------------------------------------------------------
   ページネーション
   ------------------------------------------------------------ */
.pagination { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-2);
    background: var(--surface-2);
    text-decoration: none;
}
.pagination a:hover { background: var(--accent-200); color: var(--accent-strong); }
.pagination .is-current { background: var(--accent-text); color: #fff; border-color: var(--accent-text); }

/* ------------------------------------------------------------
   月間カレンダー（施工予定・既存機能を維持）
   ------------------------------------------------------------ */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.calendar-head {
    background: var(--fill);
    padding: 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-2);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.calendar-head.sun { color: var(--ng); }
.calendar-head.sat { color: var(--accent-text); }

.calendar-cell {
    min-height: 92px;
    padding: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    font-size: 11px;
}
.calendar-cell.is-other-month { background: var(--bg); color: var(--muted); }
.calendar-cell.is-today { background: var(--accent-200); }

.calendar-cell .cell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.calendar-cell .cell-head-left { display: flex; align-items: center; gap: 4px; }
.calendar-cell .date     { font-family: var(--font-heading); font-weight: 500; font-size: 12px; }
.calendar-cell .date.sun { color: var(--ng); }
.calendar-cell .date.sat { color: var(--accent-text); }
.calendar-cell .cell-add {
    display: inline-block;
    width: 16px; height: 16px;
    line-height: 14px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-text);
    text-decoration: none;
    border: 1px solid var(--accent-text);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.calendar-cell:hover .cell-add { opacity: 1; }
.calendar-cell .cell-add:hover { background: var(--accent-text); color: #fff; }
.calendar-cell.is-today .cell-add { opacity: 1; }
.calendar-cell .badge-count {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--accent-text);
    color: #fff;
    font-weight: 600;
}
.calendar-cell ul { list-style: none; margin: 0; padding: 0; }
.calendar-cell li {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    line-height: 1.5;
    padding: 2px 5px;
    margin-bottom: 2px;
    border-radius: 3px;
    border-left: 3px solid transparent;
}
.calendar-cell li a { color: var(--text); text-decoration: none; }
.calendar-cell li a:hover { text-decoration: underline; }

.calendar-cell .cal-time {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-text);
    margin-right: 2px;
}

/* B案: セル展開（アコーディオン） */
.calendar-cell li.cal-extra { display: none; }
.calendar-cell.is-expanded li.cal-extra { display: block; }
.calendar-cell .cal-more-btn {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 6px;
    font-size: 10px;
    line-height: 1.4;
    color: var(--accent-text);
    background: transparent;
    border: 1px dashed var(--accent-text);
    border-radius: 3px;
    cursor: pointer;
    font-weight: 600;
}
.calendar-cell .cal-more-btn:hover { background: var(--accent-200); }
.calendar-cell.is-expanded .cal-more-btn { color: var(--muted); border-color: var(--border); }

/* 施工予定 li のステータス別カラー（既存踏襲） */
.calendar-cell li.is-pending      { background: #F3F4F6; border-left-color: #9CA3AF; }
.calendar-cell li.is-work-done    { background: #E0F2FE; border-left-color: #0EA5E9; }
.calendar-cell li.is-work-stale   { background: #FEF3C7; border-left-color: #D97706; }
.calendar-cell li.is-work-stale a { color: #7C2D12; font-weight: 600; }
.calendar-cell li.is-photo-late   { background: #EDE9FE; border-left-color: #7C3AED; }
.calendar-cell li.is-photo-late a { color: #5B21B6; font-weight: 600; }
.calendar-cell li.is-notice-warn  { background: #FEE2E2; border-left-color: #DC2626; }
.calendar-cell li.is-notice-warn a{ color: #991B1B; font-weight: 700; }
.calendar-cell li.is-report-done  { background: #DBEAFE; border-left-color: #3B82F6; }
.calendar-cell li.is-invoiced     { background: #FFEDD5; border-left-color: #F97316; }
.calendar-cell li.is-paid         { background: #D1F0DA; border-left-color: #15803D; }
.calendar-cell li.is-paid a       { font-weight: 600; }
.calendar-cell li.muted           { background: transparent; border-left-color: transparent; padding-left: 0; }
.calendar-cell li.is-today-item {
    background: #FEF9C3;
    border-left-color: #EAB308;
    border-left-width: 5px;
    box-shadow: inset 0 0 0 1px #EAB308;
    font-weight: 600;
}

.cal-legend {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    border-left: 3px solid transparent;
    font-size: 11px;
    color: var(--text);
}
.cal-legend.is-pending      { background: #F3F4F6; border-left-color: #9CA3AF; }
.cal-legend.is-work-done    { background: #E0F2FE; border-left-color: #0EA5E9; }
.cal-legend.is-work-stale   { background: #FEF3C7; border-left-color: #D97706; }
.cal-legend.is-photo-late   { background: #EDE9FE; border-left-color: #7C3AED; color: #5B21B6; font-weight: 600; }
.cal-legend.is-notice-warn  { background: #FEE2E2; border-left-color: #DC2626; color: #991B1B; font-weight: 700; }
.cal-legend.is-report-done  { background: #DBEAFE; border-left-color: #3B82F6; }
.cal-legend.is-invoiced     { background: #FFEDD5; border-left-color: #F97316; }
.cal-legend.is-paid         { background: #D1F0DA; border-left-color: #15803D; }
.cal-legend.is-today-item {
    background: #FEF9C3;
    border-left-color: #EAB308;
    border-left-width: 5px;
    box-shadow: inset 0 0 0 1px #EAB308;
    font-weight: 600;
}

@media (max-width: 820px) {
    .calendar-cell { min-height: 64px; padding: 4px; font-size: 10px; }
    .calendar-cell .date { font-size: 11px; }
    .calendar-cell li { font-size: 10px; padding: 1px 3px; }
    .calendar-cell .cal-time { font-size: 9px; }
    .calendar-cell .cell-add { opacity: 1; width: 14px; height: 14px; line-height: 12px; font-size: 10px; }
}

/* ------------------------------------------------------------
   施工予定モーダル
   ------------------------------------------------------------ */
.tx-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(23,26,45,.45);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.tx-modal-overlay[hidden] { display: none; }
.tx-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px;
    position: relative;
    box-shadow: var(--shadow-md);
}
.tx-modal-title {
    margin: 0 0 12px;
    padding-right: 32px;
    font-size: 16px;
    line-height: 1.4;
    color: var(--accent-deep);
    font-weight: 500;
}
.tx-modal-close {
    position: absolute;
    top: 10px; right: 12px;
    background: none; border: none;
    font-size: 24px; line-height: 1;
    cursor: pointer;
    color: var(--muted);
    width: 32px; height: 32px;
    padding: 0;
}
.tx-modal-close:hover { color: var(--text); }
.tx-modal-body th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tx-modal-body td { font-size: 13px; }
.tx-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
    .tx-modal { padding: 16px; border-radius: var(--radius); }
    .tx-modal-title { font-size: 14px; }
    .tx-modal-body td { font-size: 12px; }
}

/* ------------------------------------------------------------
   進捗チェック・ピル（施工履歴）
   ------------------------------------------------------------ */
.check-pill {
    display: inline-block;
    font-size: 10px;
    line-height: 1;
    padding: 3px 5px;
    margin-right: 2px;
    border-radius: 3px;
    background: var(--fill);
    color: var(--muted);
}
.check-pill.is-done {
    background: var(--accent-200);
    color: var(--accent-strong);
    font-weight: 600;
}
.check-pill.is-warn {
    background: #FEE2E2;
    color: #B91C1C;
    font-weight: 700;
    border: 1px solid #DC2626;
}
.check-pill.is-clickable {
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    font-size: 11px;
    transition: transform .05s ease, box-shadow .1s ease, opacity .1s ease;
}
.check-pill.is-clickable:hover  { box-shadow: 0 0 0 2px rgba(121,108,191,.20); }
.check-pill.is-clickable:active { transform: scale(0.96); }
.check-pill.is-clickable:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.check-pill.is-clickable.is-busy { opacity: .5; pointer-events: none; }

/* 施工履歴 行内の予定日ステータスバッジ */
.sched-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
}
.sched-badge.sched-pending { background: #F3F4F6; color: #4B5563; border-color: #9CA3AF; }
.sched-badge.sched-today   { background: #FEF9C3; color: #78350F; border-color: #EAB308; }
.sched-badge.sched-done    { background: #E0F2FE; color: #075985; border-color: #0EA5E9; }
.sched-badge.sched-stale   { background: #FEF3C7; color: #7C2D12; border-color: #D97706; }

/* ------------------------------------------------------------
   顧客詳細タブ（.cust-tabs / .cust-tab-pane）— v2: 濃塗り／薄塗り
   ------------------------------------------------------------ */
.cust-tabs {
    display: flex;
    gap: 6px;
    padding: 0 4px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}
.cust-tabs button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    margin-bottom: -2px;
    border: none;
    border-radius: 8px 8px 0 0;
    font: 500 14px inherit;
    cursor: pointer;
    background: var(--accent-200);
    color: var(--text-2);
    border-bottom: 3px solid transparent;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
    white-space: nowrap;
}
.cust-tabs button:hover {
    transform: translateY(-1px);
    box-shadow: var(--lift);
    filter: brightness(.96);
}
.cust-tabs button.is-active {
    background: var(--accent-strong);
    color: var(--accent-100);
    border-bottom-color: var(--accent-strong);
}
.cust-tabs button i.ph { font-size: 16px; }
.cust-tabs .tab-badge {
    display: inline-block;
    min-width: 22px;
    padding: 1px 7px;
    font: 500 11px var(--font-heading);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--accent-strong);
    text-align: center;
}
.cust-tabs button.is-active .tab-badge {
    background: var(--accent-200);
    color: var(--accent-deep);
}
.cust-tab-pane { display: none; }
.cust-tab-pane.is-active { display: block; }

/* 顧客詳細ヘッダー情報カード（5カラム） */
.cust-info-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px 20px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.cust-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.cust-info-item .label {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .06em;
    text-transform: none;
}
.cust-info-item .value {
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cust-info-item .value.num { font-family: var(--font-heading); font-size: 15px; }
.cust-info-item .value a { color: var(--accent-strong); }

/* 詳細画面のヘッダー行（戻るリンク＋会社名＋タグ） */
.cust-detail-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cust-detail-back {
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
}
.cust-detail-back:hover { color: var(--accent-strong); text-decoration: none; }
.cust-detail-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 24px;
    font-weight: 500;
    margin: 0;
    line-height: 1.2;
}
.cust-detail-meta {
    font-size: 13px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.cust-detail-meta a { color: var(--accent-strong); }

/* ドロップダウン（＋追加 ▾） */
.dropdown { position: relative; display: inline-block; }
.dropdown.is-open > .dropdown-menu { display: block; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 40;
    display: none;
}
.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: background .12s ease;
}
.dropdown-menu a:hover { background: var(--accent-200); color: var(--accent-strong); text-decoration: none; }
.dropdown-menu a i.ph { font-size: 18px; color: var(--accent-text); }

/* 担当者アイコン（頭1文字） */
.user-icon {
    display: inline-block;
    width: 22px; height: 22px;
    line-height: 22px;
    border-radius: 50%;
    background: #6E7CB9;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin: 2px 6px 2px 0;
    vertical-align: middle;
}
.user-icon:last-child { margin-right: 0; }

/* ------------------------------------------------------------
   ログイン画面
   ------------------------------------------------------------ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sb-bg-top) 0%, var(--sb-bg-mid) 45%, var(--sb-bg-bottom) 100%);
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 340px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo img { display: block; width: 70%; max-width: 200px; height: auto; margin: 0 auto 8px; }
.login-logo .sub  { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }
.login-card .btn-primary { width: 100%; text-align: center; padding: 9px; font-size: 14px; min-height: 40px; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }

/* ------------------------------------------------------------
   バーチャート（サーバー描画）
   ------------------------------------------------------------ */
.barh { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.barh-label { width: 150px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.barh-track { flex: 1; background: var(--border-soft); border-radius: 3px; height: 6px; overflow: hidden; min-width: 60px; }
.barh-fill  { height: 100%; background: var(--accent); }
.barh-val   { width: 130px; flex-shrink: 0; text-align: right; color: var(--muted); font-family: var(--font-heading); }
/* 縦棒 */
.barv-wrap { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.barv-col  { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.barv      { width: 70%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.barv:hover { background: var(--accent-strong); }
.barv-cap  { font-size: 9px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.barv-amt  { font-size: 9px; color: var(--text); font-family: var(--font-heading); }

/* ------------------------------------------------------------
   オートコンプリート
   ------------------------------------------------------------ */
.suggest-wrap { position: relative; }
.suggest-box {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 6px 16px rgba(41,43,49,0.15);
}
.suggest-box:empty { display: none; }
.suggest-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
    border-top: 1px solid var(--border-soft);
}
.suggest-item:first-child { border-top: none; }
.suggest-item:hover, .suggest-item.is-active { background: var(--accent-200); }
.suggest-item .sub { color: var(--muted); font-size: 11px; margin-left: 4px; }
.suggest-empty { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------
   モバイル用サイドバートグル（PCでは非表示）
   ------------------------------------------------------------ */
.sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--sb-border);
    border-radius: 6px;
    color: var(--sb-text);
    font-size: 20px;
    line-height: 1;
    padding: 4px 10px;
    cursor: pointer;
}
.sidebar-toggle:hover { background: var(--sb-hover); }

/* ------------------------------------------------------------
   フォーカスリング（全体）
   ------------------------------------------------------------ */
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 820px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--sb-border);
    }
    .sidebar-logo {
        justify-content: space-between;
        padding: 10px 16px;
    }
    .sidebar-toggle { display: inline-block; }
    .sidebar-nav { display: none; padding-bottom: 6px; }
    .sidebar.is-open .sidebar-nav { display: flex; }
    .sidebar-user { display: none; }
    .sidebar.is-open .sidebar-user { display: flex; }

    .nav-link { padding: 11px 12px; font-size: 15px; }

    .content { padding: 16px; gap: 14px; }
    .footer { padding: 12px 16px; }
    .card { padding: 14px; }
    .page-head h1 { font-size: 20px; }

    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .form-control, .input { max-width: 100% !important; }
    .card[style*="max-width"] { max-width: 100% !important; }

    .login-page { padding: 16px; }
    .login-card { width: 100%; max-width: 360px; padding: 24px; }
}

@media (max-width: 480px) {
    body { font-size: 13px; }
    .stat-value { font-size: 24px; }
    .card-grid { grid-template-columns: 1fr; }
    .filter-bar { gap: 8px; }
    .filter-bar .form-row,
    .filter-bar .form-control { width: 100%; }
}
