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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: 100dvh;
}

/* Debug time overlay */
.debug-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.debug-overlay.active {
  display: flex;
}

.debug-box {
  background: #1a1a2e;
  border: 2px solid #667eea;
  border-radius: 12px;
  padding: 2rem;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 0 40px rgba(102, 126, 234, 0.4);
}

.debug-title {
  color: #667eea;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.debug-input {
  padding: 0.6rem 0.8rem;
  border: 2px solid #667eea;
  border-radius: 8px;
  background: #0f0f1a;
  color: white;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  width: 100%;
}

.debug-input:focus {
  outline: none;
  border-color: #00ff88;
}

.debug-buttons {
  display: flex;
  gap: 0.5rem;
}

.debug-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.debug-btn-apply  { background: #667eea; color: white; }
.debug-btn-clear  { background: #e94560; color: white; }
.debug-btn-cancel { background: #444; color: #ccc; }

.debug-btn:hover { opacity: 0.85; }

/* Debug active indicator */
.debug-indicator {
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  background: #e94560;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  z-index: 9998;
  letter-spacing: 0.05em;
  font-family: 'Courier New', monospace;
}

/* Tomorrow Section Separator Row */
.tomorrow-section-row td {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
  color: white;
  text-align: center;
  padding: clamp(0.6rem, 1.5vh, 1.2rem) clamp(0.8rem, 1.5vw, 1.5rem);
  font-size: clamp(0.95rem, 2vw, 1.3rem);
  font-weight: 700;
  letter-spacing: clamp(1px, 0.3vw, 3px);
  text-transform: uppercase;
}

.tomorrow-section-fr {
  display: none;
}

.tomorrow-departure {
  opacity: 0.75;
}

/* Landing Page Styles - Viewport Adaptive */
.landing-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.landing-header {
  text-align: center;
  color: white;
  margin-bottom: clamp(1.5rem, 5vh, 4rem);
}

.landing-header h1 {
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  margin-bottom: clamp(0.3rem, 1vh, 1rem);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.landing-header h2 {
  font-size: clamp(1.2rem, 4vw, 2.5rem);
  font-weight: 300;
  opacity: 0.9;
}

.landing-main {
  background: white;
  border-radius: clamp(15px, 3vw, 25px);
  padding: clamp(1.5rem, 5vw, 4rem);
  box-shadow: 0 4vh 10vh rgba(0, 0, 0, 0.3);
  max-width: min(90vw, 700px);
  width: 100%;
}

.landing-content {
  text-align: center;
  margin-bottom: clamp(1rem, 3vh, 2.5rem);
}

.landing-content p {
  font-size: clamp(0.95rem, 2.5vw, 1.3rem);
  line-height: 1.6;
  color: #333;
  margin-bottom: clamp(0.5rem, 1.5vh, 1.5rem);
}

.landing-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.5vh, 1.5rem);
}

.landing-footer {
  margin-top: clamp(1.5rem, 4vh, 3rem);
  color: white;
  text-align: center;
  opacity: 0.8;
  font-size: clamp(0.85rem, 2vw, 1.1rem);
}

/* Departure Board Styles - Viewport Adaptive */
.departure-board-container {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.language-indicator {
  position: absolute;
  top: clamp(0.5rem, 1.5vh, 1.5rem);
  left: clamp(0.5rem, 1.5vw, 1.5rem);
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
  padding: clamp(0.3rem, 1vh, 0.8rem) clamp(0.5rem, 1.5vw, 1.5rem);
  border-radius: clamp(6px, 1vw, 12px);
  font-weight: 700;
  font-size: clamp(0.9rem, 1.8vw, 1.4rem);
  box-shadow: 0 0.5vh 2vh rgba(0, 0, 0, 0.2);
  z-index: 100;
}

.departure-header {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: clamp(1rem, 2.5vh, 2.5rem) clamp(1rem, 3vw, 3rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1vh 2vh rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: min(95vw, 1400px);
  margin: 0 auto;
}

.header-title {
  font-size: clamp(1.5rem, 4vw, 3.5rem);
  font-weight: 600;
}

.clock {
  font-size: clamp(1.5rem, 5vw, 4rem);
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: #00ff88;
  text-shadow: 0 0 2vh rgba(0, 255, 136, 0.5);
}

.departure-main {
  flex: 1;
  padding: clamp(0.5rem, 1.5vh, 1.5rem) clamp(1rem, 3vw, 3rem);
  max-width: min(95vw, 1400px);
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Board footer / page indicator */
.board-footer {
  flex-shrink: 0;
  display: none;
  justify-content: center;
  align-items: center;
  padding: clamp(0.3rem, 0.8vh, 0.6rem) clamp(1rem, 3vw, 3rem);
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.7);
}

.page-indicator {
  font-size: clamp(0.75rem, 1.5vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.departure-table {
  width: 100%;
  background: white;
  border-radius: clamp(10px, 2vw, 20px);
  overflow: hidden;
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.2);
  font-size: clamp(0.85rem, 1.8vw, 1.2rem);
  align-self: flex-start;
}

.departure-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.departure-table th {
  padding: clamp(0.5rem, 1.2vh, 1rem) clamp(0.8rem, 1.5vw, 1.5rem);
  text-align: left;
  font-weight: 600;
  font-size: clamp(0.8rem, 2vw, 1.3rem);
  text-transform: uppercase;
  letter-spacing: clamp(0.5px, 0.1vw, 2px);
}

.departure-table tbody tr {
  border-bottom: 1px solid #eee;
  transition: background-color 0.3s ease;
}

.departure-table tbody tr:nth-child(even):not(.tomorrow-section-row) {
  background-color: #f4f5ff;
}

.departure-table tbody tr:nth-child(odd):not(.tomorrow-section-row) {
  background-color: #ffffff;
}

.departure-table tbody tr:hover:not(.tomorrow-section-row) {
  background-color: #e8eaff;
}

.departure-table tbody tr:last-child {
  border-bottom: none;
}

.departure-table td {
  padding: clamp(0.35rem, 0.9vh, 0.7rem) clamp(0.8rem, 1.5vw, 1.5rem);
  font-size: clamp(0.9rem, 1.8vw, 1.3rem);
}

.time-cell {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  color: #667eea;
}

.status-cell {
  font-weight: 600;
  padding: clamp(0.3rem, 1vh, 0.8rem) clamp(0.5rem, 1.5vw, 1.2rem);
  border-radius: 20px;
  text-align: center;
  font-size: clamp(0.8rem, 1.8vw, 1.2rem);
}

.status-cell:contains('On Time') {
  background-color: #d4edda;
  color: #155724;
}

.status-cell:contains('Delayed') {
  background-color: #fff3cd;
  color: #856404;
}

.status-cell:contains('Boarding') {
  background-color: #cce5ff;
  color: #004085;
}

.status-cell:contains('Cancelled') {
  background-color: #f8d7da;
  color: #721c24;
}

.status-cell:contains('Departed') {
  background-color: #dfe6e9;
  color: #636e72;
}

/* Admin Panel Styles - Viewport Adaptive */
.admin-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 3vh, 3rem) clamp(1rem, 3vw, 3rem);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(1rem, 3vh, 3rem);
  color: white;
}

.admin-header h1 {
  font-size: clamp(1.5rem, 4vw, 3rem);
}

.admin-main {
  max-width: min(95vw, 1200px);
  margin: 0 auto;
  width: 100%;
}

.add-departure-section,
.departures-list-section,
.settings-section {
  background: white;
  border-radius: clamp(10px, 2vw, 20px);
  padding: clamp(1.5rem, 3vh, 3rem);
  margin-bottom: clamp(1rem, 3vh, 3rem);
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.2);
}

.add-departure-section h2,
.departures-list-section h2,
.settings-section h2 {
  margin-bottom: clamp(1rem, 2vh, 2rem);
  color: #667eea;
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.settings-form {
  max-width: 400px;
}

.form-group small.help-text {
  display: block;
  color: #888;
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  margin-top: clamp(0.3rem, 1vh, 0.5rem);
  font-style: italic;
}

.form-group.checkbox-group {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  min-width: 20px;
  height: 20px;
  cursor: pointer;
}

.departure-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(1rem, 2vh, 2rem);
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: clamp(0.3rem, 1vh, 0.8rem);
  font-weight: 600;
  color: #333;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
}

.form-group input,
.form-group select {
  padding: clamp(0.6rem, 1.5vh, 1rem) clamp(0.8rem, 1.5vw, 1.2rem);
  border: clamp(1px, 0.3vh, 3px) solid #e0e0e0;
  border-radius: clamp(6px, 1vw, 12px);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.85rem, 1.8vw, 1.1rem);
}

.admin-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.admin-table th {
  padding: clamp(0.8rem, 2vh, 1.2rem) clamp(0.8rem, 1.5vw, 1.2rem);
  text-align: left;
  font-weight: 600;
}

.admin-table tbody tr {
  border-bottom: 1px solid #eee;
}

.admin-table tbody tr:last-child {
  border-bottom: none;
}

.admin-table td {
  padding: clamp(0.8rem, 2vh, 1.2rem) clamp(0.8rem, 1.5vw, 1.2rem);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-content {
  background-color: white;
  border-radius: clamp(10px, 2vw, 20px);
  padding: clamp(1.5rem, 3vh, 3rem);
  width: min(90vw, 500px);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideIn 0.3s;
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.3);
}

@keyframes slideIn {
  from { transform: translateY(-50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.close-btn {
  position: absolute;
  top: clamp(0.8rem, 2vh, 1.5rem);
  right: clamp(0.8rem, 2vw, 1.5rem);
  font-size: clamp(1.5rem, 4vw, 2rem);
  cursor: pointer;
  color: #888;
  line-height: 1;
}

.close-btn:hover {
  color: #333;
}

.modal-content h2 {
  margin-bottom: clamp(1rem, 2vh, 2rem);
  color: #667eea;
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.modal-content .form-group {
  margin-bottom: clamp(0.8rem, 2vh, 1.2rem);
}

.modal-content .btn {
  margin-top: clamp(0.5rem, 1.5vh, 1rem);
  margin-right: clamp(0.5rem, 1vw, 1rem);
}

/* Button Styles - Viewport Adaptive */
.btn {
  padding: clamp(0.6rem, 1.5vh, 1rem) clamp(1rem, 2.5vw, 2rem);
  border: none;
  border-radius: clamp(6px, 1vw, 12px);
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 1vh 3vh rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: clamp(1px, 0.3vh, 3px) solid #667eea;
}

.btn-secondary:hover {
  background: #667eea;
  color: white;
}

.btn-back {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: clamp(1px, 0.3vh, 3px) solid white;
  font-size: clamp(0.8rem, 1.8vw, 1rem);
}

.btn-back:hover {
  background: white;
  color: #667eea;
}

.btn-delete {
  background: #dc3545;
  color: white;
  padding: clamp(0.4rem, 1vh, 0.8rem) clamp(0.6rem, 1.5vw, 1rem);
  font-size: clamp(0.8rem, 1.8vw, 1rem);
}

.btn-delete:hover {
  background: #c82333;
}

.btn-edit {
  background: #ffc107;
  color: #212529;
  padding: clamp(0.4rem, 1vh, 0.8rem) clamp(0.6rem, 1.5vw, 1rem);
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  margin-right: clamp(0.3rem, 1vw, 0.5rem);
}

.btn-edit:hover {
  background: #e0a800;
}

.btn-save {
  background: #28a745;
  color: white;
  padding: clamp(0.4rem, 1vh, 0.8rem) clamp(0.6rem, 1.5vw, 1rem);
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  margin-right: clamp(0.3rem, 1vw, 0.5rem);
}

.btn-save:hover {
  background: #218838;
}

.btn-cancel {
  background: #6c757d;
  color: white;
  padding: clamp(0.4rem, 1vh, 0.8rem) clamp(0.6rem, 1.5vw, 1rem);
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  margin-right: clamp(0.3rem, 1vw, 0.5rem);
}

.btn-cancel:hover {
  background: #5a6268;
}

/* Spreadsheet-style editing */
.editable-row {
  cursor: pointer;
}

.editable-row:hover:not(.editing) {
  background-color: #f8f9fa;
}

.editable-cell {
  position: relative;
}

.editable-row.editing {
  background-color: #e3f2fd;
}

.editable-row.editing .editable-cell {
  padding: clamp(0.4rem, 1vh, 0.8rem);
}

.cell-input {
  width: 100%;
  padding: clamp(0.3rem, 0.8vh, 0.5rem);
  border: 2px solid #667eea;
  border-radius: 4px;
  font-size: inherit;
  font-family: inherit;
}

.cell-input:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.cell-input[type="time"] {
  width: auto;
  min-width: 100px;
}

.cell-input select {
  width: 100%;
}

.status-badge {
  display: inline-block;
  padding: clamp(0.2rem, 0.6vh, 0.4rem) clamp(0.5rem, 1vw, 0.8rem);
  border-radius: 20px;
  font-size: clamp(0.75rem, 1.6vw, 0.9rem);
  font-weight: 600;
}

.status-on-time {
  background: #d4edda;
  color: #155724;
}

.status-delayed {
  background: #fff3cd;
  color: #856404;
}

.status-boarding {
  background: #cce5ff;
  color: #004085;
}

.status-cancelled {
  background: #f8d7da;
  color: #721c24;
}

.status-departed {
  background: #e2e3e5;
  color: #383d41;
}

.status-delayed {
  background: #ff9800;
  color: white;
  animation: pulse-delayed 2s infinite;
}

@keyframes pulse-delayed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 152, 0, 0); }
}

/* Gate Updated Badge - Departure Board */
.gate-updated-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: clamp(0.15rem, 0.4vh, 0.3rem) clamp(0.4rem, 1vw, 0.6rem);
  background: #ff9800;
  color: white;
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  font-weight: 700;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: pulse-badge 2s infinite;
  white-space: nowrap;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Delayed Departure Styling */
.original-time {
  text-decoration: line-through;
  opacity: 0.5;
  margin-right: 0.5rem;
}

.delayed-time {
  color: #ff9800;
  font-weight: 700;
  background: rgba(255, 152, 0, 0.15);
  padding: clamp(0.1rem, 0.3vh, 0.2rem) clamp(0.3rem, 0.8vw, 0.5rem);
  border-radius: 4px;
}

.delayed-row {
  background: rgba(255, 152, 0, 0.05);
}

/* Gate Access Section - Viewport Adaptive */
.gate-access-section {
  margin-top: clamp(1.5rem, 4vh, 3rem);
  padding-top: clamp(1.5rem, 4vh, 3rem);
  border-top: clamp(1px, 0.4vh, 3px) solid #eee;
  text-align: center;
}

.gate-access-section h3 {
  color: #667eea;
  margin-bottom: clamp(0.8rem, 2vh, 1.5rem);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.gate-buttons {
  display: flex;
  gap: clamp(0.5rem, 1.5vw, 1.5rem);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: clamp(0.5rem, 1.5vh, 1.5rem);
}

.btn-gate {
  background: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
  color: white;
  font-weight: 600;
}

.btn-gate:hover {
  transform: translateY(-2px);
  box-shadow: 0 1vh 3vh rgba(233, 69, 96, 0.4);
}

.gate-hint {
  color: #888;
  font-size: clamp(0.8rem, 2vw, 1rem);
  font-style: italic;
}

.terminal-gate-hint {
  margin-top: clamp(1rem, 2vh, 1.5rem);
  padding-top: clamp(1rem, 2vh, 1.5rem);
  border-top: 1px solid #eee;
}

.terminal-gate-hint p {
  color: #666;
  font-size: clamp(0.85rem, 2vw, 1rem);
  margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
}

/* Responsive Design - Enhanced for Viewport Adaptiveness */
@media (max-width: 768px) {
  .landing-header h1 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
  }
  
  .landing-header h2 {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
  }
  
  .header-title {
    font-size: clamp(1.2rem, 5vw, 2rem);
  }
  
  .clock {
    font-size: clamp(1.2rem, 6vw, 2.5rem);
  }
  
  .departure-table {
    font-size: clamp(0.8rem, 3vw, 1rem);
  }
  
  .departure-table th,
  .departure-table td {
    padding: clamp(0.3rem, 1vh, 0.6rem) clamp(0.5rem, 2vw, 1rem);
  }
  
  .admin-header h1 {
    font-size: clamp(1.2rem, 5vw, 2rem);
  }
  
  .departure-form {
    grid-template-columns: 1fr;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  .landing-main {
    padding: clamp(1rem, 4vw, 2rem);
  }
  
  .landing-content p {
    font-size: clamp(0.9rem, 4vw, 1.1rem);
  }
  
  .departure-table th,
  .departure-table td {
    padding: clamp(0.25rem, 1vh, 0.5rem) clamp(0.4rem, 1.5vw, 0.8rem);
    font-size: clamp(0.75rem, 3vw, 0.9rem);
  }
  
  .time-cell {
    font-size: clamp(0.85rem, 3.5vw, 1.1rem);
  }
}

/* Large screens / Wallboards */
@media (min-width: 1920px) {
  .departure-board-container,
  .admin-container {
    font-size: 1.2rem;
  }
  
  .departure-table th,
  .departure-table td {
    padding: 1.5rem;
  }
}
