:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --sidebar-w: 260px;
    --header-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
}
.logo i { font-size: 1.6rem; color: var(--accent); }
.logo-sub { color: rgba(255,255,255,0.6); display: block; margin-top: 4px; font-size: 0.75rem; }

.nav-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.7);
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
    border-right: 3px solid var(--accent);
}
.nav-item i { width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.user-name { font-weight: 500; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: rgba(255,255,255,0.5); }

/* Main */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}

.header {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); }
.page-title { font-size: 1.2rem; font-weight: 700; flex: 1; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.notification-bell { position: relative; cursor: pointer; font-size: 1.2rem; color: var(--text-light); }
.notif-badge {
    position: absolute; top: -6px; right: -8px;
    background: var(--danger); color: white;
    font-size: 0.65rem; width: 18px; height: 18px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.current-date { font-size: 0.85rem; color: var(--text-light); }

.notif-panel {
    display: none;
    position: fixed;
    top: var(--header-h);
    right: 32px;
    width: 420px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 60;
    padding: 20px;
}
.notif-panel.show { display: block; }
.notif-panel h3 { margin-bottom: 16px; font-size: 1rem; }
.notif-item {
    display: flex; gap: 12px; padding: 12px;
    border-radius: 8px; margin-bottom: 8px;
    background: #f8fafc;
}
.notif-item.critical { border-left: 4px solid var(--danger); }
.notif-item.warning { border-left: 4px solid var(--warning); }
.notif-item.info { border-left: 4px solid var(--primary-light); }
.notif-item i { margin-top: 2px; }
.notif-item.critical i { color: var(--danger); }
.notif-item.warning i { color: var(--warning); }
.notif-item.info i { color: var(--primary-light); }
.notif-item p { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }
.notif-item small { font-size: 0.75rem; color: #94a3b8; }

/* Page content */
.page-content { padding: 24px 32px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary-light); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }
.stat-value { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-label { font-size: 0.85rem; color: var(--text-light); }

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-card.wide { grid-column: span 1; }
.charts-row:first-of-type .chart-card.wide { grid-column: 1 / 2; }
.chart-card h3 { font-size: 1rem; margin-bottom: 16px; font-weight: 600; }

/* Effect bars */
.effect-list { margin-bottom: 20px; }
.effect-item { margin-bottom: 12px; }
.effect-label { font-size: 0.85rem; color: var(--text-light); display: block; margin-bottom: 4px; }
.effect-bar {
    height: 28px; background: #f1f5f9; border-radius: 14px; overflow: hidden;
}
.effect-fill {
    height: 100%; border-radius: 14px;
    background: linear-gradient(90deg, var(--primary-light), var(--accent));
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 12px; font-size: 0.8rem; font-weight: 600; color: white;
    transition: width 1s ease;
}
.effect-fill.orange { background: linear-gradient(90deg, var(--warning), #fb923c); }
.effect-fill.green { background: linear-gradient(90deg, var(--success), #34d399); }
.effect-fill.purple { background: linear-gradient(90deg, var(--purple), #a78bfa); }

.cost-saving {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, #dbeafe, #ede9fe);
    padding: 16px; border-radius: 12px;
}
.cost-saving i { font-size: 2rem; color: var(--primary); }
.saving-value { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); display: block; }
.saving-label { font-size: 0.8rem; color: var(--text-light); }

/* Recent repairs */
.recent-repairs { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.repair-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: 8px; background: #f8fafc;
    font-size: 0.85rem;
}
.repair-status {
    width: 10px; height: 10px; border-radius: 50; flex-shrink: 0;
    border-radius: 50%;
}
.repair-status.completed { background: var(--success); }
.repair-status.in-progress { background: var(--warning); }
.repair-status.pending { background: var(--text-light); }
.repair-info { flex: 1; }
.repair-info strong { display: block; }
.repair-time { color: var(--text-light); font-size: 0.8rem; white-space: nowrap; }

/* PREDICTIVE */
.page-header-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header-row h2 { font-size: 1.3rem; }
.btn {
    padding: 10px 20px; border: none; border-radius: 8px;
    cursor: pointer; font-size: 0.9rem; font-weight: 500;
    display: inline-flex; align-items: center; gap: 8px;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary-light); color: white; }
.btn-primary:hover { background: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; background: var(--primary-light); color: white; border: none; border-radius: 6px; cursor: pointer; }
.btn-sm:hover { background: var(--primary); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-light); }

.ai-status-bar {
    background: var(--card); border-radius: 8px; padding: 16px;
    margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ai-progress { height: 6px; background: #e2e8f0; border-radius: 3px; margin-bottom: 8px; overflow: hidden; }
.ai-progress-bar {
    height: 100%; background: linear-gradient(90deg, var(--primary-light), var(--accent));
    border-radius: 3px; width: 0%; transition: width 0.3s;
}
#aiDiagText { font-size: 0.85rem; color: var(--text-light); }

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}
.equip-card {
    background: var(--card); border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer; transition: all 0.2s;
    border-left: 4px solid var(--success);
}
.equip-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.equip-card.warning { border-left-color: var(--warning); }
.equip-card.critical { border-left-color: var(--danger); }
.equip-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.equip-name { font-weight: 600; font-size: 0.95rem; }
.equip-model { font-size: 0.8rem; color: var(--text-light); }
.equip-badge {
    padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 500;
}
.equip-badge.normal { background: #d1fae5; color: #065f46; }
.equip-badge.warning { background: #fef3c7; color: #92400e; }
.equip-badge.critical { background: #fee2e2; color: #991b1b; }
.equip-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.equip-metric { font-size: 0.8rem; }
.equip-metric span { color: var(--text-light); display: block; font-size: 0.75rem; }
.equip-metric strong { color: var(--text); }
.health-bar { height: 4px; background: #e2e8f0; border-radius: 2px; margin-top: 12px; overflow: hidden; }
.health-fill { height: 100%; border-radius: 2px; transition: width 1s; }
.health-fill.good { background: var(--success); }
.health-fill.warn { background: var(--warning); }
.health-fill.bad { background: var(--danger); }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--card); border-radius: 16px;
    width: 90%; max-width: 600px; max-height: 85vh;
    overflow-y: auto;
}
.modal-lg { max-width: 800px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 24px; }

.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 0.9rem; color: var(--text-light); margin-bottom: 8px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { font-size: 0.75rem; color: var(--text-light); display: block; }
.detail-item value, .detail-item .val { font-weight: 600; font-size: 0.95rem; }
.sensor-chart-wrap { margin-top: 16px; }
.ai-recommendation {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border-radius: 12px; padding: 16px; margin-top: 16px;
}
.ai-recommendation h4 { color: var(--primary); margin-bottom: 8px; }
.ai-recommendation p { font-size: 0.9rem; line-height: 1.6; }
.ai-recommendation .action-btn { margin-top: 12px; }

/* DISPATCH */
.dispatch-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 24px; }
.dispatch-map {
    background: var(--card); border-radius: 12px; padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    min-height: 450px;
}
.map-container { position: relative; width: 100%; }
#mapSvg { width: 100%; height: 400px; background: #f0f7ff; border-radius: 8px; }
.map-legend {
    display: flex; gap: 16px; margin-top: 8px; font-size: 0.8rem; color: var(--text-light);
    align-items: center;
}
.map-legend span { display: flex; align-items: center; gap: 4px; }
.route-line { width: 20px; height: 2px; background: var(--primary-light); display: inline-block; border-top: 2px dashed var(--primary-light); }

.dispatch-panel {
    background: var(--card); border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.dispatch-panel h3 { font-size: 1rem; margin-bottom: 16px; }
.badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-light); color: white;
    width: 24px; height: 24px; border-radius: 50%; font-size: 0.8rem;
    margin-left: 4px;
}
.dispatch-list { max-height: 320px; overflow-y: auto; margin-bottom: 16px; }
.dispatch-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 8px; margin-bottom: 6px;
    background: #f8fafc; font-size: 0.85rem;
    transition: background 0.2s;
}
.dispatch-item:hover { background: #eef2ff; }
.dispatch-priority {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dispatch-priority.high { background: var(--danger); }
.dispatch-priority.medium { background: var(--warning); }
.dispatch-priority.low { background: var(--success); }
.dispatch-info { flex: 1; }
.dispatch-info strong { display: block; font-size: 0.85rem; }
.dispatch-info small { color: var(--text-light); }
.dispatch-time { font-size: 0.8rem; color: var(--text-light); white-space: nowrap; }

.dispatch-summary {
    border-top: 1px solid var(--border); padding-top: 12px;
}
.summary-item {
    display: flex; justify-content: space-between; padding: 6px 0;
    font-size: 0.9rem;
}
.summary-item.optimized {
    color: var(--success); font-weight: 600;
    background: #f0fdf4; padding: 8px; border-radius: 8px; margin-top: 8px;
}

.engineer-section {
    background: var(--card); border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.engineer-section h3 { margin-bottom: 16px; }
.engineer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.engineer-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; border-radius: 10px; background: #f8fafc;
}
.eng-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--primary-light); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem;
}
.eng-info { flex: 1; }
.eng-name { font-weight: 600; font-size: 0.9rem; }
.eng-status { font-size: 0.8rem; }
.eng-status.active { color: var(--success); }
.eng-status.busy { color: var(--warning); }
.eng-tasks { font-size: 0.75rem; color: var(--text-light); }

/* CHATBOT */
.chatbot-layout { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; }
.chatbot-info h2 { margin-bottom: 12px; }
.chatbot-info p { color: var(--text-light); margin-bottom: 20px; line-height: 1.7; }
.chatbot-stats { display: flex; gap: 20px; margin-bottom: 24px; }
.cb-stat {
    background: var(--card); border-radius: 12px; padding: 16px 20px; flex: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); text-align: center;
}
.cb-stat-value { display: block; font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.cb-stat-label { font-size: 0.8rem; color: var(--text-light); }
.quick-scenarios h4 { margin-bottom: 12px; font-size: 0.9rem; }
.scenario-btn {
    display: inline-block; padding: 8px 16px; margin: 4px;
    border: 1px solid var(--border); border-radius: 20px;
    background: white; cursor: pointer; font-size: 0.85rem;
    transition: all 0.2s;
}
.scenario-btn:hover { border-color: var(--primary-light); color: var(--primary-light); background: #eff6ff; }

.chatbot-window {
    background: var(--card); border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    display: flex; flex-direction: column;
    height: 550px;
}
.chat-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: white; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.online-status { color: var(--success); display: block; font-size: 0.75rem; }

.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
}
.chat-msg { display: flex; gap: 10px; max-width: 85%; animation: msgIn 0.3s; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
}
.chat-msg.bot .msg-avatar { background: linear-gradient(135deg, var(--primary-light), var(--accent)); color: white; }
.chat-msg.user .msg-avatar { background: #e2e8f0; color: var(--text-light); }
.msg-content {
    padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; line-height: 1.6;
}
.chat-msg.bot .msg-content { background: #f1f5f9; border-bottom-left-radius: 4px; }
.chat-msg.user .msg-content { background: var(--primary-light); color: white; border-bottom-right-radius: 4px; }
.msg-content p { margin-bottom: 4px; }
.msg-content ul { margin: 8px 0; padding-left: 16px; }
.msg-content li { margin-bottom: 4px; }
.msg-content .action-buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.msg-content .action-btn {
    padding: 6px 14px; border-radius: 6px; font-size: 0.8rem;
    border: 1px solid var(--primary-light); color: var(--primary-light);
    background: white; cursor: pointer; transition: all 0.2s;
}
.msg-content .action-btn:hover { background: var(--primary-light); color: white; }

.typing-indicator {
    display: flex; gap: 4px; padding: 12px 16px;
}
.typing-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #94a3b8;
    animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

.chat-input-area {
    display: flex; gap: 8px; padding: 16px 20px;
    border-top: 1px solid var(--border);
}
#chatInput {
    flex: 1; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: 24px; font-size: 0.9rem; outline: none;
    font-family: inherit;
}
#chatInput:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
#chatSend {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary-light); color: white; border: none;
    cursor: pointer; font-size: 1rem;
    transition: background 0.2s;
}
#chatSend:hover { background: var(--primary); }

/* PARTS */
.parts-overview {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}
.filter-group { display: flex; gap: 10px; align-items: center; }
.filter-group select {
    padding: 10px 16px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; font-family: inherit;
    background: white; cursor: pointer;
}

.parts-table-wrapper {
    background: var(--card); border-radius: 12px; padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.parts-table-wrapper h3 { margin-bottom: 16px; }
.parts-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.parts-table th {
    text-align: left; padding: 12px; background: #f8fafc;
    color: var(--text-light); font-weight: 500; border-bottom: 2px solid var(--border);
}
.parts-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.parts-table tr:hover { background: #f8fafc; }
.status-badge {
    padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 500;
}
.status-badge.danger { background: #fee2e2; color: #991b1b; }
.status-badge.warning { background: #fef3c7; color: #92400e; }
.status-badge.ok { background: #d1fae5; color: #065f46; }
.order-btn {
    padding: 4px 12px; border-radius: 6px; font-size: 0.8rem;
    background: var(--primary-light); color: white; border: none;
    cursor: pointer;
}
.order-btn:hover { background: var(--primary); }

/* REPORTS */
.report-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.report-card {
    background: var(--card); border-radius: 12px; padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.2s;
}
.report-card:hover { transform: translateY(-2px); }
.report-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: #dbeafe; color: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: 16px;
}
.report-icon.orange { background: #fef3c7; color: var(--warning); }
.report-icon.green { background: #d1fae5; color: var(--success); }
.report-icon.purple { background: #ede9fe; color: var(--purple); }
.report-card h3 { margin-bottom: 8px; font-size: 1rem; }
.report-card p { font-size: 0.85rem; color: var(--text-light); margin-bottom: 16px; }
.report-meta { display: flex; justify-content: space-between; align-items: center; }
.report-meta span { font-size: 0.8rem; color: var(--text-light); }

.report-generating { text-align: center; padding: 40px; }
.spinner {
    width: 40px; height: 40px; border: 4px solid #e2e8f0;
    border-top-color: var(--primary-light); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.report-content h4 { margin: 16px 0 8px; color: var(--primary); }
.report-content p { margin-bottom: 8px; line-height: 1.7; font-size: 0.9rem; }
.report-content .metric-row {
    display: flex; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}

/* Nav Divider */
.nav-divider {
    padding: 16px 24px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 8px;
}

/* Search Input */
.search-input {
    padding: 10px 16px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; font-family: inherit;
    background: white; min-width: 200px;
}
.search-input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* Customer Table */
.customer-table-wrapper {
    background: var(--card); border-radius: 12px; padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow-x: auto;
}
.customer-table td .ai-score {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 600; font-size: 0.85rem;
}
.ai-score .score-bar { width: 60px; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.ai-score .score-fill { height: 100%; border-radius: 3px; }
.detail-btn {
    padding: 4px 12px; border-radius: 6px; font-size: 0.8rem;
    background: transparent; border: 1px solid var(--border);
    cursor: pointer; transition: all 0.2s;
}
.detail-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.customer-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.customer-tag {
    padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 500;
    background: #eff6ff; color: var(--primary-light);
}
.customer-tag.upsell { background: #fef3c7; color: #92400e; }
.customer-tag.renew { background: #fee2e2; color: #991b1b; }

/* Sales AI Cards */
.sales-ai-cards {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px;
}
.sales-section {
    background: var(--card); border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.sales-section h3 {
    font-size: 1rem; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.sales-section h3 i { color: var(--primary-light); }

.opportunity-card {
    padding: 14px; border-radius: 10px; background: #f8fafc;
    margin-bottom: 10px; cursor: pointer; transition: all 0.2s;
    border-left: 4px solid var(--accent);
}
.opportunity-card:hover { background: #eff6ff; transform: translateX(4px); }
.opp-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 6px; }
.opp-customer { font-weight: 600; font-size: 0.95rem; }
.opp-value { font-weight: 700; color: var(--primary); font-size: 0.9rem; }
.opp-reason { font-size: 0.85rem; color: var(--text-light); margin-bottom: 8px; }
.opp-confidence {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; padding: 3px 10px; border-radius: 20px;
    background: #dbeafe; color: var(--primary);
}
.opp-actions { display: flex; gap: 6px; margin-top: 10px; }
.opp-action-btn {
    padding: 5px 12px; border-radius: 6px; font-size: 0.78rem;
    border: 1px solid var(--border); background: white; cursor: pointer;
    transition: all 0.2s;
}
.opp-action-btn:hover { background: var(--primary-light); color: white; border-color: var(--primary-light); }
.opp-action-btn.primary { background: var(--primary-light); color: white; border-color: var(--primary-light); }

.churn-card {
    padding: 14px; border-radius: 10px; background: #fef2f2;
    margin-bottom: 10px; border-left: 4px solid var(--danger);
}
.churn-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.churn-customer { font-weight: 600; }
.churn-risk { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; background: #fee2e2; color: #991b1b; }
.churn-signals { font-size: 0.85rem; color: var(--text-light); }
.churn-signals li { margin-bottom: 2px; }
.churn-action { margin-top: 10px; }

/* Activity Timeline */
.activity-timeline { position: relative; padding-left: 24px; }
.activity-timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item {
    position: relative; padding: 12px 0 12px 16px;
    font-size: 0.85rem;
}
.timeline-item::before {
    content: ''; position: absolute; left: -20px; top: 18px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary-light); border: 2px solid white;
}
.timeline-item.visit::before { background: var(--success); }
.timeline-item.call::before { background: var(--warning); }
.timeline-item.email::before { background: var(--accent); }
.timeline-date { font-size: 0.75rem; color: var(--text-light); }
.timeline-content strong { display: block; margin-bottom: 2px; }
.timeline-content p { color: var(--text-light); }

/* Kanban Board */
.pipeline-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}
.kanban-board {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 12px; min-height: 500px;
}
.kanban-col {
    background: #f1f5f9; border-radius: 12px; padding: 12px;
    min-height: 400px;
}
.kanban-col.won { background: #f0fdf4; }
.kanban-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 4px; margin-bottom: 12px; font-weight: 600; font-size: 0.9rem;
}
.kanban-count {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary-light); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
    background: white; border-radius: 10px; padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer; transition: all 0.2s;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.kanban-card-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.kanban-card-info { font-size: 0.78rem; color: var(--text-light); margin-bottom: 4px; }
.kanban-card-amount { font-weight: 700; color: var(--primary); font-size: 0.9rem; }
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.kanban-card-date { font-size: 0.72rem; color: var(--text-light); }
.kanban-card-prob {
    padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600;
}
.prob-high { background: #d1fae5; color: #065f46; }
.prob-mid { background: #fef3c7; color: #92400e; }
.prob-low { background: #fee2e2; color: #991b1b; }

/* AI Doc Search */
.page-desc { color: var(--text-light); margin-bottom: 20px; line-height: 1.6; }
.doc-search-box {
    background: var(--card); border-radius: 16px; padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); margin-bottom: 24px;
}
.doc-search-input-wrap {
    display: flex; align-items: center; gap: 12px;
    background: #f8fafc; border: 2px solid var(--border);
    border-radius: 12px; padding: 8px 16px;
    transition: border-color 0.2s;
}
.doc-search-input-wrap:focus-within { border-color: var(--primary-light); }
.doc-search-input-wrap i { color: var(--text-light); font-size: 1.1rem; }
.doc-search-input-wrap input {
    flex: 1; border: none; background: transparent; font-size: 1rem;
    font-family: inherit; outline: none; padding: 8px 0;
}
.doc-search-input-wrap .btn { white-space: nowrap; }
.doc-search-tags {
    display: flex; align-items: center; gap: 8px; margin-top: 14px;
    flex-wrap: wrap;
}
.doc-search-tags > span { font-size: 0.8rem; color: var(--text-light); white-space: nowrap; }
.tag-btn {
    padding: 5px 14px; border-radius: 20px; font-size: 0.8rem;
    border: 1px solid var(--border); background: white; cursor: pointer;
    transition: all 0.2s; white-space: nowrap;
}
.tag-btn:hover { background: #eff6ff; border-color: var(--primary-light); color: var(--primary-light); }

.doc-results { margin-bottom: 24px; }
.doc-results-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.doc-results-header h3 { font-size: 1rem; }
.doc-results-header span { font-weight: 400; color: var(--text-light); font-size: 0.9rem; }
.doc-sort select {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.85rem; font-family: inherit; background: white;
}

.doc-result-item {
    background: var(--card); border-radius: 10px; padding: 18px;
    margin-bottom: 10px; display: flex; gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer; transition: all 0.2s;
}
.doc-result-item:hover { transform: translateX(4px); box-shadow: 0 3px 12px rgba(0,0,0,0.1); }
.doc-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.doc-icon.pptx { background: #fef3c7; color: #d97706; }
.doc-icon.pdf { background: #fee2e2; color: #dc2626; }
.doc-icon.xlsx { background: #d1fae5; color: #059669; }
.doc-icon.docx { background: #dbeafe; color: #2563eb; }
.doc-result-info { flex: 1; }
.doc-result-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.doc-result-excerpt { font-size: 0.83rem; color: var(--text-light); margin-bottom: 6px; line-height: 1.5; }
.doc-result-excerpt mark { background: #fef08a; padding: 1px 2px; border-radius: 2px; }
.doc-result-meta {
    display: flex; gap: 16px; font-size: 0.75rem; color: #94a3b8;
}
.doc-relevance {
    padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
    background: #dbeafe; color: var(--primary); white-space: nowrap;
}

.doc-ai-summary {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border-radius: 12px; padding: 20px; margin-bottom: 24px;
}
.ai-summary-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
    color: var(--primary);
}
.ai-summary-header h4 { margin: 0; }
#docAiSummaryContent { font-size: 0.9rem; line-height: 1.7; }
#docAiSummaryContent p { margin-bottom: 8px; }
#docAiSummaryContent ul { padding-left: 18px; margin: 8px 0; }
#docAiSummaryContent li { margin-bottom: 4px; }

.doc-categories { margin-top: 24px; }
.doc-categories h3 { margin-bottom: 16px; }
.doc-cat-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
.doc-cat-card {
    background: var(--card); border-radius: 12px; padding: 20px;
    text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer; transition: all 0.2s;
}
.doc-cat-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.doc-cat-card i { font-size: 2rem; color: var(--primary-light); display: block; margin-bottom: 10px; }
.doc-cat-card strong { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.doc-cat-card span { font-size: 0.8rem; color: var(--text-light); }

/* BIZCARD */
.bizcard-view-toggle {
    display: flex; gap: 4px; margin-bottom: 16px;
}
.toggle-btn {
    width: 36px; height: 36px; border: 1px solid var(--border);
    background: white; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-light); transition: all 0.2s;
}
.toggle-btn.active { background: var(--primary-light); color: white; border-color: var(--primary-light); }

.bizcard-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}
.bizcard-item {
    background: var(--card); border-radius: 12px; padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex; gap: 14px; cursor: pointer;
    transition: all 0.2s; position: relative;
    border-left: 4px solid var(--primary-light);
}
.bizcard-item:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.bizcard-item.linked { border-left-color: var(--success); }
.bizcard-item.new { border-left-color: var(--warning); }
.bizcard-avatar {
    width: 50px; height: 50px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.bizcard-info { flex: 1; min-width: 0; }
.bizcard-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.bizcard-company { font-size: 0.85rem; color: var(--text-light); }
.bizcard-title { font-size: 0.8rem; color: var(--text-light); }
.bizcard-meta {
    display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.bizcard-tag {
    padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 500;
}
.bizcard-tag.linked { background: #d1fae5; color: #065f46; }
.bizcard-tag.new { background: #fef3c7; color: #92400e; }
.bizcard-tag.keyp { background: #dbeafe; color: var(--primary); }
.bizcard-date { font-size: 0.72rem; color: #94a3b8; position: absolute; top: 12px; right: 14px; }

/* Scan */
.scan-area { min-height: 200px; }
.scan-dropzone {
    border: 2px dashed var(--border); border-radius: 12px;
    padding: 48px; text-align: center; color: var(--text-light);
    cursor: pointer; transition: all 0.2s;
}
.scan-dropzone:hover { border-color: var(--primary-light); background: #f8fafc; }
.scan-dropzone i { font-size: 3rem; margin-bottom: 12px; color: var(--primary-light); display: block; }
.scan-progress-wrap { margin-bottom: 20px; }
.scan-extracted {
    background: #f8fafc; border-radius: 12px; padding: 20px;
}
.scan-card-preview {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    margin-bottom: 16px;
}
.scan-field { margin-bottom: 8px; }
.scan-field label { font-size: 0.75rem; color: var(--text-light); display: block; margin-bottom: 2px; }
.scan-field .val { font-weight: 600; font-size: 0.95rem; }
.scan-field input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.scan-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.scan-ai-match {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border-radius: 10px; padding: 14px; margin-top: 16px;
}
.scan-ai-match h4 { color: var(--primary); margin-bottom: 6px; font-size: 0.9rem; }
.scan-ai-match p { font-size: 0.85rem; }

/* FOLLOWUP */
.followup-ai-panel {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.followup-ai-panel .ai-summary-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#followupAiContent { font-size: 0.9rem; line-height: 1.7; }
#followupAiContent .ai-followup-item {
    background: white; border-radius: 10px; padding: 14px; margin-bottom: 10px;
    display: flex; gap: 12px; align-items: start;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#followupAiContent .ai-followup-icon {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
}
#followupAiContent .ai-followup-icon.email { background: #dbeafe; color: var(--primary-light); }
#followupAiContent .ai-followup-icon.call { background: #fef3c7; color: var(--warning); }
#followupAiContent .ai-followup-icon.visit { background: #d1fae5; color: var(--success); }
#followupAiContent .ai-followup-text { flex: 1; }
#followupAiContent .ai-followup-text strong { display: block; margin-bottom: 2px; }
#followupAiContent .ai-followup-text p { color: var(--text-light); font-size: 0.85rem; margin: 0; }

.followup-list-wrap {
    background: var(--card); border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.followup-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; border-radius: 10px; margin-bottom: 8px;
    transition: all 0.2s; cursor: pointer;
    border-left: 4px solid transparent;
}
.followup-item:hover { background: #f8fafc; }
.followup-item.overdue { border-left-color: var(--danger); background: #fef2f2; }
.followup-item.today { border-left-color: var(--warning); background: #fffbeb; }
.followup-item.scheduled { border-left-color: var(--primary-light); }
.followup-item.done { border-left-color: var(--success); opacity: 0.7; }

.followup-check {
    width: 22px; height: 22px; border: 2px solid var(--border);
    border-radius: 50%; flex-shrink: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.followup-check:hover { border-color: var(--success); }
.followup-check.checked { background: var(--success); border-color: var(--success); color: white; }

.followup-type-icon {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}
.followup-type-icon.email { background: #dbeafe; color: var(--primary-light); }
.followup-type-icon.call { background: #fef3c7; color: var(--warning); }
.followup-type-icon.visit { background: #d1fae5; color: var(--success); }
.followup-type-icon.task { background: #ede9fe; color: var(--purple); }

.followup-content { flex: 1; min-width: 0; }
.followup-content strong { font-size: 0.9rem; display: block; }
.followup-content .followup-desc { font-size: 0.83rem; color: var(--text-light); margin-top: 2px; }
.followup-customer-tag {
    padding: 2px 8px; border-radius: 10px; font-size: 0.72rem;
    background: #f1f5f9; color: var(--text-light); margin-top: 4px; display: inline-block;
}
.followup-right {
    text-align: right; flex-shrink: 0; min-width: 100px;
}
.followup-date { font-size: 0.82rem; font-weight: 600; }
.followup-date.overdue { color: var(--danger); }
.followup-date.today { color: var(--warning); }
.followup-person { font-size: 0.75rem; color: var(--text-light); }

.followup-detail-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.followup-detail-actions .btn { font-size: 0.85rem; }
.ai-email-draft {
    background: #f8fafc; border-radius: 10px; padding: 16px; margin-top: 16px;
    font-size: 0.9rem; line-height: 1.7; white-space: pre-line;
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1024px) {
    .sales-ai-cards { grid-template-columns: 1fr; }
    .kanban-board { grid-template-columns: repeat(3, 1fr); }
    .pipeline-stats { grid-template-columns: repeat(2, 1fr); }
    .bizcard-grid { grid-template-columns: 1fr; }
    .stats-grid, .parts-overview { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .chart-card.wide { grid-column: 1; }
    .dispatch-layout { grid-template-columns: 1fr; }
    .chatbot-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid, .parts-overview { grid-template-columns: 1fr; }
    .engineer-grid { grid-template-columns: 1fr; }
}
