/* ─── Base ─── */
* {
  box-sizing: border-box;
}
:root {
  --primary: #1a3a6b;
  --primary-light: #2a5a9b;
  --primary-dark: #0f2847;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --gray-100: #f8f9fc;
  --gray-200: #e9edf4;
  --gray-300: #d0d8e3;
  --gray-400: #9aa8b9;
  --gray-500: #6b7a8f;
  --gray-600: #3d4a5f;
  --gray-700: #1e2a3a;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  --transition: 0.25s ease;
  --sidebar-bg: #dce8f5;
  --sidebar-hover: #c5d7eb;
  --header-common: #e3edf7;
  --header-comfort: #f0e6f7;
  --header-loading: #e6f3ed;
  --header-offices: #f7eee6;
  --header-facilities: #e6f0f7;
  --header-electrical: #f7e6e6;
  --header-roof: #edf7e6;
  --header-perimeter: #f7f0e6;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: #f0f4fa;
  margin: 0;
  padding: 0;
  color: #1a2a3a;
  line-height: 1.5;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #e9edf4;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: #b0bcca;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #9aa8b9;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--sidebar-bg);
  background: linear-gradient(180deg, #dce8f5 0%, #c5d7eb 100%);
  border-right: 1px solid rgba(26, 58, 107, 0.12);
  padding: 0 0 1rem 0;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
  box-shadow: 2px 0 16px rgba(26, 58, 107, 0.1);
}
.sidebar-header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(26, 58, 107, 0.1);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 0 0 12px 0;
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}
.sidebar-header span {
  font-size: 0.65rem;
  color: var(--gray-600);
  background: rgba(255, 255, 255, 0.6);
  padding: 0.1rem 0.6rem;
  border-radius: 10px;
  display: inline-block;
  margin-top: 0.2rem;
}
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
}
.nav-section-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  padding: 0.5rem 0.75rem 0.25rem;
  font-weight: 700;
  opacity: 0.7;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  margin: 1px 0;
  background: transparent;
}
.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--primary-dark);
}
.nav-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(26, 58, 107, 0.25);
}
.nav-link .nav-icon {
  font-size: 1rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(26, 58, 107, 0.08);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
}
.mobile-toggle {
  width: 100%;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--gray-600);
  cursor: pointer;
}
.mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* ─── Mobile menu button ─── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1001;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.mobile-menu-btn:hover {
  background: var(--primary-dark);
}

/* ─── Main content ─── */
.main-content {
  margin-left: 240px;
  padding: 1.5rem 2rem 3rem;
  min-height: 100vh;
}
.container {
  max-width: 1300px;
  margin: 0 auto;
}

/* ─── Brand header ─── */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border: 1px solid var(--gray-200);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.brand-header .brand-text h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}
.brand-header .brand-text p {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--gray-500);
}
.brand-header .brand-logo img {
  height: 40px;
  width: auto;
  max-height: 52px;
  object-fit: contain;
}

/* ─── View sections ─── */
.view-section {
  display: none;
}
.view-section.active {
  display: block;
}

/* ─── Cards ─── */
.card {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--gray-200);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ─── History grid ─── */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}
.history-grid .action-group {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.history-grid .action-group .action-btn-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
}
.history-grid .action-group .action-btn-group .btn {
  white-space: nowrap;
  flex: 0 1 auto;
}

/* ─── Form grid ─── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.form-group label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--gray-500);
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  transition:
    border var(--transition),
    box-shadow var(--transition);
  width: 100%;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.12);
}
.form-group input:disabled {
  background: var(--gray-100);
  opacity: 0.7;
}

.action-btn-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
}
.action-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: #fff;
  background: var(--gray-400);
  line-height: 1.3;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary {
  background: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-light);
}
.btn-success {
  background: var(--success);
}
.btn-success:hover {
  background: #218838;
}
.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #c82333;
}
.btn-warning {
  background: var(--warning);
  color: #1a2a3a;
}
.btn-warning:hover {
  background: #e0a800;
}
.btn-info {
  background: var(--info);
}
.btn-info:hover {
  background: #138496;
}
.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-600);
}
.btn-secondary:hover {
  background: var(--gray-300);
}
.btn-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
}
.btn-save {
  background: var(--success) !important;
  border-color: var(--success) !important;
}
.btn-save:hover {
  background: #218838 !important;
  border-color: #1e7e34 !important;
}

/* ─── Areas / Tables ─── */
.area {
  margin-bottom: 2rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.area h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  color: var(--gray-700);
}
.area .area-badge {
  font-size: 0.6rem;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.5);
  color: var(--gray-600);
  padding: 0.05rem 0.6rem;
  border-radius: 10px;
}
/* Area header backgrounds */
.area-common-area h2 {
  background: var(--header-common);
}
.area-comfort-rooms h2 {
  background: var(--header-comfort);
}
.area-loading-bay h2 {
  background: var(--header-loading);
}
.area-offices h2 {
  background: var(--header-offices);
}
.area-building-facilities h2 {
  background: var(--header-facilities);
}
.area-electrical-room h2 {
  background: var(--header-electrical);
}
.area-roof h2 {
  background: var(--header-roof);
}
.area-building-perimeter h2 {
  background: var(--header-perimeter);
}

.area table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  background: #fff;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.area table th {
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 600;
  padding: 0.4rem 0.4rem;
  text-align: left;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.area table td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
  background: #fff;
}
.area table tr:hover td {
  background: var(--gray-100);
}
.area table td input[type="radio"] {
  accent-color: var(--primary);
  transform: scale(1.05);
  cursor: pointer;
}
.area table td input[type="text"],
.area table td input[type="date"] {
  width: 100%;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.75rem;
  background: #fff;
  transition: border var(--transition);
}
.area table td input[type="text"]:focus,
.area table td input[type="date"]:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 2px rgba(26, 58, 107, 0.1);
}
.area table td input[type="text"]:disabled,
.area table td input[type="date"]:disabled {
  background: var(--gray-100);
  opacity: 0.6;
  cursor: not-allowed;
}

/* ─── Photo cell ─── */
.photo-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 70px;
}
.photo-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-600);
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
}
.photo-trigger:hover:not(:disabled) {
  background: var(--gray-200);
  border-color: var(--gray-400);
}
.photo-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
.photo-trigger .trigger-icon {
  font-size: 0.8rem;
}
.photo-trigger .trigger-text {
  font-size: 0.65rem;
}
.photo-trigger.uploading .trigger-text::after {
  content: " …";
  animation: dots 1s steps(4) infinite;
}
@keyframes dots {
  0% {
    content: " …";
  }
  25% {
    content: " ..";
  }
  50% {
    content: " .";
  }
  75% {
    content: "";
  }
  100% {
    content: " …";
  }
}

.photo-preview-wrapper {
  display: none;
  position: relative;
  margin-top: 2px;
  max-width: 60px;
  max-height: 60px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--gray-300);
  background: var(--gray-100);
}
.photo-preview-wrapper img {
  width: 100%;
  height: auto;
  max-height: 60px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}
.photo-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: var(--transition);
}
.photo-remove:hover {
  background: rgba(200, 0, 0, 0.85);
  transform: scale(1.1);
}
.photo-empty {
  font-size: 0.65rem;
  color: var(--gray-400);
}
.photo-url-hidden {
  display: none;
}
.photo-file-input {
  display: none;
}
.photo-cell.has-photo .photo-empty {
  display: none !important;
}
.photo-status {
  font-size: 0.55rem;
  color: var(--gray-500);
  margin-left: 0.2rem;
}

/* ─── Admin / unlock badges ─── */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  background: #d4edda;
  color: #155724;
  padding: 0.05rem 0.6rem;
  border-radius: 10px;
  font-weight: 500;
}
.admin-unlock-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 0.05rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  margin-left: 0.4rem;
}
.admin-unlock-indicator.unlocked {
  color: #155724;
  background: #d4edda;
  border-color: #c3e6cb;
}
.unlock-hint {
  font-size: 0.65rem;
  color: var(--gray-500);
  margin-left: 0.3rem;
  font-weight: 400;
  background: var(--gray-100);
  padding: 0.05rem 0.5rem;
  border-radius: 10px;
}

/* ─── Masked field ─── */
.masked-field {
  opacity: 0.55;
  pointer-events: none;
  filter: grayscale(0.25);
  position: relative;
}
.masked-field input,
.masked-field select,
.masked-field button {
  cursor: not-allowed;
  opacity: 0.6;
}
.masked-field .photo-trigger {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* ─── Share report header ─── */
.share-report-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border: 1px solid var(--gray-200);
  flex-wrap: wrap;
  gap: 0.75rem;
}
.share-report-header .report-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.share-report-header .report-title small {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 0.05rem 0.6rem;
  border-radius: 10px;
}
.share-report-header .report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--gray-600);
  margin-top: 0.2rem;
}
.share-report-header .report-meta span {
  background: var(--gray-100);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
}
body.share-mode .sidebar {
  display: none;
}
body.share-mode .main-content {
  margin-left: 0;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding: 1.5rem;
}

/* ─── Analysis / Summary ─── */
.analysis-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}
.analysis-filters .btn-group-wrap {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-self: end;
  padding-bottom: 0.1rem;
}
.analysis-filters .btn-group-wrap .btn-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
}
.analysis-filters .btn-group-wrap .btn-group .btn {
  white-space: nowrap;
  flex: 0 1 auto;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.summary-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-200);
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-card .label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--gray-500);
  font-weight: 500;
}
.summary-card .value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.1rem;
}
.summary-card .value.danger {
  color: var(--danger);
}
.summary-card .value.success {
  color: var(--success);
}

/* ─── Defect table ─── */
.defect-table-wrap {
  overflow-x: auto;
}
.defect-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.defect-table th {
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.defect-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
.defect-table tr:hover td {
  background: var(--gray-100);
}
.defect-table .img-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--gray-300);
  cursor: pointer;
  transition: var(--transition);
}
.defect-table .img-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.defect-table .img-placeholder {
  color: var(--gray-400);
  font-size: 0.7rem;
}
.defect-table .area-badge-sm {
  display: inline-block;
  background: var(--gray-100);
  padding: 0.05rem 0.5rem;
  border-radius: 10px;
  font-size: 0.65rem;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.defect-table .status-badge {
  display: inline-block;
  padding: 0.05rem 0.6rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
}
.defect-table .status-badge.defect {
  background: #f8d7da;
  color: #721c24;
}
.defect-table .col-updated {
  order: 1;
}
.defect-table .col-conducted {
  order: 2;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}
.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.empty-state h3 {
  margin: 0 0 0.25rem;
  color: var(--gray-600);
  font-weight: 600;
}
.empty-state p {
  margin: 0;
  color: var(--gray-500);
  font-size: 0.85rem;
}

/* ─── Print header ─── */
#print-header {
  display: none;
  text-align: center;
  padding: 1rem 0;
  border-bottom: 2px solid var(--gray-300);
  margin-bottom: 1rem;
}
#print-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--primary);
}
#print-header p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  0% {
    transform: scale(0.92) translateY(12px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}
.modal-title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-700);
}
.modal-text {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--gray-600);
  line-height: 1.5;
}
.modal-input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.modal-input:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.1);
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.share-link-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.share-link-box input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.8rem;
  background: var(--gray-100);
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}
.toast {
  background: #1a2a3a;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  transition:
    opacity 0.3s,
    transform 0.3s;
  transform: translateX(0);
  border-left: 4px solid var(--info);
}
.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.warning {
  border-left-color: var(--warning);
  color: #1a2a3a;
  background: #fff3cd;
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .main-content {
    padding: 1rem 1.25rem;
  }
  .area table {
    font-size: 0.7rem;
  }
  .area table th,
  .area table td {
    padding: 0.25rem 0.3rem;
  }
  .history-grid .action-group .action-btn-group {
    flex-wrap: wrap;
  }
  .analysis-filters .btn-group-wrap .btn-group {
    flex-wrap: wrap;
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }
  .mobile-menu-btn {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 0.75rem 0.75rem 2rem;
  }
  body.share-mode .main-content {
    padding: 0.75rem;
  }
  .brand-header {
    padding: 0.75rem 1rem;
  }
  .brand-header .brand-text h1 {
    font-size: 1.05rem;
  }
  .card {
    padding: 0.75rem 1rem;
  }
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
  .history-grid {
    grid-template-columns: 1fr 1fr;
  }
  .history-grid .action-group {
    grid-column: span 2;
  }
  .history-grid .action-group .action-btn-group {
    flex-wrap: nowrap;
  }
  .analysis-filters {
    grid-template-columns: 1fr 1fr;
  }
  .analysis-filters .btn-group-wrap {
    grid-column: span 2;
  }
  .analysis-filters .btn-group-wrap .btn-group {
    flex-wrap: nowrap;
  }
  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
  .area table {
    font-size: 0.65rem;
  }
  .area table th,
  .area table td {
    padding: 0.2rem 0.25rem;
  }
  .photo-trigger {
    padding: 0.15rem 0.4rem;
    font-size: 0.6rem;
  }
  .photo-preview-wrapper {
    max-width: 44px;
    max-height: 44px;
  }
  .photo-preview-wrapper img {
    max-height: 44px;
  }
  .share-report-header {
    padding: 0.75rem 1rem;
  }
  .share-report-header .report-title {
    font-size: 0.95rem;
  }
  .defect-table {
    font-size: 0.7rem;
  }
  .defect-table th,
  .defect-table td {
    padding: 0.25rem 0.3rem;
  }
  .defect-table .img-thumb {
    width: 32px;
    height: 32px;
  }
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .history-grid {
    grid-template-columns: 1fr;
  }
  .history-grid .action-group {
    grid-column: span 1;
  }
  .history-grid .action-group .action-btn-group {
    flex-wrap: wrap;
  }
  .analysis-filters {
    grid-template-columns: 1fr;
  }
  .analysis-filters .btn-group-wrap {
    grid-column: span 1;
  }
  .analysis-filters .btn-group-wrap .btn-group {
    flex-wrap: wrap;
  }
  .brand-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .brand-header .brand-logo {
    align-self: flex-end;
  }
  .btn-group {
    flex-wrap: wrap;
  }
  .btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.8rem;
  }
  .area table {
    font-size: 0.6rem;
  }
  .area table th,
  .area table td {
    padding: 0.15rem 0.2rem;
  }
  .area table td input[type="text"],
  .area table td input[type="date"] {
    font-size: 0.65rem;
    padding: 0.1rem 0.25rem;
  }
  .photo-trigger {
    padding: 0.1rem 0.3rem;
    font-size: 0.55rem;
  }
  .photo-preview-wrapper {
    max-width: 36px;
    max-height: 36px;
  }
  .photo-preview-wrapper img {
    max-height: 36px;
  }
  .photo-remove {
    width: 14px;
    height: 14px;
    font-size: 8px;
  }
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .summary-card .value {
    font-size: 1.1rem;
  }
  .share-report-header .report-meta {
    font-size: 0.65rem;
    gap: 0.3rem 0.6rem;
  }
  .modal {
    padding: 1rem;
  }
  .toast-container {
    max-width: 90%;
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }
  .toast {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
}

/* ─── Print styles ─── */
@media print {
  .no-print {
    display: none !important;
  }
  .sidebar {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0.5in !important;
    max-width: 100% !important;
  }
  .brand-header {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
  .area table {
    box-shadow: none !important;
  }
  .area table tr:hover td {
    background: #fff !important;
  }
  .photo-trigger {
    display: none !important;
  }
  .photo-remove {
    display: none !important;
  }
  .photo-preview-wrapper {
    border: 1px solid #ccc !important;
  }
  .admin-unlock-indicator,
  .unlock-hint,
  .admin-badge {
    display: none !important;
  }
  .defect-table .img-thumb {
    max-width: 60px;
    max-height: 60px;
  }
  #print-header {
    display: block !important;
  }
  .share-report-header {
    display: none !important;
  }
  body.share-mode .main-content {
    padding: 0.5in !important;
  }
}
