/* ===== Reset & Variables ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a5632;
  --primary-light: #2d7a4a;
  --primary-dark: #0f3d22;
  --accent: #e8a820;
  --accent-light: #f5c94d;
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --sidebar-width: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.sidebar .subtitle {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 2px;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.nav-links a {
  display: block;
  padding: 10px 20px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.1);
  color: white;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.75rem;
  opacity: 0.5;
}

.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ===== Main Content ===== */
.content {
  margin-left: var(--sidebar-width);
  padding: 32px;
  flex: 1;
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
}

.view { display: none; }
.view.active { display: block; }

h2 {
  font-size: 1.6rem;
  margin-bottom: 24px;
  color: var(--primary-dark);
}

h3 {
  font-size: 1.2rem;
  margin: 24px 0 12px;
  color: var(--primary-dark);
}

/* ===== Dashboard Layout ===== */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dash-header h2 { margin-bottom: 0; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.dash-card-header h3 {
  margin: 0;
  font-size: 1rem;
}

.dash-link {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}

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

.dash-card .audit-list,
.dash-card .filter-bar {
  padding: 12px 20px;
}

.dash-card .filter-bar {
  padding-bottom: 0;
}

.dash-map-preview {
  height: 280px;
  background: #e2e8f0;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stats-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}

.stat-primary { border-top-color: var(--primary); }
.stat-warning { border-top-color: var(--warning); }
.stat-success { border-top-color: var(--success); }
.stat-info { border-top-color: #3b82f6; }
.stat-accent { border-top-color: var(--accent); }
.stat-danger { border-top-color: var(--danger); }

.stat-number {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Map ===== */
.audit-map {
  height: calc(100vh - 180px);
  min-height: 400px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  width: 100%;
}

/* Let map view use full width */
#view-map {
  max-width: none;
}

#view-map .dash-header {
  max-width: none;
}

/* ===== Schedule ===== */
.schedule-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
}

.schedule-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}

.schedule-tab.active {
  background: var(--primary);
  color: white;
}

.schedule-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.schedule-date-badge {
  min-width: 60px;
  text-align: center;
  padding: 8px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  line-height: 1.2;
}

.schedule-date-badge .sched-day {
  font-size: 1.4rem;
  font-weight: 700;
  display: block;
}

.schedule-date-badge .sched-month {
  font-size: 0.7rem;
  text-transform: uppercase;
  opacity: 0.8;
}

.schedule-date-badge.past {
  background: var(--text-muted);
}

.schedule-info {
  flex: 1;
}

.schedule-info h4 {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.schedule-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.schedule-actions {
  display: flex;
  gap: 6px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input,
.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--bg-card);
}

.search-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 140px; }

/* ===== Audit List ===== */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.audit-item:hover { box-shadow: var(--shadow-md); }

.audit-item-info h4 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.audit-item-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.audit-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-draft { background: #fef3c7; color: #92400e; }
.badge-completed { background: var(--success-light); color: var(--success); }

/* ===== Forms ===== */
.audit-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  background: var(--bg-card);
}

.audit-form legend {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--primary);
  padding: 0 8px;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.form-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,50,0.1);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

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

.btn-primary:hover { background: var(--primary-light); }

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

.btn-secondary:hover { background: var(--border); }

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

.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-record {
  background: var(--danger);
  color: white;
  min-width: 160px;
}

.btn-record:hover { background: #b91c1c; }

.btn-record.recording {
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Star Rating ===== */
.star-rating {
  display: flex;
  gap: 2px;
}

.star-rating .star {
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--border);
  transition: color 0.15s;
  font-size: 1.4rem;
  line-height: 1;
}

.star-rating .star.filled {
  color: var(--accent);
}

.star-rating .star:hover {
  color: var(--accent-light);
}

/* ===== Score Select ===== */
.score-select {
  max-width: 260px;
}

/* ===== Rating & Diagnostic Tables ===== */
.rating-table table,
.diagnostic-table table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.rating-table th,
.rating-table td,
.diagnostic-table th,
.diagnostic-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.rating-table th,
.diagnostic-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* ===== Projects ===== */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.project-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

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

.project-header h4 {
  font-size: 0.95rem;
  color: var(--primary);
}

/* ===== Recorder ===== */
.recorder-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 16px 0;
}

.recorder-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.recorder-timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
  color: var(--text);
}

.recorder-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== Transcription & AI Results ===== */
.transcription-result,
.ai-result {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  text-align: left;
}

.transcription-text {
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 12px;
  background: white;
  border-radius: var(--radius);
  margin: 8px 0 12px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.ai-result h4,
.transcription-result h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  margin: 16px 0;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(26,86,50,0.03);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.image-preview-area {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.image-preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview .remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Memo History ===== */
.memo-history {
  margin-top: 32px;
}

.memo-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.memo-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.memo-item-section {
  font-weight: 600;
  color: var(--primary);
}

.memo-item-date {
  color: var(--text-muted);
}

.memo-item-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Settings ===== */
.settings-form {
  max-width: 500px;
}

.settings-form .form-group {
  margin-bottom: 20px;
}

.settings-form hr {
  margin: 32px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

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

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body { padding: 20px; }

/* ===== Report Detail ===== */
.report-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.report-section h3 {
  margin-top: 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.report-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  table-layout: auto;
}

.report-table th,
.report-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  text-align: left;
  word-break: break-word;
}

.report-section {
  overflow-x: auto;
}

.report-table th {
  background: var(--bg);
  font-weight: 600;
}

.report-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

/* ===== Login Screen ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 420px;
  width: 90%;
}

.login-card h1 {
  color: var(--primary-dark);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.login-card > p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-card #googleSignInBtn {
  display: flex;
  justify-content: center;
  margin: 24px 0;
}

.login-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: var(--danger-light);
  border-radius: var(--radius);
  margin-top: 12px;
}

/* ===== User Info in Sidebar ===== */
.user-info {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-info .user-details {
  overflow: hidden;
}

.user-info .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-email {
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Energy Bills ===== */
.bill-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0;
}

.bill-upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.bill-upload-card h4 {
  margin-bottom: 4px;
  font-size: 0.95rem;
  color: var(--primary);
}

.bill-analysis .bill-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.bill-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bill-detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.bill-detail-card h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--primary);
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.bar-label {
  min-width: 55px;
  text-align: right;
  color: var(--text-muted);
}

.bar-track {
  flex: 1;
  height: 16px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.3s;
}

.bar-fill.bar-peak {
  background: var(--danger);
}

.bar-value {
  min-width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .bill-upload-grid {
    grid-template-columns: 1fr;
  }

  .bill-analysis .bill-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .bill-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Project Library ===== */
.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.lib-project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.lib-project-header strong {
  font-size: 0.92rem;
}

.lib-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.lib-project-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.lib-project-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.4;
}

.lib-project-meta {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lib-project-meta span {
  white-space: nowrap;
}

/* ===== Review Panel ===== */
.review-table input {
  transition: border-color 0.2s;
}

.review-table input:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(26,86,50,0.15);
}

.suggestion-project label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.suggestion-project input {
  transition: border-color 0.2s;
}

.suggestion-project input:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(26,86,50,0.15);
}

/* ===== Utility ===== */
.hidden { display: none !important; }

.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  z-index: 400;
  animation: slideUp 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

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

/* ===== Responsive ===== */
/* ===== Mobile / Tablet ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .menu-toggle { display: block; }

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

  .stats-grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .dash-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .audit-map {
    height: 350px;
  }

  .schedule-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .schedule-actions {
    width: 100%;
  }

  .schedule-actions .btn {
    flex: 1;
  }

  .content {
    margin-left: 0;
    padding: 12px;
    padding-top: 56px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row-4 {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-actions {
    flex-direction: column;
  }

  .section-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 14px 20px;
    font-size: 1rem;
  }

  .filter-bar {
    flex-direction: column;
  }

  .audit-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .report-actions {
    flex-wrap: wrap;
  }

  .report-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
  }

  .report-table {
    font-size: 0.75rem;
  }

  .report-table th,
  .report-table td {
    padding: 4px 6px;
  }

  .review-table th,
  .review-table td {
    padding: 6px !important;
    font-size: 0.8rem !important;
  }

  .suggestion-project {
    padding: 12px !important;
  }

  .suggestion-project > div:last-child {
    grid-template-columns: 1fr !important;
  }

  .btn-record {
    padding: 16px 24px;
    font-size: 1.1rem;
  }

  #modalTranscriptArea {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  .upload-zone {
    padding: 24px 16px;
  }

  h2 {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .form-row-4 {
    grid-template-columns: 1fr;
  }

  .recorder-controls {
    flex-direction: column;
  }

  .recorder-controls .btn {
    width: 100%;
  }

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

  .stat-card {
    padding: 14px;
  }

  .stat-number {
    font-size: 1.5rem;
  }
}

/* ===== Touch-friendly ===== */
@media (pointer: coarse) {
  .star-rating .star {
    width: 36px;
    height: 36px;
    font-size: 1.8rem;
  }

  .btn {
    min-height: 44px;
  }

  .nav-links a {
    padding: 14px 20px;
  }

  .score-select {
    min-height: 44px;
  }
}

/* ===== Standalone PWA mode ===== */
@media (display-mode: standalone) {
  .content {
    padding-top: max(env(safe-area-inset-top, 0px), 16px);
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 16px);
  }

  .sidebar {
    padding-top: env(safe-area-inset-top, 0px);
  }

  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}
