/* Yupiteru+目標管理システム - ベーススタイル */

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

html, body {
    overscroll-behavior-y: none;  /* PWA pull-to-refresh 無効化 */
}

:root {
    /* === カラー - テーマごとに上書き === */
    --primary: #1960aa;
    --primary-dark: #164270;
    --secondary: #1979d3;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --accent-purple: #7c3aed;
    --accent-purple-light: #8b5cf6;
    --accent-amber: #d97706;
    --gradient-avatar: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: rgba(15, 23, 42, 0.08);
    --surface: #ffffff;
    --surface-alt: #f8fafc;

    /* === RGB成分（rgba() で使用） === */
    --primary-rgb: 25, 96, 170;
    --secondary-rgb: 25, 121, 211;
    --success-rgb: 16, 185, 129;
    --warning-rgb: 245, 158, 11;
    --danger-rgb: 239, 68, 68;
    --accent-purple-rgb: 124, 58, 237;
    --accent-purple-light-rgb: 139, 92, 246;
    --accent-amber-rgb: 217, 119, 6;
    --text-secondary-rgb: 100, 116, 139;

    /* === フォントファミリー === */
    --font-body: 'Noto Sans JP', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* === フォントサイズ === */
    --text-xs: 0.6875rem;   /* 11px - セクションラベル */
    --text-sm: 0.75rem;     /* 12px - 補足テキスト */
    --text-base: 0.875rem;  /* 14px - 本文標準 */
    --text-md: 1rem;        /* 16px - 本文やや大 */
    --text-lg: 1.125rem;    /* 18px - 小見出し */
    --text-xl: 1.25rem;     /* 20px - カードタイトル */
    --text-2xl: 1.5rem;     /* 24px - ロゴ */
    --text-3xl: 1.75rem;    /* 28px - 統計値 */
    --text-4xl: 2rem;       /* 32px - ページタイトル */

    /* === フォントウェイト === */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* === スペーシング === */
    --space-1: 0.25rem;     /* 4px */
    --space-2: 0.5rem;      /* 8px */
    --space-3: 0.75rem;     /* 12px */
    --space-4: 1rem;        /* 16px */
    --space-5: 1.25rem;     /* 20px */
    --space-6: 1.5rem;      /* 24px */
    --space-8: 2rem;        /* 32px */

    /* === 角丸 === */
    --radius-sm: 8px;       /* ボタン・ナビ */
    --radius-md: 10px;      /* フラッシュ・サイドバー */
    --radius-lg: 12px;      /* ドロップダウン */
    --radius-xl: 14px;      /* 統計カード */
    --radius-2xl: 16px;     /* メインカード */
    --radius-full: 9999px;  /* バッジ・アバター */

    /* === シャドウ === */
    --shadow-sm: 0 1px 3px var(--shadow);
    --shadow-md: 0 4px 12px var(--shadow);
    --shadow-lg: 0 6px 16px var(--shadow);
    --shadow-xl: 0 12px 24px var(--shadow);

    /* === トランジション === */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* === レイアウト === */
    --header-height: 50px;
    --sidebar-width: 260px;
    --content-max-width: 1400px;

    /* === Z-index === */
    --z-header: 100;
    --z-dropdown: 1000;
    --z-modal: 2000;
    --z-toast: 3000;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

body.has-app-rail {
    padding-left: 40px;
}

/* ===== App Rail（ポータル横断ナビ） ===== */
.app-rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: var(--primary-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    z-index: 1100;
    overflow: visible;
}

.app-rail-item {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    margin: 10px 0;
    transition: background 0.2s, color 0.2s, border-radius 0.2s;
    position: relative;
    flex-shrink: 0;
}

.app-rail-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.app-rail-item.active {
    background: rgba(255, 255, 255, 0.18);
    color: white;
}

.app-rail-item svg {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
}

.app-rail-item:first-child {
    margin-top: 0;
}

.app-rail-item.has-unread {
    color: #f59e0b;
}

.unread-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

/* メールチェッカー等、data-badge-url で汎用ポーリングするレールバッジ（赤・小型・右下寄り） */
.app-rail-item[data-badge-url] .unread-badge {
    top: 70%;
    left: 70%;
    min-width: 12px;
    height: 12px;
    padding: 0 2px;
    border-radius: 6px;
    font-size: 8px;
    line-height: 12px;
    background: var(--danger);
}

.app-rail-divider {
    width: 24px;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin: 4px 0;
    flex-shrink: 0;
}

/* ツールチップ */
.app-rail-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 9999;
}

.app-rail-item:hover::after {
    opacity: 1;
}

/* スキップリンク */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    background: var(--primary);
    color: #fff;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    z-index: var(--z-toast);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    text-decoration: none;
}
.skip-link:focus {
    top: var(--space-2);
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 0 2rem;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: inherit;
}

.logo {
    height: 25px;
    width: auto;
    display: block;
    filter: brightness(0) invert(1);
}

.logo-label,
.logo-label-link {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: var(--text-lg);
    font-weight: 700;
}
.logo-label-link {
    text-decoration: none;
    color: inherit;
}
.logo-label-link:hover {
    opacity: 0.8;
}

/* WaChat ブランド（chat ヘッダー専用：ロゴ + マスコット） */
.wachat-brand {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    line-height: 1;
}
.wachat-logo {
    height: 28px;
    width: auto;
    display: block;
    margin-top: 8px;
    filter: brightness(0) invert(1);
}
.wachat-mascot {
    height: 32px;
    width: auto;
    display: block;
    margin-top: 5px;
}

.header-nav {
    display: flex;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-chat-link {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.15s;
    transform: scaleX(-1);
}
.header-chat-link:hover {
    color: #fff;
}
.header-chat-link {
    position: relative;
}
.header-chat-link .unread-badge {
    transform: translate(-50%, -50%) scaleX(-1);
}
.header-chat-link.has-unread {
    color: #f59e0b;
}
.header-chat-link.has-unread:hover {
    color: #fbbf24;
}

/* テーマ切り替えドロップダウン */
.theme-selector {
    position: relative;
}

.theme-button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s, border-color 0.2s;
}

.theme-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.theme-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
}

.theme-dropdown.show {
    display: block;
}

.theme-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.theme-option:last-child {
    border-bottom: none;
}

.theme-option:hover {
    background: var(--bg-main);
}

.theme-option.active {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1) 0%, rgba(var(--secondary-rgb), 0.1) 100%);
    font-weight: 600;
}

.theme-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    background: none;
    border: none;
    font: inherit;
    padding: 0;
}

.user-info-text {
    text-align: left;
}

.user-info-name {
    font-size: 0.85rem;
    line-height: 1;
}

.user-info-dept {
    font-size: 0.7rem;
    opacity: 0.8;
    line-height: 1.6;
}

/* ---- User dropdown menu ---- */
.user-menu-wrap {
    position: relative;
}
.user-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px var(--shadow);
    padding: 6px 0;
    z-index: 1100;
}
.user-menu-wrap.open .user-menu {
    display: block;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-base);
    white-space: nowrap;
    transition: background .15s;
}
.user-menu-item:hover {
    background: var(--bg-main);
}
.user-menu-item--danger {
    color: var(--danger);
}
.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--gradient-avatar);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}
img.avatar {
    object-fit: cover;
    background: none;
}

/* サイドバー */
.container {
    display: flex;
    min-height: calc(100vh - 50px);
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1rem;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-item {
    padding: 0;
    margin-bottom: 0.25rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
}

.sidebar-item .sidebar-link {
    padding: 0.5rem 1rem;
}

@media (hover: hover) {
    .sidebar-item:hover {
        background: var(--bg-main);
        color: var(--text-primary);
    }
}

.sidebar-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.sidebar-icon {
    width: 20px;
    height: 20px;
}

.sidebar-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1.5rem 1rem 0.5rem;
    list-style: none;
}

.sidebar-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

/* サイドバー項目内の件数バッジ（メールチェッカー＝app-rail data-badge-url と同系） */
.sidebar-badge {
    margin-left: auto;
    min-width: 18px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* 統計カード */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.stat-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* カード */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* カードリンク */
.card-link {
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.card-link:hover {
    text-decoration: underline;
}

/* ボタン */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
    font-size: 0.875rem;
    font-family: 'Noto Sans JP', sans-serif;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-main);
    border-color: var(--text-secondary);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-main);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.85;
}

/* フォーム */
.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    margin-bottom: var(--space-1);
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
}

/* 汎用テーブル */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.table-responsive table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.table-responsive th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    background: var(--bg-main);
    white-space: nowrap;
}

.table-responsive td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.table-responsive tbody tr:hover {
    background: var(--bg-main);
}

/* フラッシュメッセージ */
.flash {
    padding: 0.875rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: flashIn 0.3s ease;
}

.flash-success {
    background: rgba(var(--success-rgb), 0.1);
    color: #059669;
    border: 1px solid rgba(var(--success-rgb), 0.3);
}

.flash-success::before { content: "✓"; font-size: 1rem; }

.flash-error {
    background: rgba(var(--danger-rgb), 0.1);
    color: #dc2626;
    border: 1px solid rgba(var(--danger-rgb), 0.3);
}

.flash-error::before { content: "!"; font-size: 1rem; font-weight: 900; }

.flash-info {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.flash-info::before { content: "ℹ"; font-size: 1rem; }

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .header-nav {
        display: none;
    }
}

/* ハンバーガーボタン（デスクトップでは非表示） */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    padding: 0;
    cursor: pointer;
    line-height: 0;
    transition: transform 0.2s ease;
}
.hamburger-btn.open {
    transform: rotate(180deg);
}

.hamburger-btn:hover {
    opacity: 0.7;
}

/* サイドバーオーバーレイ（モバイル用） */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
}

.sidebar-overlay.show {
    display: block;
}

@media (max-width: 768px) {
    .app-rail {
        display: none !important;
    }
    body.has-app-rail {
        padding-left: 0 !important;
    }

    .hamburger-btn {
        display: flex;
    }

    .sidebar {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 50;
        box-shadow: var(--shadow-xl);
        overflow-y: auto;
    }

    .sidebar.sidebar-open {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem;
    }

    /* テーマボタン: アイコンのみ */
    .theme-button-label,
    .theme-button-arrow {
        display: none !important;
    }

    .theme-button {
        padding: var(--space-2);
    }

    /* ユーザー名・部門を非表示 */
    .user-info-text {
        display: none;
    }

    .header {
        padding: 0 1rem;
    }

    .header-right {
        gap: var(--space-3);
    }
}

/* ===== プルトゥリフレッシュ（PWA standalone用） ===== */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: center;
    align-items: center;
    height: 0;
    overflow: hidden;
    background: var(--bg-main);
    z-index: 9999;
    transition: height 0.2s ease;
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.ptr-indicator.ptr-pulling { transition: none; }
.ptr-indicator .ptr-arrow {
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.2s ease;
}
.ptr-indicator.ptr-ready .ptr-arrow { transform: rotate(180deg); }
.ptr-indicator.ptr-refreshing .ptr-arrow {
    animation: ptr-spin 0.6s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ===== ヘッダー期間セレクタ ===== */
.header-period-select {
    padding: 0.3rem 0.6rem;
    border: 1.5px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    font-family: 'Noto Sans JP', sans-serif;
    font-size: var(--text-xs);
    font-weight: 600;
    color: rgba(255,255,255,0.95);
    background: rgba(255,255,255,0.12);
    cursor: pointer;
    min-width: 0;
    max-width: 200px;
}
.header-period-select option {
    color: var(--text-primary);
    background: var(--bg-card);
}
.header-period-select:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}
@media (max-width: 768px) {
    .header-period-select {
        max-width: 140px;
        font-size: 0.7rem;
    }
}

/* ===== 期間セレクタ（ページ内用・管理画面等） ===== */
.period-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.period-selector-label {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

.period-selector-select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: 'Noto Sans JP', sans-serif;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    min-width: 200px;
}

.period-selector-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* ===== 評価ステージ共通カラー ===== */
/* 自己: Blue(--primary)  上長: Green(--success)  相対: Purple(--accent-purple) */

/* テーブルカラムヘッダー背景 */
.th-group-self { background: rgba(var(--primary-rgb), 0.06); }
.th-group-first { background: rgba(var(--success-rgb), 0.06); }
.th-group-gm { background: rgba(var(--accent-purple-rgb), 0.06); }

/* テーブルセル背景 */
.td-self { background: rgba(var(--primary-rgb), 0.02); }
.td-first { background: rgba(var(--success-rgb), 0.02); }
.td-gm { background: rgba(var(--accent-purple-rgb), 0.02); }

/* スコア文字色 */
.score-self { color: var(--primary); }
.score-first { color: var(--success); }
.score-gm { color: var(--accent-purple); }
.score-na { color: var(--text-secondary); opacity: 0.7; }

/* 明細パネル スコアボックス背景 */
.detail-score-box.stage-self { background: rgba(var(--primary-rgb), 0.04); }
.detail-score-box.stage-first { background: rgba(var(--success-rgb), 0.04); }
.detail-score-box.stage-gm { background: rgba(var(--accent-purple-rgb), 0.04); }

/* 上長入力セレクト（filled状態） */
.sup-select.filled,
.sup-grid-select.filled {
    border-color: var(--success);
    color: var(--success);
}

.sup-select:focus,
.sup-grid-select:focus {
    outline: none;
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(var(--success-rgb), 0.15);
}

/* 役員入力セレクト（filled状態） */
.gm-select.filled {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

.gm-select:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(var(--accent-purple-rgb), 0.15);
}

/* 閲覧モードバッジ */
.viewonly-badge {
    font-size: var(--text-xs);
    background: var(--text-secondary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    vertical-align: middle;
}

/* ===== フィルターバー（共通） ===== */
.filter-bar {
    background: var(--bg-card);
    padding: var(--space-6);
    border-radius: var(--radius-2xl);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.filter-label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    font-weight: 600;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* ===== プログレスバー（共通） ===== */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* ===== ステップバッジ（共通） ===== */
.step-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
}

.step-not_started { background: rgba(var(--text-secondary-rgb), 0.1); color: var(--text-secondary); }
.step-goals_draft { background: rgba(var(--text-secondary-rgb), 0.15); color: var(--text-secondary); }
.step-goals_submitted { background: rgba(var(--warning-rgb), 0.1); color: var(--warning); }
.step-goals_approved { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.step-self_evaluated { background: rgba(var(--secondary-rgb), 0.1); color: var(--secondary); }
.step-first_evaluated { background: rgba(var(--success-rgb), 0.1); color: var(--success); }
.step-gm_evaluated { background: rgba(var(--accent-purple-rgb), 0.1); color: var(--accent-purple); }
.step-feedback_done { background: rgba(var(--success-rgb), 0.2); color: var(--success); }

/* ===== ステータスバッジ（共通） ===== */
.status-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 700;
}

.status-active { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.status-completed { background: rgba(var(--success-rgb), 0.1); color: var(--success); }
.status-pending { background: rgba(var(--warning-rgb), 0.1); color: var(--warning); }
.status-draft { background: rgba(var(--text-secondary-rgb), 0.1); color: var(--text-secondary); }
.status-closed { background: rgba(var(--warning-rgb), 0.1); color: var(--warning); }
.status-not-started { background: rgba(var(--text-secondary-rgb), 0.1); color: var(--text-secondary); }

/* ===== ロールバッジ（共通） ===== */
.role-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px; font-size: var(--text-xs); font-weight: 700; }
.role-admin   { background: rgba(var(--danger-rgb), 0.1); color: var(--danger); }
.role-sy      { background: rgba(var(--accent-purple-rgb), 0.1); color: var(--accent-purple); }
.role-gm      { background: rgba(var(--success-rgb), 0.1); color: var(--success); }
.role-manager { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.role-user    { background: rgba(var(--text-secondary-rgb), 0.1); color: var(--text-secondary); }
.role-sm      { background: rgba(var(--warning-rgb), 0.1); color: var(--warning); }

/* ===== ツールバー・ビュー切替（共通） ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.toolbar-left {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.toolbar-right {
    display: flex;
    gap: var(--space-2);
}

.view-toggle {
    display: flex;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.view-btn {
    padding: var(--space-2) var(--space-4);
    border: none;
    background: none;
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font-body);
}

.view-btn.active {
    background: var(--primary);
    color: white;
}

/* ===== ビュー切替（共通） ===== */
.card-view { display: none; }
.card-view.active { display: grid; }
.table-view { display: none; }
.table-view.active { display: block; }
.beh-grid-view { display: none; }
.beh-grid-view.active { display: block; }

/* ===== 評価テーブル（共通） ===== */
.eval-table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.eval-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.eval-table th {
    padding: 0.6rem var(--space-2);
    text-align: center;
    font-weight: 700;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.eval-table td {
    padding: 0.6rem var(--space-2);
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-heading);
    font-weight: 600;
}

.eval-table td.name-cell,
.eval-table td.dept-cell {
    font-family: var(--font-body);
    text-align: left;
}

.eval-table tbody tr:hover {
    background: var(--bg-main);
}

/* ===== 行動一覧テーブル（共通） ===== */
.beh-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

.beh-grid-table th {
    padding: 0.3rem 0.2rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.beh-grid-table td {
    padding: 0.35rem 0.2rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.beh-grid-table tbody tr:hover {
    background: var(--bg-main);
}

.beh-grid-table .sticky-name {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 2;
    text-align: left;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.78rem;
    min-width: 80px;
    padding-left: var(--space-2);
    white-space: nowrap;
}

.beh-grid-table tbody tr:hover .sticky-name {
    background: var(--bg-main);
}

.beh-grid-table .sticky-name-th {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 3;
    text-align: left;
    padding-left: var(--space-2);
}

.beh-grid-table .cat-header {
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 0.4rem 0.3rem;
}

.beh-grid-table .item-header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.65rem;
    min-height: 70px;
    line-height: 1.2;
    white-space: nowrap;
}

/* ===== リンク・セル（共通） ===== */
.name-cell-link {
    cursor: pointer;
    color: var(--primary);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.name-cell-link:hover {
    text-decoration-style: solid;
}

/* ===== アクションバー（共通） ===== */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}

/* ===== カードアクション（共通） ===== */
.card-actions {
    display: flex;
    gap: var(--space-2);
}

.card-actions .btn {
    padding: 0.84rem 0;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
}

/* ===== 明細パネル（共通） ===== */
.detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-dropdown);
}

.detail-overlay.show {
    display: flex;
    justify-content: flex-end;
}

.detail-panel {
    width: min(680px, 90vw);
    height: 100vh;
    background: var(--bg-main);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.detail-panel-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}

.detail-panel-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.detail-panel-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.detail-panel-close {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--space-1);
    line-height: 1;
}

.detail-panel-body {
    padding: var(--space-4) var(--space-5);
}

.detail-section {
    margin-bottom: var(--space-5);
}

.detail-section-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.detail-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-2);
    border: 1px solid var(--border);
}

.detail-item-title {
    font-weight: 700;
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.detail-item-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
    line-height: 1.5;
}

.detail-scores {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.detail-score-box {
    flex: 1;
    text-align: center;
    padding: 0.4rem var(--space-2);
    border-radius: var(--radius-md);
}

.detail-score-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.detail-score-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.detail-comment {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: var(--space-2) 0.6rem;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    margin-top: 0.35rem;
}

.detail-comment-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

/* ===== データテーブル（共通） ===== */
.data-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    background: var(--bg-main);
    white-space: nowrap;
}

.data-table th.text-right,
.data-table td.text-right {
    text-align: right;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--bg-main);
}

/* ===== フェーズバー（共通） ===== */
.phase-bar {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.phase-bar-inner {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.phase-bar-label {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}
.phase-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.phase-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}
.phase-dot-active { background: var(--primary); }
.phase-dot-inactive { background: var(--border); }
.phase-name {
    font-size: var(--text-sm);
    text-decoration: none;
}
.phase-name-active {
    font-weight: 700;
    color: var(--primary);
}
.phase-name-inactive {
    font-weight: 400;
    color: var(--text-secondary);
}
.phase-separator {
    width: 20px;
    height: 2px;
    background: var(--border);
}

/* ===== Rich Text 共通 (render_rich_text) ===== */
.rt-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin: var(--space-2) 0;
}
.rt-info + .rt-info { margin-top: 0; }
.rt-info-title {
    font-weight: 700;
    background: var(--dm-info-title-bg, rgba(37, 99, 235, 0.08));
    border-bottom: 1px solid var(--border);
    padding: var(--space-2) var(--space-3);
    margin: calc(-1 * var(--space-3)) calc(-1 * var(--space-3)) var(--space-2);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.rt-code {
    background: var(--bg-main, rgba(0, 0, 0, 0.05));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    font-family: 'Courier New', monospace;
    font-size: var(--text-sm);
    white-space: pre-wrap;
    overflow-x: auto;
}
.rt-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-2) 0;
}
/* 伏字 [hide] */
.rt-hide {
    cursor: pointer;
    user-select: none;
}
.rt-hide .rt-hide-body { display: none; }
.rt-hide .rt-hide-mask {
    background: var(--bg-main, rgba(0, 0, 0, 0.1));
    border-radius: var(--radius-sm);
    padding: 0 var(--space-1);
    letter-spacing: 2px;
    color: var(--text-muted);
}
.rt-hide--open .rt-hide-body { display: inline; }
.rt-hide--open .rt-hide-mask { display: none; }
/* マーカー */
mark {
    background: rgba(250, 204, 21, 0.4);
    border-radius: 2px;
    padding: 0 2px;
}
/* リスト */
.rt-ul, .rt-ol {
    margin: var(--space-1) 0;
    padding-left: 1.5em;
}
.rt-ul { list-style: disc; }
.rt-ol { list-style: decimal; }
.rt-ul li, .rt-ol li { padding: 1px 0; }

/* ===== prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
