/* ===== Mobile: Card Layout ===== */
@media (max-width: 768px) {
    .hamburger { display: block; position: absolute; right: 16px; top: 14px; }

    .header {
        position: relative;
        padding: 14px 16px;
    }
    .header h1 { font-size: 15px; }
    .header-left { padding-right: 50px; }

    .header-actions {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: var(--primary-dark);
        padding: 12px 16px;
        gap: 8px;
        z-index: 150;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    }
    .header-actions.open { display: flex; }
    .header-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    .stats-bar { padding: 12px 16px; gap: 10px; grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 12px 14px; }
    .stat-card .value { font-size: 24px; }
    .stat-card .label { font-size: 10px; }

    .filters {
        padding: 0 16px 10px;
        flex-direction: column;
        gap: 8px;
    }
    .filters select, .filters input { width: 100%; font-size: 14px; padding: 10px; }

    /* Table → Card transformation */
    .session-table { border-collapse: separate; border-spacing: 0 8px; width: 100%; }
    .session-table thead { display: none; }
    .session-table tbody tr {
        display: block;
        background: var(--card-bg);
        border-radius: 10px;
        padding: 12px 16px;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border);
        position: relative;
    }
    .session-table td {
        display: inline-block;
        padding: 0;
        border: none;
        font-size: 13px;
    }
    .session-table td::before {
        content: attr(data-label) ": ";
        font-size: 11px;
        color: var(--text-light);
        font-weight: 600;
    }
    /* 患者名: 1行目に大きく表示 */
    .session-table td[data-label="患者名"] {
        display: block;
        font-size: 15px;
        font-weight: 700;
        padding-bottom: 6px;
        margin-bottom: 6px;
        border-bottom: 1px solid var(--border);
    }
    .session-table td[data-label="患者名"]::before { display: none; }
    /* 成約バッジ: 右上に配置 */
    .session-table td[data-label="成約"] {
        position: absolute;
        top: 12px;
        right: 16px;
    }
    .session-table td[data-label="成約"]::before { display: none; }
    /* 予約/医院/DH/DRを横並び */
    .session-table td[data-label="予約"],
    .session-table td[data-label="医院"],
    .session-table td[data-label="DH"],
    .session-table td[data-label="DR"] {
        margin-right: 12px;
    }
    /* 録音時間は非表示 */
    .session-table td[data-label="録音"] { display: none; }
    /* スコア: 患者名の右、成約の下 */
    .session-table td[data-label="スコア"] {
        position: absolute;
        top: 38px;
        right: 16px;
        font-size: 14px;
        font-weight: 700;
    }
    .session-table td[data-label="スコア"]::before { display: none; }
    /* 操作列はモバイルで非表示（ボタンは患者名セル内に移動済み） */
    .session-table td[data-label=""] { display: none; }
    .session-table .mobile-actions { display: inline; margin-left: 8px; }
    .session-table .desktop-actions { display: none; }
    .session-table .mobile-actions .btn-sm { padding: 4px 10px; font-size: 11px; }
    /* クリック可能な行全体にタップフィードバック */
    .session-table tbody tr.clickable-row:active {
        background: #e0efff !important;
    }

    .pagination { padding: 10px 16px; }
    .content { padding: 0 10px 10px; }

    .modal { padding: 12px; border-radius: 0; min-height: 100vh; }
    .modal-overlay { padding: 0; }
    .detail-meta { grid-template-columns: 1fr; }
    .meta-item { padding: 8px 0; }

    .tab-nav { padding: 0 16px; }
    .tab-btn { padding: 12px 16px; font-size: 13px; }
}

/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border);
    padding: 0 24px;
    gap: 0;
}

.tab-btn {
    padding: 14px 28px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(15,76,117,0.03);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { min-height: 400px; }

/* ===== Dashboard ===== */
.dash-container {
    padding: 20px 24px 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.dash-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.dash-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: 0.2px;
}

.dash-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-left: 16px;
}

.dash-clinic-select {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    background: white;
    cursor: pointer;
}

.dash-clinic-select:focus {
    border-color: var(--primary-light);
    outline: none;
}

/* KPI Grid */
.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.dash-kpi {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    text-align: center;
    transition: box-shadow 0.2s, transform 0.15s;
}

.dash-kpi:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.dash-kpi-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    font-weight: 600;
}

.dash-kpi-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}

.dash-kpi-unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    margin-left: 2px;
}

.dash-kpi-sub {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
    font-weight: 500;
}

.kpi-primary .dash-kpi-value { color: var(--primary); }
.kpi-success .dash-kpi-value { color: var(--success); }
.kpi-danger .dash-kpi-value { color: var(--danger); }
.kpi-warning .dash-kpi-value { color: var(--warning); }
.kpi-info .dash-kpi-value { color: var(--info); }
.kpi-danger { border-left: 4px solid var(--danger); }
.kpi-success { border-left: 4px solid var(--success); }

/* Dash sections */
.dash-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.dash-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.2px;
}

/* Financial Grid */
.dash-fin-grid {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.dash-fin-card {
    flex: 1;
    min-width: 140px;
    text-align: center;
    padding: 16px 12px;
    border-radius: 10px;
    background: var(--bg);
}

.dash-fin-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.dash-fin-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
}

.dash-fin-value.success { color: var(--success); }
.dash-fin-value.danger { color: var(--danger); }

.dash-fin-detail {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

.dash-fin-op {
    font-size: 22px;
    font-weight: 300;
    color: var(--text-light);
    flex-shrink: 0;
}

/* Profit row */
.dash-profit-row {
    display: flex;
    gap: 14px;
    margin-top: 18px;
    justify-content: center;
}

.dash-profit-card {
    padding: 16px 24px;
    border-radius: 10px;
    background: var(--bg);
    text-align: center;
    min-width: 160px;
}

.dash-profit-card.highlight {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

.dash-profit-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.dash-profit-card.highlight .dash-profit-label {
    color: rgba(255,255,255,0.8);
}

.dash-profit-value {
    font-size: 24px;
    font-weight: 800;
}

.dash-profit-value.pos { color: var(--success); }
.dash-profit-value.neg { color: var(--danger); }
.dash-profit-value.warn { color: var(--warning); }
.dash-profit-card.highlight .dash-profit-value { color: white; }

/* Opportunity Cost */
.dash-opportunity {
    background: linear-gradient(135deg, #fef2f2, #fff7ed);
    border-color: #fecaca;
}

.dash-opp-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dash-opp-item {
    text-align: center;
    padding: 14px 20px;
    border-radius: 10px;
    background: rgba(255,255,255,0.8);
    min-width: 120px;
}

.dash-opp-item.highlight {
    background: var(--danger);
    color: white;
}

.dash-opp-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 4px;
}

.dash-opp-item.highlight .dash-opp-label { color: rgba(255,255,255,0.85); }

.dash-opp-val {
    font-size: 20px;
    font-weight: 800;
    color: var(--danger);
}

.dash-opp-val.big { font-size: 26px; }
.dash-opp-item.highlight .dash-opp-val { color: white; }

.dash-opp-note {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

.dash-opp-arrow {
    font-size: 20px;
    color: var(--text-light);
    font-weight: 300;
}

/* Rankings */
.dash-rankings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.dash-rank-panel { margin-bottom: 0; }

.dash-rank-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dash-rank-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}

.dash-rank-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.dash-rank-table tbody tr:hover {
    background: var(--bg);
}

.medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    background: var(--bg);
    color: var(--text-light);
}

.medal.gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.medal.silver { background: linear-gradient(135deg, #9ca3af, #6b7280); color: white; }
.medal.bronze { background: linear-gradient(135deg, #d97706, #b45309); color: white; }

/* Mini bars */
.dash-mini-bar {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
}

.dash-mini-bar.wide { width: 80px; }

.dash-mini-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Trends table */
.dash-trends-table-wrap { overflow-x: auto; }

.dash-trends-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dash-trends-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}

.dash-trends-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.dash-trends-table tbody tr:hover { background: var(--bg); }

/* Clinic breakdown cards */
.dash-clinic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.dash-clinic-card {
    border-radius: 10px;
    background: var(--bg);
    padding: 18px;
    border: 1px solid var(--border);
}

.dash-clinic-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.dash-clinic-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dash-clinic-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.dash-clinic-stat .lbl {
    font-size: 12px;
    color: var(--text-light);
}

.dash-clinic-stat .val {
    font-size: 15px;
    font-weight: 700;
}

/* Sortable columns */
.session-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.session-table th.sortable:hover {
    background: rgba(15,76,117,0.06);
}

.sort-arrow {
    font-size: 10px;
    opacity: 0.3;
    margin-left: 2px;
}

.sort-arrow.active {
    opacity: 1;
    color: var(--primary);
}

/* Reference score (audio quality issue) */
.score-ref { color: var(--text-light) !important; opacity: 0.6; }
.ref-badge {
    display: inline-block;
    font-size: 9px;
    background: var(--text-light);
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 4px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.source-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.source-badge.reengage {
    background: #E0E7FF;
    color: #3730A3;
}

/* Today's appointments */
.today-appts-container {
    margin: 14px 24px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
}

.today-appts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.today-appts-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
}

.today-appts-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--info);
}

.today-clinic {
    margin-bottom: 12px;
}

.today-clinic-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.today-clinic-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    margin-left: 8px;
}

.today-appt-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-size: 13px;
}

.today-time {
    min-width: 45px;
    font-weight: 600;
    color: var(--text-light);
}

.today-name {
    flex: 1;
    font-weight: 500;
    color: var(--text);
}

.rec-ok {
    display: inline-block;
    background: var(--success-light);
    color: #065F46;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.rec-no {
    display: inline-block;
    background: var(--danger-light);
    color: var(--danger);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.needs-check {
    display: inline-block;
    background: #FEF3C7;
    color: #92400E;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.overall-score-display.audio-ref {
    background: var(--bg);
    border: 2px dashed var(--border);
    opacity: 0.7;
}

/* Dashboard filters row */
.dash-filters { display: flex; gap: 10px; }

/* Dr Commission Cards */
.dash-dr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.dash-dr-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    text-align: center;
}

.dash-dr-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.dash-dr-rate {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.dash-dr-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.dash-dr-stats { margin-bottom: 10px; }

.dash-rate-bar {
    position: relative;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: visible;
    margin-bottom: 8px;
}

.dash-rate-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.dash-rate-target {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 16px;
    background: var(--danger);
    opacity: 0.5;
}

.dash-dr-comm {
    font-size: 12px;
    color: var(--text-light);
}

.dash-dr-comm strong {
    color: var(--primary);
    font-size: 14px;
}

.dash-target-legend {
    text-align: center;
    font-size: 11px;
    color: var(--danger);
    opacity: 0.6;
    margin-top: 12px;
}

/* Clinic contract rate visual bars */
.dash-clinic-rate-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.dash-clinic-rate-label {
    min-width: 100px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.dash-clinic-rate-bar-wrap {
    flex: 1;
    position: relative;
}

.dash-clinic-rate-bg {
    height: 14px;
    background: var(--bg);
    border-radius: 7px;
    overflow: hidden;
}

.dash-clinic-rate-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.5s ease;
}

.dash-clinic-rate-target {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 18px;
    background: var(--danger);
    opacity: 0.4;
}

.dash-clinic-rate-val {
    min-width: 60px;
    text-align: right;
    font-size: 20px;
    font-weight: 800;
}


/* ============================================================
   商業品質UI: 絵文字を排除し、CSSスタイリングで視覚区別
   ============================================================ */
.staff-analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}
.staff-analytics-header h2 { margin: 0; }

.axis-good-count {
    color: var(--success);
    font-weight: 700;
}
.axis-improve-count {
    color: var(--danger);
    font-weight: 700;
    margin-left: 4px;
}

/* 言い換え提案: ラベル付きスタイル */
.ai-phrase-label {
    display: inline-block;
    padding: 1px 8px;
    margin-right: 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: 0.05em;
}
.ai-phrase-bad .ai-phrase-label {
    background: #fee2e2;
    color: #991b1b;
}
.ai-phrase-better .ai-phrase-label {
    background: #d1fae5;
    color: #065f46;
}

/* AIレビューempty: 絵文字なし、シンプルテキスト */
.ai-review-empty {
    padding: 24px;
    text-align: center;
}
