/* =====================================================================
   DESIGN SYSTEM & VARIABLES
   ===================================================================== */
:root {
    /* Best Auto 公式カラーパレット */
    --bg-app: #f4f6f9;              /* ベースカラー(背景) */
    --bg-panel: #ffffff;            /* ベースカラー(クリーンホワイト) */
    --bg-panel-hover: #f8fafc;
    --border-color: #c0c0c0;        /* サブカラー(コンクリートグレー) による境界線 */
    
    --text-primary: #003366;        /* メインカラー(ディープネイビー、主要テキスト) */
    --text-secondary: #335c85;      /* メインカラーのバリエーション */
    --text-muted: #64748b;
    
    --accent-orange: #FF7F00;       /* アクセントカラー(セーフティオレンジ) */
    --accent-blue: #003366;         /* メインカラー(ディープネイビー) */
    --accent-gray: #c0c0c0;         /* サブカラー(コンクリートグレー) */
    
    --accent-blue-gradient: linear-gradient(135deg, #003366, #004080);
    --accent-orange-gradient: linear-gradient(135deg, #FF7F00, #ff9933);
    --accent-gray-gradient: linear-gradient(135deg, #c0c0c0, #d9d9d9);
    
    /* フォント規定 (日本語: 源ノ角ゴシック Heavy = Noto Sans JP 900) */
    --font-heading: 'Noto Sans JP', 'Outfit', sans-serif;
    --font-body: 'Noto Sans JP', 'Inter', sans-serif;
    --font-heavy: 900;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 12px rgba(255, 127, 0, 0.15);
    
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* 文字サイズ変更用の基準値 */
    --base-font-size: 15px;
}

/* =====================================================================
   RESET & BASE STYLES
   ===================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--base-font-size);
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

input, button, select, textarea {
    font-family: inherit;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

svg {
    max-width: 100%;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 51, 102, 0.25);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 51, 102, 0.45);
}

/* =====================================================================
   LAYOUT (SIDEBAR & MAIN CONTENT)
   ===================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
    z-index: 1010;
}

/* 折り畳み状態のサイドバー */
.sidebar.collapsed {
    width: 72px;
    padding: 16px 8px;
}

.bestauto-logo-img {
    display: block;
}

.bestauto-logo-collapsed {
    display: none !important;
}

.sidebar.collapsed .bestauto-logo-img {
    display: none !important;
}

.sidebar.collapsed .bestauto-logo-collapsed {
    display: block !important;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    margin-bottom: 0 !important;
}

.sidebar.collapsed .sidebar-current-view {
    display: none !important;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
}

.sidebar.collapsed .menu-item span {
    display: none;
}

.sidebar.collapsed .menu-item svg {
    margin-right: 0;
    width: 22px;
    height: 22px;
}


.profile-info-sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed .profile-info-sidebar {
    display: none !important;
}

.sidebar.collapsed .profile-actions {
    display: none !important;
}

.sidebar.collapsed .sidebar-profile {
    align-items: center;
    padding-top: 10px;
}

.sidebar.collapsed #users-login-status,
.sidebar.collapsed .sidebar-font-size-adjust {
    display: none !important;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer .status-text {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    width: 100%;
}

.sidebar.collapsed .sidebar-header {
    flex-direction: column-reverse;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

#btn-toggle-sidebar {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: var(--transition-smooth);
    border-radius: 6px;
    background-color: rgba(0,0,0,0.03);
}

#btn-toggle-sidebar:hover {
    background-color: rgba(0,0,0,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--accent-blue-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.brand-logo svg {
    width: 22px;
    height: 22px;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-text span {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.menu-item svg {
    width: 20px;
    height: 20px;
}

.menu-item:hover {
    background-color: var(--bg-panel-hover);
    color: var(--text-primary);
}

.menu-item.active {
    background-color: rgba(0, 51, 102, 0.08);
    color: var(--accent-blue);
    border-color: rgba(0, 51, 102, 0.2);
    box-shadow: 0 0 10px rgba(0, 51, 102, 0.05);
    font-weight: var(--font-heavy);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    height: 100%;
    min-height: 0;
}

.main-header {
    height: 50px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    display: flex;
    align-items: center;
    background-color: var(--bg-panel);
    position: relative;
    z-index: 1000;
}

.header-title h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: var(--font-heavy);
}

.header-title p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-info {
    text-align: right;
}

.profile-name {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
}

.profile-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-purple-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.view-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-app) 0%, #e2e8f0 100%);
    min-width: 0;
}

/* =====================================================================
   VIEW SECTIONS CONTROLLERS
   ===================================================================== */
@keyframes viewFadeIn {
    from {
        opacity: 0;
        transform: scale(0.995) translateY(4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.view-section {
    display: none;
    opacity: 0;
    min-height: 0;
}

.view-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 12px;
    animation: viewFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

/* =====================================================================
   COMPONENTS: STAT CARDS (DASHBOARD)
   ===================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13.75rem, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-0.25rem);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.stat-icon.purple { background: var(--accent-purple-gradient); }
.stat-icon.blue { background: var(--accent-blue-gradient); }
.stat-icon.green { background: var(--accent-green-gradient); }
.stat-icon.amber { background: var(--accent-amber-gradient); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
}

/* =====================================================================
   COMPONENTS: CARDS & TIMELINE
   ===================================================================== */
.card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    min-width: 0;
}

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

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: var(--font-heavy);
}

.badge {
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: var(--font-heavy);
    border-radius: 4px;
    background-color: rgba(255, 127, 0, 0.12);
    color: var(--accent-orange);
    border: 1px solid rgba(255, 127, 0, 0.25);
}

.card-body {
    padding: 16px;
}

.card-body.scrollable {
    overflow-y: auto;
    overflow-x: auto;
    max-height: calc(100vh - 290px);
    position: relative;
}

.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.4375rem;
    top: 0.625rem;
    bottom: 0.625rem;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -1.375rem;
    top: 0.3125rem;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background-color: var(--bg-panel);
    border: 3px solid var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-blue);
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.timeline-details a {
    color: var(--accent-blue);
    text-decoration: none;
}
.timeline-details a:hover {
    text-decoration: underline;
}

/* =====================================================================
   COMPONENTS: SEARCH BAR & TABS
   ===================================================================== */
.search-and-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background-color: var(--bg-panel);
    padding: 12px 24px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.tab-buttons {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    background-color: var(--bg-app);
    color: var(--accent-blue);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.search-bar {
    position: relative;
    width: 320px;
}

.search-bar.filter-bar {
    width: 100%;
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px 10px 40px;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.search-bar input:focus {
    border-color: var(--accent-orange);
    box-shadow: var(--shadow-glow);
}

/* =====================================================================
   COMPONENTS: SPLIT DATA VIEW
   ===================================================================== */
.data-view-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.data-list-card {
    height: auto;
    min-height: 0;
}

.data-detail-card {
    height: auto;
    min-height: 0;
    background-color: rgba(21, 28, 44, 0.3);
}

/* リストアイテム */
.list-item {
    padding: 8px 16px;
    border-radius: 4px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.list-item:hover {
    background-color: var(--bg-panel-hover);
}

.list-item.selected {
    background-color: rgba(0, 180, 216, 0.08);
    border-color: rgba(0, 180, 216, 0.2);
}

.list-item-title {
    font-size: 0.88rem;
    font-weight: 600;
}

.list-item-sub {
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.list-item-tag {
    font-size: 0.68rem;
    color: var(--text-muted);
    align-self: flex-start;
}

/* 詳細プレースホルダー */
.detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 16px;
    text-align: center;
}

.detail-placeholder svg {
    width: 64px;
    height: 64px;
    color: rgba(255, 255, 255, 0.05);
}

.detail-placeholder p {
    font-size: 0.9rem;
    max-width: 250px;
    line-height: 1.5;
}

/* 詳細コンテンツ */
.detail-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.3s ease;
}

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

.detail-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.detail-header h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
}

.detail-header-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.detail-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value.link {
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: underline;
}

.detail-section-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

/* =====================================================================
   COMPONENTS: VEHICLE GRID (CARD)
   ===================================================================== */
.vehicles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.vehicle-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.vehicle-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-blue-gradient);
}

.vehicle-card:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 180, 216, 0.3);
    box-shadow: var(--shadow-md);
}

.vehicle-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.vehicle-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

.vehicle-maker {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.vehicle-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.vehicle-info-row {
    display: flex;
    justify-content: space-between;
}

.vehicle-info-label {
    color: var(--text-secondary);
}

.vehicle-info-val {
    font-weight: 500;
}

.vehicle-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.inspection-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.inspection-tag.ok {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.inspection-tag.alert {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* =====================================================================
   COMPONENTS: MODAL
   ==================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 700px;
    max-width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

/* =====================================================================
   LOADING SPINNER
   ===================================================================== */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =====================================================================
   EXTENDED STYLES FOR VEHICLE ATTRIBUTES
   ===================================================================== */
.vehicle-ton {
    display: inline-block;
    padding: 2px 6px;
    background-color: rgba(0, 180, 216, 0.12);
    color: var(--accent-blue);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 6px;
    border: 1px solid rgba(0, 180, 216, 0.2);
}

.status-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-tag.sales {
    background-color: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-tag.deal {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-tag.sold {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-tag.hold {
    background-color: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

.status-tag.lost {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-tag.assessment {
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.spec-text {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: 8px;
    color: var(--text-secondary);
}

.filter-select {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    min-width: 140px;
    transition: var(--transition-smooth);
}

.filter-select:focus {
    border-color: var(--accent-orange);
    box-shadow: var(--shadow-glow);
}

/* =====================================================================
   DATA TABLE STYLES
   ===================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed; /* fixedに戻すことで常に横幅100%にきれいに広がります */
}

.data-table th, 
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 列の幅に収まらない場合は自動で ... に省略します */
}

.data-table td > div,
.data-table td > span {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.data-table th {
    background-color: #0f172a !important;
    color: #ffffff !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    box-shadow: inset 0 -1.5px 0 rgba(255, 255, 255, 0.15) !important;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background-color 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s ease !important;
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--bg-app);
}

.data-table tbody tr.row-unconfirmed:nth-child(even) {
    background-color: rgba(255, 127, 0, 0.08) !important;
}

.data-table tbody tr.row-sales {
    background-color: rgba(26, 115, 232, 0.035) !important;
}
.data-table tbody tr.row-sales:hover {
    background-color: rgba(26, 115, 232, 0.08) !important;
}
.data-table tbody tr.row-assessment {
    background-color: rgba(16, 185, 129, 0.035) !important;
}
.data-table tbody tr.row-assessment:hover {
    background-color: rgba(16, 185, 129, 0.08) !important;
}

.data-table tbody tr:hover {
    background-color: var(--bg-panel-hover) !important;
    box-shadow: inset 3px 0 0 var(--accent-orange) !important;
}

.data-table tbody tr.selected {
    background-color: rgba(255, 127, 0, 0.05) !important;
    box-shadow: inset 4px 0 0 var(--accent-orange) !important;
}

.data-table tbody tr.selected td {
    color: var(--text-primary);
}

/* ボタンのスタイル拡張 */
.btn {
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-orange-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(255, 127, 0, 0.25);
    border: 1px solid #e07000;
}

.btn-primary:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 127, 0, 0.35);
}

.btn-danger {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.btn-danger:hover {
    background-color: #dc2626;
    color: #ffffff;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

/* フォームグループ */
.form-group label {
    font-weight: 600;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent-orange) !important;
    box-shadow: var(--shadow-glow);
    outline: none;
}

/* =====================================================================
   VEHICLE SUB-VIEWS FOR FULL TRANSITION
   ===================================================================== */
@keyframes subViewFadeIn {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.vehicle-sub-view, .customer-sub-view, .case-sub-view {
    display: none;
    width: 100%;
    overflow: hidden;
}

/* display: flex !important のみ !important → display:none を確実に上書き */
/* height は JS (syncCustomerSubviewHeight) が getBoundingClientRect で実測して inline style で設定 */
.vehicle-sub-view.active, .customer-sub-view.active, .case-sub-view.active {
    display: flex !important;
    flex-direction: column;
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    animation: subViewFadeIn 0.14s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#btn-back-to-vehicles:hover {
    color: var(--text-primary) !important;
    transform: translateX(-4px);
}

/* =====================================================================
   COLUMN SELECT POPOVER
   ===================================================================== */
.column-select-popover {
    display: none;
    position: absolute;
    top: 38px;
    right: 0;
    left: auto;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    width: 250px;
    max-width: 90vw; /* 画面幅が狭いときに自動で縮小 */
    box-shadow: var(--shadow-md), var(--shadow-glow);
    z-index: 2000;
    max-height: 380px;
    overflow-y: auto;
    box-sizing: border-box;
}

.column-select-popover.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: var(--transition-smooth);
    font-size: 0.85rem;
    user-select: none;
}

.popover-item.draggable {
    cursor: grab;
}

.popover-item.draggable:active {
    cursor: grabbing;
}

.popover-item:hover {
    background-color: rgba(0, 51, 102, 0.06);
}

.popover-item.dragging {
    opacity: 0.5;
    background-color: rgba(255, 127, 0, 0.15);
    border: 1px dashed var(--accent-orange);
}

.popover-item.over {
    background-color: rgba(255, 127, 0, 0.08);
    border-top: 2px solid var(--accent-orange);
}

.popover-item input[type="checkbox"] {
    -webkit-appearance: checkbox !important;
    appearance: checkbox !important;
    opacity: 1 !important;
    display: inline-block !important;
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent-blue) !important;
}

.drag-handle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-right: 2px;
    display: inline-flex;
    align-items: center;
    user-select: none;
}

/* =====================================================================
   FONT SIZE SLIDER CUSTOMIZATION
   ===================================================================== */
#font-size-slider {
    -webkit-appearance: none;
    appearance: none;
}

#font-size-slider::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.15);
    height: 4px;
    border-radius: 2px;
}

#font-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: var(--accent-blue);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-top: -5px;
    box-shadow: 0 0 6px var(--accent-blue);
    transition: var(--transition-smooth);
}

#font-size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #ffffff;
}

/* =====================================================================
   VEHICLE DETAIL SECTIONS (DRAG & DROP)
   ===================================================================== */
.card-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 16px;
    transition: var(--transition-smooth);
}

.card-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.card-section-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.section-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 1rem;
    user-select: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.section-drag-handle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-blue);
}

.draggable-section.dragging-section {
    opacity: 0.4;
    background: rgba(0, 180, 216, 0.05);
    border: 1px dashed var(--accent-blue);
}

.draggable-section.over-section {
    border-top: 2px solid var(--accent-blue);
    background: rgba(0, 180, 216, 0.02);
}

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

.detail-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 600px) {
    .detail-grid-2col {
        grid-template-columns: 1fr;
    }
}

/* =====================================================================
   LAYOUT EDITOR MODE STYLES
   ===================================================================== */
.layout-edit-active .card-section {
    border: 1px dashed rgba(0, 180, 216, 0.4);
    background: rgba(0, 180, 216, 0.01);
}

.layout-edit-active .card-section:hover {
    border-color: var(--accent-blue);
    background: rgba(0, 180, 216, 0.03);
}

/* 編集モード時の個別項目ブロック */
.layout-edit-active .detail-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: grab;
    user-select: none;
    transition: var(--transition-smooth);
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layout-edit-active .detail-group:hover {
    background: rgba(0, 180, 216, 0.08);
    border-color: var(--accent-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.layout-edit-active .detail-group.dragging-field {
    opacity: 0.4;
    border: 1px dashed var(--accent-blue);
    background: rgba(0, 180, 216, 0.05);
}

.layout-edit-active .detail-group.over-field {
    border-left: 3px solid var(--accent-blue);
    background: rgba(0, 180, 216, 0.05);
}

/* 未使用項目トレイ */
.unused-fields-tray {
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    transition: var(--transition-smooth);
}

.unused-fields-tray.layout-edit-active {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.01);
}

.unused-fields-tray.over-tray {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.unused-fields-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.unused-fields-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #f59e0b;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.unused-fields-list {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    max-height: none;
    overflow-y: visible;
    padding-right: 4px;
    width: 100%;
}

.unused-field-item {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbd38d;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: grab;
    user-select: none;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
}

.unused-field-item:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.unused-field-item.dragging-field {
    opacity: 0.4;
    border: 1px dashed #f59e0b;
}

/* ミニ操作ボタン */
.section-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
    line-height: 1;
}

.section-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.section-action-btn.edit-btn:hover {
    color: var(--accent-blue);
}

.section-action-btn.delete-btn:hover {
    color: var(--accent-red);
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* レイアウト編集トグルスイッチ */
.editor-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 20px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-round {
    background-color: var(--accent-blue);
}

input:checked + .slider-round:before {
    transform: translateX(14px);
}

/* マルチカラムグリッド */
.detail-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.detail-grid-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 900px) {
    .detail-grid-4col {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .detail-grid-3col, .detail-grid-4col {
        grid-template-columns: 1fr;
    }
}

/* レイアウト編集用ドロップダウン入力 */
.section-cols-select, .add-field-select {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}

.section-cols-select:hover, .add-field-select:hover {
    background: #f8fafc;
    border-color: var(--accent-orange);
}

.section-cols-select option, .add-field-select option {
    background: #ffffff;
    color: var(--text-primary);
}

.add-field-select {
    width: 100%;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    padding: 8px;
    font-size: 0.8rem;
}

.add-field-select:hover {
    border-color: #f59e0b;
    color: #fbd38d;
    background: rgba(245, 158, 11, 0.03);
}

.add-field-select option {
    background: #111827;
    color: var(--text-primary);
}

/* =====================================================================
   LAYOUT EDITOR WORKSPACE (SIDEBAR LAYOUT)
   ===================================================================== */
.layout-editor-workspace {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    align-items: flex-start;
}

.layout-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.01);
    border: 1.5px dashed rgba(245, 158, 11, 0.25);
    padding: 16px;
    border-radius: 10px;
    display: none; /* デフォルト非表示 */
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    align-self: flex-start;
    transition: var(--transition-smooth);
}

.layout-edit-active .layout-sidebar {
    display: flex; /* 編集モード時のみ表示 */
}

.layout-sidebar.over-sidebar {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.layout-main-sections {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (max-width: 850px) {
    .layout-editor-workspace {
        flex-direction: column;
    }
    .layout-sidebar {
        width: 100%;
        position: static;
    }
}

/* ドラッグオーバーによるヘッダー/ボディの発光インジケータ */
.card-section-header.over-header {
    border-bottom: 2px solid var(--accent-blue) !important;
    background: rgba(0, 180, 216, 0.04) !important;
    transition: var(--transition-smooth);
}

.card-section-body.over-body {
    border-bottom: 2px dashed #f59e0b !important;
    background: rgba(245, 158, 11, 0.02) !important;
    transition: var(--transition-smooth);
}

/* 詳細カードの sticky 対応のための overflow 上書き */
#vehicle-detail-card {
    overflow: visible !important;
}

/* セクションの上下移動用ドラッグオーバー効果 */
.draggable-section {
    position: relative;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.draggable-section.over-section-top {
    border-top: 3px solid var(--accent-blue) !important;
    transform: translateY(6px);
}

.draggable-section.over-section-bottom {
    border-bottom: 3px solid var(--accent-blue) !important;
    transform: translateY(-6px);
}

/* セクションドラッグハンドル */
.section-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: grab;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 1.05rem;
    transition: var(--transition-smooth);
    user-select: none;
}
.section-drag-handle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-blue) !important;
}
.section-drag-handle:active {
    cursor: grabbing;
}

/* 項目のドラッグオーバー左右配置インジケータ */
.draggable-field {
    position: relative;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.draggable-field.over-field-left {
    border-left: 3px solid var(--accent-blue) !important;
    transform: translateX(4px);
}

.draggable-field.over-field-right {
    border-right: 3px solid var(--accent-blue) !important;
    transform: translateX(-4px);
}

/* テーブルカラムのリサイズ */
#vehicle-table {
    table-layout: fixed !important;
    width: auto !important;
    min-width: 100% !important;
    border-collapse: collapse;
}

.resizable-th {
    position: relative;
    user-select: none;
}

.col-resize-handle {
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 100;
    background: transparent;
    transition: background-color 0.1s;
}

.col-resize-handle:hover {
    background-color: var(--accent-orange) !important;
    width: 4px !important;
    right: -2px !important;
}

body.resizing {
    cursor: col-resize !important;
}

body.resizing * {
    user-select: none !important;
}

/* 数値入力フィールドのスピンボタン（上下矢印）を非表示にする */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

/* スクロールバーと縦スクロール対応 (フェーズ3改善) */
#customer-detail, #vehicle-detail-card {
    overflow-y: auto !important;
    max-height: 100% !important;
    height: 100% !important;
}

/* スタイリッシュなスクロールバーのデザイン */
#customer-detail::-webkit-scrollbar, #vehicle-detail-card::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#customer-detail::-webkit-scrollbar-track, #vehicle-detail-card::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 3px;
}
#customer-detail::-webkit-scrollbar-thumb, #vehicle-detail-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
#customer-detail::-webkit-scrollbar-thumb:hover, #vehicle-detail-card::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================== */
/* 詳細パネルのライトモード化 (背景を白にし、文字を黒にする) (フェーズ3改善) */
/* ============================================================== */
.data-detail-card, #vehicle-detail-card {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03) !important;
}

/* 内部テキストとラベルのライトモードオーバーライド */
.data-detail-card .detail-header h3, #vehicle-detail-card h3 {
    color: #0f172a !important;
}
.data-detail-card .detail-header-sub, #vehicle-detail-card .vehicle-maker {
    color: #64748b !important;
}
.data-detail-card .detail-label, #vehicle-detail-card .detail-label {
    color: #475569 !important; /* ラベル */
}
.data-detail-card .detail-value, #vehicle-detail-card .detail-value {
    color: #0f172a !important; /* 値 */
    font-weight: 500;
}
.data-detail-card .detail-value.link, #vehicle-detail-card .detail-value.link {
    color: #0284c7 !important; /* リンク */
}
.data-detail-card .detail-section-title, #vehicle-detail-card h4 {
    color: #1e293b !important;
}

/* ボーダーラインのライトモード化 */
.data-detail-card div, #vehicle-detail-card div, 
.data-detail-card section, #vehicle-detail-card section {
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* AI要約カードのライトモードデザイン */
#contact-ai-summary-section .ai-summary-card {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.04), rgba(0, 102, 204, 0.01)) !important;
    border: 1px solid rgba(0, 102, 204, 0.25) !important;
}
#contact-ai-summary-text {
    color: #1e293b !important;
}
#vehicle-ai-summary-section .ai-summary-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.04), rgba(245, 158, 11, 0.01)) !important;
    border: 1px solid rgba(245, 158, 11, 0.25) !important;
}
#product-ai-summary-text {
    color: #1e293b !important;
}
#case-ai-summary-section .ai-summary-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.04), rgba(139, 92, 246, 0.01)) !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
}
#case-ai-summary-text {
    color: #1e293b !important;
}
#case-ai-summary-section h4 {
    color: #8b5cf6 !important;
}

/* タイムラインのライトモードデザイン */
.data-detail-card .timeline-content, #vehicle-detail-card .timeline-content {
    background: #f8fafc !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    color: #334155 !important;
}
.data-detail-card .timeline-title, #vehicle-detail-card .timeline-title {
    color: #0f172a !important;
}
.data-detail-card .timeline-time, #vehicle-detail-card .timeline-time {
    color: #64748b !important;
}
.data-detail-card .timeline-details, #vehicle-detail-card .timeline-details {
    color: #475569 !important;
}
.data-detail-card .timeline-marker, #vehicle-detail-card .timeline-marker {
    background: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}
.data-detail-card .timeline-item::after, #vehicle-detail-card .timeline-item::after {
    background-color: #e2e8f0 !important;
}

/* 所属する連絡先（担当者）カードのライトモード化 */
.data-detail-card div[style*="background:rgba(255,255,255,0.02)"] {
    background: #f8fafc !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

/* アクションボタン（編集・削除）のスタイル調整 */
.data-detail-card button.btn[style*="border:1px solid var(--border-color)"] {
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}
.data-detail-card button.btn[style*="border:1px solid var(--border-color)"]:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

/* 所属会社リンク */
/* 所属会社リンク */
.data-detail-card span[onclick*="showCustomerLink"] {
    color: #0284c7 !important;
}

/* 詳細カード自体を縦いっぱいに引き伸ばす */
.customer-sub-view .data-detail-card,
.case-sub-view .data-detail-card,
.vehicle-sub-view #vehicle-detail-card {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
}

/* 詳細カードのボディにだけ縦スクロールを出す */
.customer-sub-view .card-body,
.case-sub-view .card-body,
.vehicle-sub-view .card-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 24px !important;
}

/* 一覧サブビューもコンテナ高さいっぱいに使う */
.customer-sub-view.active > .card.data-list-card,
.case-sub-view.active > .card.data-list-card {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin-top: 0 !important; /* 操作バーが消えたため上のマージンをリセット */
    height: 100% !important;
}

/* ヘッダー位置に移動したアクションツールバー用スタイル調整 */
.main-header .tab-buttons {
    display: flex;
    gap: 4px;
}

.main-header .tab-btn {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    height: 32px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    font-weight: 600;
}

.main-header .tab-btn.active {
    background-color: rgba(0, 51, 102, 0.08) !important;
    border-color: rgba(0, 51, 102, 0.15) !important;
    color: var(--accent-blue) !important;
}

.main-header .search-bar {
    height: 32px !important;
    padding: 0 10px 0 32px !important;
    border-radius: 6px !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-app) !important;
    display: flex !important;
    align-items: center !important;
    position: relative !important;
}

.main-header .search-bar svg {
    position: absolute !important;
    left: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
}

.main-header .search-bar input {
    background: transparent !important;
    border: none !important;
    height: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    font-size: 0.78rem !important;
    outline: none !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

/* 問い合わせ一覧 (gmail-row) のコンパクト化 */
.gmail-row > div:first-child {
    padding: 6px 16px !important;
}
.gmail-body {
    padding: 12px 20px 12px 42px !important;
}

/* 詳細ビューを前面の浮いたカードではなく、画面全体に広がるフラットな表示領域にする */
.customer-sub-view, 
.case-sub-view, 
.vehicle-sub-view {
    padding: 0 !important; /* 隙間を無くす */
}

/* 詳細エリアの上部に配置される「戻る」ボタンエリアをフラットなヘッダーバー化 */
.detail-back-bar {
    margin-bottom: 0 !important;
    padding: 10px 20px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

/* 詳細カード自体をフラットにし、ボーダーや角丸、影を消して画面全体化 */
/* ★ flex:1 で親（customer-sub-view.active）の残り高さをすべて確保する ★ */
.customer-sub-view .data-detail-card,
.case-sub-view .data-detail-card,
.vehicle-sub-view #vehicle-detail-card {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background-color: var(--bg-panel) !important;
    margin-top: 0 !important;
    width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* 詳細部分のパディングを画面全体にフィットさせる */
/* ★ flex:1 で .data-detail-card の残り高さをすべて確保し、縦スクロール ★ */
.customer-sub-view .data-detail-card > .card-body,
.case-sub-view .data-detail-card > .card-body,
.vehicle-sub-view #vehicle-detail-card > .card-body {
    padding: 20px !important;
    background-color: var(--bg-panel) !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
}

/* 一覧用のカードにコンパクトな余白と境界線を設定し、視認性を高める */
.data-list-card,
#view-vehicles .card {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    background-color: var(--bg-panel) !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* 一覧のスクロールコンテナのパディングを 0 にしてテーブルを端まで広げる */
.data-list-card .card-body.scrollable,
#view-vehicles .card-body.scrollable {
    padding: 0 !important;
    overflow-y: auto !important;
    overflow-x: auto !important; /* 横スクロールを明示的に有効化 */
    flex: 1 !important;
    max-height: 100% !important;
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
}

/* テーブル内のセルアライメント調整 */
.data-table th,
.data-table td {
    padding: 8px 12px !important;
}
.data-table th:first-child,
.data-table td:first-child {
    padding-left: 20px !important;
}
.data-table th:last-child,
.data-table td:last-child {
    padding-right: 20px !important;
}

/* サイドバーのフォントサイズ調整セクション */
.sidebar-footer-fontsize {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}
.fontsize-btn-group {
    display: inline-flex;
    gap: 6px;
}
.btn-fontsize-adjust {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
    line-height: 1;
}
.btn-fontsize-adjust:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}
.btn-fontsize-adjust:active {
    transform: scale(0.95);
}

/* 要確認データ行の警告色の背景 */
.data-table tbody tr.row-unconfirmed {
    background-color: rgba(255, 127, 0, 0.05) !important;
}
.data-table tbody tr.row-unconfirmed:hover {
    background-color: rgba(255, 127, 0, 0.09) !important;
}
.badge-unconfirmed-inline {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    background-color: rgba(255, 127, 0, 0.12);
    color: var(--accent-orange);
    border: 1px solid rgba(255, 127, 0, 0.25);
    margin-left: 8px;
    line-height: 1.2;
}

/* =====================================================================
   LAYOUT FIX: ensure flex height propagation from .view-section.active -> sub-views
   Problem: .*-sub-view.active was absolutely positioned which can break
   height propagation in a nested flex chain. The overrides below force the
   active section and subview to participate in the flex layout so children
   can use flex:1 and min-height:0 correctly.
   ===================================================================== */

.view-section.active {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
}

/* Active subviews fill the parent section using flex layout, which preserves
   the flex-height chain and avoids absolute-positioned collapse inside nested
   flex containers. */
.vehicle-sub-view.active, .customer-sub-view.active, .case-sub-view.active {
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
    animation: subViewFadeIn 0.14s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Ensure the visible subview and its direct card expand to the full available height. */
.customer-sub-view.active,
.vehicle-sub-view.active,
.case-sub-view.active,
#customer-list-view,
#vehicle-list-view,
#case-list-view,
#customer-detail-view,
#vehicle-detail-view,
#case-detail-view {
    min-height: 0 !important;
    height: 100% !important;
}

/* Force the list card and its scroll body to fill the active customer/vehicle/case subview. */
.customer-sub-view.active > .card.data-list-card,
.vehicle-sub-view.active > .card,
.case-sub-view.active > .card {
    height: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

.customer-sub-view.active .card-body.scrollable,
.vehicle-sub-view.active .card-body.scrollable,
.case-sub-view.active .card-body.scrollable {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: 100% !important;
    width: 100% !important;
}

/* Ensure scrollable/card bodies can shrink correctly inside flex containers */
.customer-sub-view .data-detail-card,
.customer-sub-view .data-detail-card > .card-body,
.data-list-card .card-body.scrollable {
    min-height: 0 !important;
}

/* =====================================================================
   FULL-SCREEN FLAT EDITING MODALS
   ===================================================================== */
#product-form-modal .modal-content,
#customer-form-modal .modal-content,
#case-form-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

#product-form-modal .modal-body,
#customer-form-modal .modal-body,
#case-form-modal .modal-body {
    flex: 1 !important;
    max-height: none !important;
    overflow-y: auto !important;
    padding: 20px 24px !important;
}

#product-form-modal .modal-header,
#customer-form-modal .modal-header,
#case-form-modal .modal-header {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 16px 24px !important;
}

#product-form-modal form,
#customer-form-modal form,
#case-form-modal form {
    max-width: 600px;
    margin: 0 auto !important;
    width: 100%;
}

/* =====================================================================
   MOBILE RESPONSIVE UI STYLES (screen widths <= 768px)
   ===================================================================== */
@media (max-width: 768px) {
    /* サイドバーを固定ドロワー（引き出し型）に変更 */
    .app-container {
        position: relative;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 270px !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2100;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.3);
        background-color: var(--bg-panel);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* モバイル専用のメニュー閉じる背景マスク */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(3px);
        z-index: 2050;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* メインコンテンツヘッダーを2列・複数行に折り返せるようにし、高さを自動調整 */
    .main-header {
        height: auto !important;
        min-height: 52px;
        padding: 8px 12px !important;
        display: flex;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 8px;
    }

    /* モバイル専用のバーガーアイコンを表示 */
    #btn-mobile-menu {
        display: flex !important;
        flex-shrink: 0;
    }

    /* ヘッダーの冗長なテキスト見出しをモバイルで非表示にしスペースを確保 */
    .main-header h2 {
        display: none !important;
    }

    /* アクションバーの折り返し設定 */
    #header-customer-actions, 
    #header-vehicle-actions, 
    #header-case-actions {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: flex-start !important;
    }

    /* 検索バーをフル幅にして押し下げる */
    .main-header .search-bar {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        order: 10; /* 最下部に配置 */
    }

    /* タブ切り替えボタンを横スクロール可能に */
    .main-header .tab-buttons,
    .main-header .tabs-container {
        display: flex !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100% - 10px);
        gap: 4px;
        padding: 2px 0;
        /* スクロールバー非表示 */
        scrollbar-width: none;
    }
    .main-header .tab-buttons::-webkit-scrollbar,
    .main-header .tabs-container::-webkit-scrollbar {
        display: none;
    }
    
    .main-header .tab-btn {
        flex-shrink: 0 !important;
        padding: 4px 10px !important;
        font-size: 0.72rem !important;
    }

    /* 各種ボタン・セレクトボックスの縮小化 */
    .main-header .btn, 
    .main-header select {
        padding: 4px 8px !important;
        height: 28px !important;
        font-size: 0.72rem !important;
    }

    /* 要重複確認チェックボックスの配置調整 */
    #wrapper-filter-unconfirmed {
        font-size: 0.7rem !important;
        gap: 4px !important;
    }

    /* 詳細画面（グリッド）を1列強制に */
    .detail-grid-3col,
    .detail-grid-4col,
    .detail-grid-2col {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* テーブル要素の横スクロールコンテナ */
    .inquiry-list-container,
    #customer-list,
    #vehicle-list {
        overflow-x: auto !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    /* モバイルでのテーブル表示調整 */
    .data-table {
        min-width: 600px; /* 横スクロールを発生させて潰れないようにする */
    }

    /* 入力フォームのタップしやすさ向上（iOSズーム防止の16px） */
    input[type="text"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
        padding: 8px 10px !important;
    }

    /* 検索条件チェックボックスの2列表示化 */
    .checkbox-group-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}


