* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }
.app { min-height: 100vh; }

/* Header */
.header { background: #1a73e8; color: #fff; padding: 12px 24px; }
.header h1 { font-size: 20px; font-weight: 600; }

/* Main Layout */
.main { display: flex; gap: 16px; padding: 16px; max-width: 1600px; margin: 0 auto; }
.panel-input { flex: 0 0 380px; min-width: 340px; }
.panel-viz { flex: 1; min-width: 0; }

/* Cards */
.card { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card h2 { font-size: 15px; margin-bottom: 12px; color: #1a73e8; }

/* Vehicle Info */
.vehicle-info { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.vehicle-info .volume { color: #666; }

/* Item List */
.item-list { max-height: 300px; overflow-y: auto; margin-bottom: 12px; }
.item-list .empty { color: #999; font-style: italic; padding: 12px 0; }
.item-summary { background: #e3f2fd; padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; font-size: 12px; color: #1565c0; }
.item-entry { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid #e0e0e0; border-radius: 6px; margin-bottom: 6px; background: #fafafa; }
.item-entry .color-dot { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.item-entry .item-info { flex: 1; font-size: 12px; }
.item-entry .item-info strong { font-size: 13px; }
.item-entry .item-meta { color: #666; }
.item-entry .btn-del { background: none; border: none; color: #e53935; cursor: pointer; font-size: 16px; padding: 4px; }
.item-entry .btn-edit { background: none; border: none; color: #1a73e8; cursor: pointer; font-size: 14px; padding: 4px; }
.item-entry .btn-edit:hover { color: #0d47a1; }
.item-entry .btn-del:hover { color: #c62828; }
.item-actions { display: flex; gap: 4px; align-items: center; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background 0.2s; }
.btn-add { background: #4caf50; color: #fff; width: 100%; }
.btn-add:hover { background: #43a047; }
.btn-calc { background: #1a73e8; color: #fff; width: 100%; padding: 12px; font-size: 15px; }
.btn-calc:hover { background: #1557b0; }
.btn-clear { background: #ff9800; color: #fff; width: 100%; }
.btn-clear:hover { background: #f57c00; }
.actions { display: flex; flex-direction: column; gap: 8px; }

/* Canvas */
.canvas-wrap { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden; position: relative; }
.canvas-wrap canvas { display: block; width: 100%; height: auto; }
.canvas-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 11px; }
.canvas-legend .legend-item { display: flex; align-items: center; gap: 4px; }
.canvas-legend .legend-dot { width: 12px; height: 12px; border-radius: 2px; }

/* Layer Tabs */
.layer-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.layer-tab { padding: 6px 14px; border: 2px solid #e0e0e0; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; background: #fff; transition: all 0.2s; }
.layer-tab:hover { border-color: #1a73e8; color: #1a73e8; }
.layer-tab.active { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.layer-info { font-size: 12px; color: #666; padding: 4px 0; }

/* Results */
#results { font-size: 13px; }
.result-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
.result-row:last-child { border-bottom: none; }
.result-row .label { color: #666; }
.result-row .value { font-weight: 600; }
.result-fit { color: #4caf50; font-size: 18px; font-weight: 700; text-align: center; padding: 12px; }
.result-overflow { color: #e53935; font-size: 18px; font-weight: 700; text-align: center; padding: 12px; }
.overflow-list { background: #fff3e0; padding: 8px 12px; border-radius: 6px; margin-top: 8px; font-size: 12px; }
.highlight-info { background: #e3f2fd; padding: 6px 8px; border-radius: 4px; margin: 2px 0; }
.highlight-info .label { color: #1565c0; font-weight: 600; }
.highlight-info .value { color: #0d47a1; font-weight: 700; }
.highlight-remain { background: #fff8e1; padding: 6px 8px; border-radius: 4px; margin: 2px 0; }
.highlight-remain .label { color: #f57f17; font-weight: 600; }
.highlight-remain .value { color: #e65100; font-weight: 700; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: #fff; border-radius: 12px; padding: 24px; width: 400px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-bottom: 16px; color: #1a73e8; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; font-weight: 600; }
.form-group input, .form-group select { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-row { display: flex; gap: 16px; margin-bottom: 12px; font-size: 13px; }
.form-row label { display: flex; align-items: center; gap: 4px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* Responsive */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .panel-input { flex: none; width: 100%; }
}

/* Cảnh báo khi phương án chưa được lưu vào database (vd: api.php lỗi). */
.save-warning {
  background: #fff4e5;
  border: 1px solid #f0b429;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0 0;
  color: #7a4b00;
  font-size: 13px;
  line-height: 1.5;
}
