.page-container {
  max-width: 1400px;
  margin: 0 auto;
}

.page-container.full-width {
  max-width: none;
  width: 100%;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #e2e8f0;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 1rem;
  color: #64748b;
  margin: 0;
  font-weight: 400;
}

.page-content {
  background: #ffffff;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-height: 400px;
  color: #1e293b;
  font-size: 1rem;
  overflow-y: scroll;
}

/* Date filter controls */
.date-filter-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.date-filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-filter-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.date-filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 200px;
}

.date-filter-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Unified card wrapper for the devices page */
.devices-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  color: #1e293b;
  font-size: 1rem;
}

/* Devices controls panel (separate from page-content so it never shifts) */
.devices-controls-panel {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid #e2e8f0;
}

/* page-content inside the devices card loses its own card styling */
.devices-card .page-content {
  background: none;
  box-shadow: none;
  border-radius: 0 0 8px 8px;
}

/* Table controls */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Search controls for Schedule page */
.search-controls {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-controls .search-input {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-controls .search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.clear-search-button {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.clear-search-button:hover {
  color: #374151;
}

/* Rooms controls */
.rooms-controls {
  margin-bottom: 1.5rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.controls-header {
  padding: 0;
}

.controls-toggle {
  width: 100%;
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.controls-toggle:hover {
  background: #e2e8f0;
}

.controls-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.search-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sort-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-section label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.sort-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sort-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-section {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #4b5563;
  cursor: pointer;
  padding: 0.25rem 0;
}

.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.action-section {
  display: flex;
  justify-content: flex-end;
}

.refresh-button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.refresh-button:hover:not(:disabled) {
  background: #2563eb;
}

.refresh-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.last-updated {
  font-size: 0.875rem;
  color: #64748b;
}

/* Messages */
.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.loading-message,
.empty-message {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
  font-size: 1rem;
}

/* Table container */
.table-container {
  overflow-x: auto;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
}

/* Device status table */
.device-status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.device-status-table thead {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.device-status-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none; /* Prevent text selection */
}

.device-status-table th:hover {
  background: #e2e8f0;
  color: #334155;
}

.device-status-table th.sortable-column {
  cursor: pointer;
}

.device-status-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: background 0.15s;
}

.device-status-table tbody tr:hover {
  background: #f8fafc;
}

.device-status-table td {
  padding: 0.75rem 1rem;
  color: #334155;
}

/* Schedule table */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.schedule-table thead {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.schedule-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none; /* Prevent text selection */
}

.schedule-table th:hover {
  background: #e2e8f0;
  color: #334155;
}

.schedule-table th.sortable-column {
  cursor: pointer;
}

.schedule-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: background 0.15s;
}

.schedule-table tbody tr:hover {
  background: #f8fafc;
}

.schedule-table td {
  padding: 0.75rem 1rem;
  color: #334155;
}

/* Specific column styles */
.device-status-table .serial-number {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: #1e293b;
}

.device-status-table .scan-count {
  text-align: center;
  font-weight: 600;
  color: #3b82f6;
}

.device-status-table .timestamp {
  font-family: 'Courier New', monospace;
  font-size: 0.8125rem;
  color: #64748b;
  white-space: nowrap;
}

/* Schedule table specific column styles */
.schedule-table .session-name {
  font-weight: 600;
  color: #1e293b;
}

.schedule-table .timestamp {
  font-family: 'Courier New', monospace;
  font-size: 0.8125rem;
  color: #64748b;
  white-space: nowrap;
}

.schedule-table .attendee-count {
  text-align: center;
  font-weight: 600;
  color: #059669;
}

.schedule-table .scan-count {
  text-align: center;
  font-weight: 600;
  color: #3b82f6;
}

/* Access status styling */
.access-status {
  font-weight: 500;
  text-transform: capitalize;
}

.access-status.granted {
  color: #059669;
}

.access-status.denied {
  color: #dc2626;
}

/* Device status row coloring */
.device-status-active {
  background-color: #dcfce7; /* intense green */
}

.device-status-inactive {
  background-color: #fef3c7; /* intense yellow */
}

.device-status-offline {
  background-color: #fecaca; /* intense red */
}

/* Scanning status styling */
.scanning-status {
  font-weight: 500;
}

.scanning-status.active {
  color: #059669;
}

.scanning-status.inactive {
  color: #64748b;
}

/* Room grid layout */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* Room card styling */
.room-card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.room-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.room-header {
  padding: 15px;
  background-color: #2c3e50;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.clear-room-button {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  margin-left: 10px;
}

.clear-room-button:hover {
  background-color: #c0392b;
}

.session-clear-toggle {
  padding: 6px 15px;
  background-color: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

.session-clear-bulk {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.session-clear-note {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  background-color: #eff6ff;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #1e3a8a;
}

.room-capacity {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.capacity-label {
  margin-right: 5px;
  font-weight: 300;
}

.capacity-value {
  font-weight: 600;
}

.room-stats {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Stat sections */
.stat-section {
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-section h4 {
  margin: 0 0 15px;
  font-size: 16px;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.stat-section h5 {
  margin: 15px 0 8px;
  font-size: 14px;
  color: #34495e;
}

/* Attendee stats */
.attendee-section {
  background-color: #e8f4fd;
}

.attendee-count {
  display: flex;
  align-items: baseline;
  margin-bottom: 10px;
}

.count-number {
  font-size: 28px;
  font-weight: bold;
  color: #2980b9;
  margin-right: 8px;
}

.count-label {
  font-size: 16px;
  color: #7f8c8d;
}

.last-activity {
  margin-top: 10px;
}

.last-scan,
.last-person {
  font-size: 14px;
  font-weight: 600;
  color: #34495e;
  margin-bottom: 4px;
}

.last-person {
  color: #2980b9;
  font-weight: 700;
}

/* Device stats */
.device-section {
  background-color: #f5f5f5;
}

.device-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.device-table th {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid #ddd;
  font-weight: 600;
  color: #34495e;
}

.device-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #eee;
  color: #555;
}

.device-serial {
  font-weight: 500;
  color: #2c3e50;
}

.device-timestamp, .scan-timestamp {
  font-size: 11px;
  color: #7f8c8d;
}

.device-temp {
  font-weight: 500;
}

.device-session {
  font-size: 11px;
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-devices {
  font-style: italic;
  color: #95a5a6;
  text-align: center;
  padding: 10px;
}

/* Schedule stats */
.schedule-section {
  background-color: #f9f4e8;
}

.current-session {
  background-color: #fff;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.session-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 5px;
  color: #2c3e50;
}

.session-time {
  font-size: 12px;
  color: #7f8c8d;
}

.no-session, .no-upcoming {
  font-size: 13px;
  color: #95a5a6;
  font-style: italic;
  padding: 5px 0;
}

.upcoming-sessions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upcoming-session {
  padding: 8px;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Setup page styles */
.setup-form {
  max-width: 800px;
}

.form-section {
  margin-bottom: 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.barcode-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #10b981;
  flex-shrink: 0;
}

.barcode-checkbox:hover {
  transform: scale(1.1);
}

.nested-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.nested-header .nested-title {
  margin: 0;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:disabled {
  background: #f9fafb;
  color: #6b7280;
  cursor: not-allowed;
}

.form-input-disabled {
  background: #f5f5f5;
  color: #9ca3af;
  border-color: #d1d5db;
  opacity: 0.7;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper .form-input {
  padding-right: 2.5rem;
}

.password-toggle-btn {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.password-toggle-btn:hover {
  opacity: 1;
}

.nested-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.nested-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 1rem 0;
}

.nested-field {
  margin-bottom: 1rem;
}



.save-button,
.refresh-button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.save-button:hover:not(:disabled),
.refresh-button:hover:not(:disabled) {
  background: #2563eb;
}

.save-button:disabled,
.refresh-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.success-message {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* View toggle buttons */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.75rem;
  background: white;
  border: none;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid #d1d5db;
  white-space: nowrap;
}

.view-toggle-btn:last-child {
  border-right: none;
}

.view-toggle-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.view-toggle-btn.active {
  background: #3b82f6;
  color: white;
}

.view-toggle-btn.active:hover {
  background: #2563eb;
}

/* Tile summary bar */
.tile-summary-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  flex-wrap: wrap;
}

.tile-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.tile-summary-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tile-summary-active .tile-summary-dot { background: #16a34a; }
.tile-summary-active { color: #15803d; }

.tile-summary-inactive .tile-summary-dot { background: #d97706; }
.tile-summary-inactive { color: #b45309; }

.tile-summary-offline .tile-summary-dot { background: #dc2626; }
.tile-summary-offline { color: #b91c1c; }

.tile-summary-total {
  margin-left: auto;
  font-size: 0.8125rem;
  color: #64748b;
}

/* Device tile grid */
.devices-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* Device tile card */
.device-tile {
  border-radius: 8px;
  border: 2px solid;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.device-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.device-tile-active {
  background: #f0fdf4;
  border-color: #86efac;
}

.device-tile-inactive {
  background: #fefce8;
  border-color: #fde047;
}

.device-tile-offline {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* Tile header row */
.device-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

/* Status badge */
.device-tile-status-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
}

.status-badge-active {
  background: #dcfce7;
  color: #15803d;
}

.status-badge-inactive {
  background: #fef9c3;
  color: #92400e;
}

.status-badge-offline {
  background: #fee2e2;
  color: #991b1b;
}

/* Tile delete button */
.device-tile-delete {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.device-tile-delete:hover:not(:disabled) {
  background: #fee2e2;
  color: #dc2626;
}

.device-tile-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Tile serial number */
.device-tile-serial {
  font-family: 'Courier New', monospace;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #1e293b;
  word-break: break-all;
}

/* Tile room name */
.device-tile-room {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8125rem;
  color: #475569;
  font-weight: 500;
}

.device-tile-room svg {
  flex-shrink: 0;
  color: #94a3b8;
}

/* Tile divider */
.device-tile-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.07);
  margin: 2px 0;
}

/* Tile stats row */
.device-tile-stats {
  display: flex;
  gap: 12px;
}

.device-tile-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.device-tile-stat-label {
  font-size: 0.6875rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.device-tile-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

/* Tile session */
.device-tile-session {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tile timestamp */
.device-tile-timestamp {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: auto;
  padding-top: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .page-title {
    font-size: 1.5rem;
  }

  .page-content {
    padding: 1.5rem;
    overflow-x: hidden;
  }

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

  /* Rooms controls responsive */
  .rooms-controls {
    padding: 1rem;
    gap: 1rem;
  }

  .search-section {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .search-input {
    width: 100%;
  }

  .sort-section {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .sort-section label {
    text-align: left;
  }

  .filter-section {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-group {
    min-width: auto;
  }

  .action-section {
    justify-content: center;
  }

  .device-status-table {
    display: block;
    overflow: auto;
    max-height: 60vh;
    white-space: nowrap;
  }

  .device-status-table thead,
  .device-status-table tbody,
  .device-status-table th,
  .device-status-table td,
  .device-status-table tr {
    display: block;
  }

  .device-status-table thead tr {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
  }

  .device-status-table tbody {
    display: block;
    overflow-y: auto;
    max-height: calc(60vh - 50px);
  }

  .device-table th:nth-child(4),
  .device-table td:nth-child(4) {
    display: none; /* Hide temperature column on small screens */
  }
}

/* Barcode button styles */
.barcode-button {
  background: #10b981;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.barcode-button:hover:not(:disabled) {
  background: #059669;
}

.barcode-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* Barcode section styles */
.barcode-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.barcode-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.barcode-actions {
  display: flex;
  gap: 1rem;
}

.download-button {
  background: #6b7280;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.download-button:hover {
  background: #4b5563;
}

.barcode-data {
  width: 100%;
  max-width: 600px;
}

.barcode-data h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.barcode-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  background: white;
  resize: vertical;
  line-height: 1.4;
}

.barcode-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  animation: modalSlideIn 0.2s ease-out;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #374151;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-barcode-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.modal-barcode-actions {
  display: flex;
  gap: 1rem;
}

.print-button {
  background: #059669;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.print-button:hover:not(:disabled) {
  background: #047857;
}

.print-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.modal-barcode-data {
  width: 100%;
  max-width: 600px;
}

.modal-barcode-data h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── DeviceDetail page ─────────────────────────────────────────────────── */

.device-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.device-detail-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.back-button {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.back-button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* SSE status badge */
.sse-status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
}

.sse-status-connecting {
  background: #fef9c3;
  color: #92400e;
}

.sse-status-connected {
  background: #dcfce7;
  color: #15803d;
}

.sse-status-error {
  background: #fee2e2;
  color: #991b1b;
}

/* Two-column body layout */
.device-detail-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

/* Main column */
.device-detail-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Device info strip */
.device-info-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

.device-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-info-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.device-info-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1e293b;
}

.device-info-value.mono {
  font-family: 'Courier New', monospace;
}

/* Screenshot feed */
.screenshot-feed {
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  border: 1px solid #1e293b;
}

.screenshot-img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
}

.screenshot-placeholder {
  color: #475569;
  font-size: 0.9375rem;
  text-align: center;
  padding: 3rem 2rem;
  line-height: 1.6;
}

.screenshot-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: right;
}

/* Sidebar */
.device-detail-sidebar {
  position: sticky;
  top: 1rem;
}

.command-panel {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.command-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.command-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.command-group {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.command-group:last-child {
  border-bottom: none;
}

.command-group-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.command-group-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.command-btn {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #f9fafb;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.command-btn:hover:not(:disabled) {
  background: #e5e7eb;
  border-color: #9ca3af;
}

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

.command-btn-danger {
  border-color: #fca5a5;
  background: #fff5f5;
  color: #dc2626;
}

.command-btn-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #f87171;
}

/* Command result toast */
.cmd-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.cmd-result-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.cmd-result-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.cmd-result-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: inherit;
  opacity: 0.7;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.cmd-result-close:hover {
  opacity: 1;
}

/* Command panel groups laid out side by side (wide panels) */
.command-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.command-groups-grid .command-group {
  border-bottom: none;
  border-right: 1px solid #f1f5f9;
}

/* Fleet commands (Devices page) */
.fleet-commands {
  margin-bottom: 1rem;
}

.fleet-commands .mono {
  font-family: monospace;
}

.fleet-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
}

.fleet-toggle-note {
  font-size: 0.8125rem;
  font-weight: 400;
  color: #64748b;
}

.fleet-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.fleet-body .loading-message {
  padding: 1rem;
}

.fleet-results {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.fleet-results-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.875rem;
  color: #334155;
}

.fleet-results-summary .refresh-button {
  margin-left: auto;
}

.fleet-result {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.fleet-result-ok {
  background: #dcfce7;
  color: #15803d;
}

.fleet-result-error {
  background: #fee2e2;
  color: #991b1b;
}

.fleet-result-no_response {
  background: #f1f5f9;
  color: #64748b;
}

.fleet-result-message {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-config-note {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.fleet-config-heading {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #334155;
}

.fleet-config-heading-diff {
  color: #b45309;
}

.fleet-config-diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.fleet-config-diff td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #fde68a;
  vertical-align: top;
}

.fleet-config-diff-key {
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  width: 35%;
}

.fleet-config-diff-value {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.1rem 0;
  word-break: break-all;
}

.fleet-config-diff-ids {
  color: #64748b;
  font-size: 0.75rem;
  text-align: right;
}

.fleet-config-missing {
  color: #94a3b8;
  font-style: italic;
}

/* Responsive: stack columns on narrow screens */
@media (max-width: 900px) {
  .device-detail-body {
    grid-template-columns: 1fr;
  }

  .device-detail-sidebar {
    position: static;
  }
}

/* ─── End DeviceDetail ───────────────────────────────────────────────────── */

/* Responsive modal adjustments */
@media (max-width: 768px) {
  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-barcode-actions {
    flex-direction: column;
    width: 100%;
  }

  .print-button,
  .download-button {
    width: 100%;
  }
}
