:root {
  --bg: #F2F2F7;
  --bg-primary: #FFFFFF;

  --blue: #007AFF;
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;

  --gray: #8E8E93;
  --gray2: #AEAEB2;
  --gray3: #C7C7CC;
  --gray4: #D1D1D6;
  --gray5: #E5E5EA;
  --gray6: #F2F2F7;

  --text: #000000;
  --text-secondary: rgba(60, 60, 67, 0.6);

  --separator: rgba(60, 60, 67, 0.1);

  --safe-top: env(safe-area-inset-top, 47px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);

  --accent: #5856D6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.app {
  height: 100%;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ==================== LOGIN ==================== */
.login-screen {
  background: linear-gradient(165deg, #667eea 0%, #5856D6 100%);
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.login-content {
  width: 100%;
  max-width: 320px;
  background: white;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #5856D6 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.app-icon svg {
  width: 32px;
  height: 32px;
  fill: white;
}

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray2);
  display: flex;
}

.input-icon svg {
  width: 20px;
  height: 20px;
}

.input-group input {
  width: 100%;
  height: 48px;
  background: var(--gray6);
  border: none;
  border-radius: 10px;
  padding: 0 14px 0 42px;
  font-size: 17px;
  color: var(--text);
}

.input-group input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(88, 86, 214, 0.2);
}

.input-group:has(input:focus) .input-icon {
  color: var(--accent);
}

.btn-primary {
  height: 48px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  color: white;
  cursor: pointer;
}

.btn-primary:active {
  opacity: 0.8;
}

.btn-primary:disabled {
  opacity: 0.5;
}

.error-text {
  text-align: center;
  color: var(--red);
  font-size: 14px;
  min-height: 20px;
}

/* ==================== MAIN ==================== */
.status-bar-space {
  height: var(--safe-top);
  flex-shrink: 0;
}

.app-header {
  padding: 4px 20px 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-name {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #667eea 0%, #5856D6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  background: white;
  padding: 8px 12px;
  border-radius: 10px;
}

.header-date svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

/* Stats - single row with big numbers */
.stats-row {
  display: flex;
  gap: 12px;
  padding: 0 20px 20px;
}

.stat-card {
  flex: 1;
  background: white;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card.available .stat-icon {
  background: rgba(52, 199, 89, 0.15);
}

.stat-card.available .stat-icon svg {
  color: var(--green);
}

.stat-card.occupied .stat-icon {
  background: rgba(255, 59, 48, 0.12);
}

.stat-card.occupied .stat-icon svg {
  color: var(--red);
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card.available .stat-number {
  color: var(--green);
}

.stat-card.occupied .stat-number {
  color: var(--red);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Section */
.section-header {
  padding: 0 20px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.section-meta {
  font-size: 15px;
  color: var(--text-secondary);
}

/* Spots List */
.spots-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.spots-list::-webkit-scrollbar { display: none; }

.spots-container {
  background: white;
  border-radius: 14px;
  overflow: hidden;
}

.spot-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  position: relative;
}

.spot-row:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 56px;
  right: 0;
  bottom: 0;
  height: 0.5px;
  background: var(--separator);
}

.spot-row:active {
  background: var(--gray6);
}

.spot-row:active::after {
  opacity: 0;
}

/* Avatar with status indicator */
.spot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  background: var(--gray5);
  color: var(--gray);
}

.spot-row.available .spot-avatar {
  background: rgba(52, 199, 89, 0.15);
  color: var(--green);
}

/* Status indicator dot */
.status-indicator {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 14px;
  height: 14px;
  border-radius: 7px;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spot-row.available .status-indicator {
  background: var(--green);
}

.spot-row.occupied .status-indicator {
  background: var(--red);
}

.status-indicator svg {
  width: 8px;
  height: 8px;
  color: white;
  stroke-width: 3;
}

.spot-content {
  flex: 1;
  min-width: 0;
}

.spot-name {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.25;
}

.spot-detail {
  font-size: 14px;
  color: var(--text-secondary);
}

.spot-row.available .spot-detail {
  color: var(--green);
}

.spot-chevron {
  color: var(--gray3);
}

.spot-chevron svg {
  width: 16px;
  height: 16px;
}

/* ==================== BOTTOM SHEET ==================== */
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.bottom-sheet.active {
  pointer-events: auto;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s;
}

.bottom-sheet.active .sheet-backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--gray6);
  border-radius: 14px 14px 0 0;
  padding: 6px 8px 8px;
  padding-bottom: calc(8px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 430px;
  margin: 0 auto;
  touch-action: none;
}

.bottom-sheet.active .sheet-content {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 5px;
  background: var(--gray3);
  border-radius: 3px;
  margin: 0 auto 8px;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-group {
  background: white;
  border-radius: 14px;
  overflow: hidden;
}

.sheet-info {
  padding: 18px 16px;
  text-align: center;
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.sheet-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sheet-btn {
  width: 100%;
  height: 56px;
  background: transparent;
  border: none;
  border-top: 0.5px solid var(--separator);
  font-size: 20px;
  cursor: pointer;
}

.sheet-btn:active {
  background: var(--gray6);
}

.sheet-btn.primary {
  color: var(--blue);
}

.sheet-btn.secondary {
  color: var(--text-secondary);
  font-size: 17px;
}

.sheet-btn.cancel {
  color: var(--blue);
  font-weight: 600;
}

/* Loading Screen */
.loading-screen {
  background: linear-gradient(165deg, #667eea 0%, #5856D6 100%);
  justify-content: center;
  align-items: center;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Loading (inline) */
.loading {
  padding: 60px 20px;
  display: flex;
  justify-content: center;
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--gray5);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Empty State */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
