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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

.container { max-width: 960px; margin: 0 auto; padding: 20px; }

/* Header */
header {
  background: white; border-bottom: 1px solid var(--gray-200);
  padding: 12px 20px; display: flex; justify-content: space-between;
  align-items: center; position: sticky; top: 0; z-index: 100;
}
header h1 { font-size: 1.25rem; color: var(--primary); }
header .user-info { display: flex; align-items: center; gap: 12px; }
#btn-logout {
  background: none; border: 1px solid var(--gray-300); padding: 6px 12px;
  border-radius: var(--radius); cursor: pointer; font-size: 0.85rem;
}
#btn-logout:hover { background: var(--gray-100); }

/* Auth */
.auth-page {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; background: var(--gray-50);
}
.auth-card {
  background: white; padding: 40px; border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 100%; max-width: 400px;
}
.auth-card h2 { text-align: center; margin-bottom: 24px; }
.auth-card .tabs { display: flex; gap: 0; margin-bottom: 24px; }
.auth-card .tab {
  flex: 1; padding: 10px; text-align: center; cursor: pointer;
  border-bottom: 2px solid var(--gray-200); color: var(--gray-500);
  background: none; border-top: none; border-left: none; border-right: none; font-size: 1rem;
}
.auth-card .tab.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 0.9rem; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 0.95rem; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group .hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }

.btn {
  display: inline-block; padding: 10px 20px; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500; cursor: pointer; border: none;
  transition: all 0.2s; text-align: center;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-100); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 8px; }

/* Dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.property-list { display: grid; gap: 16px; }
.property-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); cursor: pointer;
  border: 1px solid var(--gray-200); transition: box-shadow 0.2s;
}
.property-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.property-card h3 { margin-bottom: 4px; }
.property-card .address { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 12px; }
.progress-bar { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.progress-text { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }

/* Steps */
.step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.step-header .step-num {
  background: var(--primary); color: white; width: 32px; height: 32px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.9rem; flex-shrink: 0;
}
.step-header h2 { font-size: 1.25rem; }
.step-description { color: var(--gray-500); margin-bottom: 20px; font-size: 0.95rem; }

/* Address lookup banner */
.address-banner {
  background: #ecfdf5; border: 1px solid #10b981; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 20px; display: flex; gap: 12px; align-items: flex-start;
}
.address-banner-icon {
  background: #10b981; color: white; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 0.85rem; flex-shrink: 0;
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--gray-300); border-radius: var(--radius);
  padding: 40px; text-align: center; cursor: pointer; transition: all 0.2s; background: white;
}
.upload-area:hover { border-color: var(--primary); background: rgba(37,99,235,0.02); }
.upload-area.dragover { border-color: var(--primary); background: rgba(37,99,235,0.05); }
.upload-area input { display: none; }
.upload-area p { color: var(--gray-500); margin-top: 8px; }

/* Floorplan canvas */
.floorplan-container {
  position: relative; background: white; border-radius: var(--radius);
  border: 1px solid var(--gray-200); overflow: hidden; margin-bottom: 16px;
}
.floorplan-container canvas { display: block; max-width: 100%; cursor: crosshair; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); display: flex; justify-content: center;
  align-items: center; z-index: 1000; padding: 16px;
}
.modal {
  background: white; border-radius: 12px; padding: 24px;
  max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-large { max-width: 680px; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* Room modal layout */
.room-modal-layout { display: flex; gap: 20px; flex-wrap: wrap; }
.room-modal-preview { flex: 0 0 200px; }
.room-modal-preview canvas { width: 100%; border-radius: var(--radius); border: 1px solid var(--gray-200); }
.room-modal-form { flex: 1; min-width: 240px; }

/* Wall step header */
.wall-step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.wall-step-header h3 { margin-bottom: 0; white-space: nowrap; }

/* Wall photo area */
.wall-photo-area {
  background: var(--gray-50); border: 2px dashed var(--gray-300);
  border-radius: var(--radius); padding: 32px; text-align: center;
}

/* Room labels on canvas */
.room-label {
  position: absolute; background: rgba(22,163,74,0.85); color: white;
  padding: 2px 8px; border-radius: 4px; font-size: 0.75rem;
  pointer-events: none; white-space: nowrap; transform: translate(-50%, -50%);
}

/* Wall chip */
.wall-chip {
  background: white; border: 1px solid var(--gray-200); padding: 6px 12px;
  border-radius: 20px; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 6px;
}
.wall-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

/* Element chips / checklist */
.element-chip {
  background: var(--gray-100); border: 1px solid var(--gray-200);
  padding: 3px 10px; border-radius: 12px; font-size: 0.8rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.element-checklist-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--gray-100); font-size: 0.9rem;
}
.element-checklist-item:last-child { border-bottom: none; }
.confidence-high { color: var(--success); }
.confidence-low { color: var(--warning); }
.btn-delete-el, .btn-delete-room-inline {
  background: none; border: none; cursor: pointer;
  color: var(--danger); font-weight: bold; font-size: 0.9rem; line-height: 1;
}

/* Room summary in modal */
.room-summary-card {
  background: var(--gray-50); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.room-summary-card h4 { font-size: 0.95rem; margin-bottom: 8px; }
.room-summary-stat { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 4px 0; }

/* Analysis */
.analysis-result {
  background: white; border-radius: var(--radius); padding: 24px;
  border: 1px solid var(--gray-200); white-space: pre-wrap; line-height: 1.8; font-size: 0.95rem;
}

/* Spinner */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.8); display: flex;
  justify-content: center; align-items: center; z-index: 10;
}

.boundary-hint {
  background: #fef3c7; border: 1px solid #f59e0b; padding: 12px 16px;
  border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .container { padding: 12px; }
  .auth-card { padding: 24px; }
  .modal { padding: 16px; }
  .room-modal-preview { flex: 0 0 100%; }
}
