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

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --border: #dbe4f0;
  --border-strong: #c9d8eb;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-soft: #e9f2ff;
  --danger-soft: #fee2e2;
  --danger: #b91c1c;
  --success-soft: #dcfce7;
  --success: #166534;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* CONTAINER */
#app {
  max-width: 640px;
  margin: auto;
  padding: 20px 16px 104px;
}

/* HEADINGS */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

p,
label,
span,
option {
  color: var(--muted);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px 16px 14px;
  background: rgba(248, 251, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(219, 228, 240, 0.8);
}

.app-header h1 {
  max-width: 640px;
  margin: 0 auto;
}

.app-container {
  width: 100%;
}

/* BUTTONS */
button {
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* INPUTS */
input, select {
  width: 100%;
  padding: 12px 14px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--primary);
}

/* CARD */
.station {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: var(--shadow);
}

/* HEADER */
.station-header {
  cursor: pointer;
  display: grid;
  gap: 8px;
}

.station-header p {
  font-size: 0.95rem;
}

.station-header h3 {
  margin-bottom: 2px;
}

/* SLOTS GRID */
.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf2f7;
}

/* SLOT BUTTON */
.slot-btn {
  min-height: 72px;
  border-radius: 14px;
  padding: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--border-strong);
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  text-align: left;
}

.slot-btn.full {
  background: var(--danger-soft);
}

.slot-btn.almost-full {
  background: #fff3cd;
}

.slot-btn.disabled {
  background: #eee;
  color: #64748b;
}

.slot-time {
  color: var(--text);
  font-size: 0.96rem;
}

.slot-meta {
  color: #334155;
  font-weight: 500;
  font-size: 0.82rem;
}

/* BOOKING SECTION */
.bookings-section {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: var(--shadow);
}

.bookings-section h2 {
  margin-bottom: 14px;
}

.booking-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #eef2f7;
}

.booking-card:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* FILTERS */
.filters {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid rgba(219, 228, 240, 0.9);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(92vw, 640px);
  display: flex;
  justify-content: space-around;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(12px);
}

.bottom-nav button {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 500;
  transform: none;
}

.bottom-nav button:hover {
  opacity: 1;
  transform: none;
}

.bottom-nav button.active {
  color: #ffffff;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 6px;
}

.hero-card,
.details-section,
.content-section,
.stock-summary {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.hero-card p,
.stock-summary div {
  font-size: 0.92rem;
}

.details-form,
.details-grid,
.details-summary {
  display: grid;
}

.details-form {
  gap: 14px;
}

.details-grid {
  gap: 12px;
}

.details-summary {
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid var(--border);
}

.stock-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  background: #f8fbff;
}

.station-warning {
  color: var(--danger);
  font-weight: 700;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.risk-green {
  background: #dcfce7;
  color: #166534;
}

.risk-orange {
  background: #fef3c7;
  color: #92400e;
}

.risk-red {
  background: #fee2e2;
  color: #b91c1c;
}

.risk-neutral {
  background: #e2e8f0;
  color: #334155;
}

.slot-btn.risk-green {
  background: #ecfdf5;
}

.slot-btn.risk-orange {
  background: #fff7ed;
}

.slot-btn.risk-red {
  background: #fef2f2;
}

.slot-btn.risk-neutral {
  background: #eff6ff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.booking-modal {
  width: min(100%, 420px);
  display: grid;
  gap: 12px;
  background: var(--surface);
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.26);
}

.modal-subtitle,
.modal-note {
  font-size: 0.9rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-stock-summary {
  display: grid;
  gap: 10px;
}

/* LOGIN PAGE */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 28px 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 228, 240, 0.9);
  border-radius: 24px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 14px;
}

.auth-card h2 {
  margin-bottom: 0;
  text-align: center;
}

.subtitle {
  text-align: center;
  font-size: 0.98rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-extra-fields {
  display: grid;
  gap: 12px;
}

.otp-hint {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

#phone {
  width: 100%;
}

#loginBtn, #signupBtn {
  width: 100%;
  display: block;
}

.error {
  min-height: 22px;
  font-size: 0.92rem;
  color: var(--danger);
  text-align: center;
}

.admin-body {
  padding: 20px 16px 40px;
}

.admin-shell {
  max-width: 640px;
  margin: 0 auto;
}

.admin-shell h2 {
  margin-bottom: 8px;
}

.admin-shell > label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

#app > button:first-child {
  width: 100%;
  margin-bottom: 16px;
}

.admin-input-wrap {
  margin-top: 14px;
}

.slot-create-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid var(--border);
}

.slot-create-grid {
  display: grid;
  gap: 10px;
}

.field-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.admin-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.secondary-btn {
  background: #e2e8f0;
  color: var(--text);
}

.danger-btn {
  background: #dc2626;
  color: #fff;
}

.admin-slot-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #edf2f7;
}

.slot-manager {
  display: grid;
  gap: 14px;
}

.admin-booking-summary {
  display: grid;
  gap: 10px;
}

.admin-summary-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: grid;
  gap: 4px;
}

.admin-summary-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.admin-summary-value {
  font-size: 1.3rem;
  color: var(--text);
}

.slot-manager-note {
  font-size: 0.92rem;
}

.slot-bulk-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.slot-checkbox-list {
  display: grid;
  gap: 10px;
}

.slot-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.slot-checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.slot-checkbox-copy {
  display: grid;
  gap: 4px;
}

.slot-checkbox-time {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.slot-checkbox-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.slot-checkbox-item.enabled {
  border-color: rgba(22, 163, 74, 0.18);
}

.slot-checkbox-item.disabled {
  border-color: rgba(220, 38, 38, 0.12);
  background: #f8fafc;
}

.slot-checkbox-item.load-low {
  border-left: 5px solid #22c55e;
}

.slot-checkbox-item.load-medium {
  border-left: 5px solid #f59e0b;
}

.slot-checkbox-item.load-high {
  border-left: 5px solid #ef4444;
}

.slot-load-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.slot-load-badge.load-low {
  background: #dcfce7;
  color: #166534;
}

.slot-load-badge.load-medium {
  background: #fef3c7;
  color: #92400e;
}

.slot-load-badge.load-high {
  background: #fee2e2;
  color: #b91c1c;
}

.notifications-section {
  background: var(--surface);
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: var(--shadow);
}

.notification-card {
  padding: 12px 14px;
  border-radius: 14px;
  margin-top: 10px;
  border: 1px solid transparent;
}

.notification-card.warning {
  background: #fff7ed;
  border-color: #fdba74;
}

.notification-card.success {
  background: #ecfdf5;
  border-color: #86efac;
}

.notification-message {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.notification-meta {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ADMIN SLOT COLORS */
.slot.enabled {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(22, 101, 52, 0.14);
  border-radius: 12px;
}

.slot.disabled {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.12);
  border-radius: 12px;
}

.slot {
  margin-top: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.45;
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
  }

  .details-grid,
  .admin-stock-summary,
  .admin-booking-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .slots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .slot-create-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .app-header {
    padding: 16px 14px 12px;
  }

  #app {
    padding: 16px 14px 100px;
  }

  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1.15rem;
  }

  .station,
  .bookings-section,
  .hero-card,
  .details-section,
  .auth-card,
  .filters {
    padding: 14px;
    border-radius: 16px;
  }

  .hero-card {
    flex-direction: column;
    align-items: stretch;
  }

  .slots {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .slot-btn {
    min-height: 68px;
    padding: 12px 12px;
  }

  .booking-card {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-nav {
    width: calc(100vw - 20px);
    padding: 12px 14px;
  }

  .admin-action-row,
  .slot-bulk-actions,
  .modal-actions {
    grid-template-columns: 1fr;
  }
}
