:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2a2e3b;
  --text: #e4e6eb;
  --text-dim: #8b8fa3;
  --text-muted: #555a6e;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --accent-light: #a29bfe;
  --booking: #63c8ff;
  --booking-light: #dff6ff;
  --booking-bg: rgba(99, 200, 255, 0.18);
  --booking-border: rgba(99, 200, 255, 0.62);
  --booking-glow: rgba(99, 200, 255, 0.45);
  --green: #00b894;
  --green-bg: rgba(0, 184, 148, 0.12);
  --green-border: rgba(0, 184, 148, 0.3);
  --red: #fd7272;
  --red-bg: rgba(253, 114, 114, 0.1);
  --red-border: rgba(253, 114, 114, 0.25);
  --yellow: #feca57;
  --yellow-bg: rgba(254, 202, 87, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 60px;
}

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

/* Header */
.header {
  text-align: center;
  margin-bottom: 28px;
  padding: 20px 0;
}
.header-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
  box-shadow: 0 8px 32px var(--accent-glow);
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}
.header p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.card:hover { border-color: #363a4a; }
.card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 14px;
}

/* Token input */
.text-input,
.token-area {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.text-input {
  height: 44px;
  font-family: inherit;
}
.token-area {
  font-family: 'SF Mono', 'Fira Code', monospace;
  resize: none;
  height: 56px;
}
.text-input::placeholder,
.token-area::placeholder { color: var(--text-muted); }
.text-input:focus,
.token-area:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.token-row {
  display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap;
}

.token-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 6px 10px;
  border-radius: 20px;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}
.token-badge.info { background: rgba(108,92,231,0.1); color: var(--accent-light); border: 1px solid rgba(108,92,231,0.2); }
.token-badge.valid { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.token-badge.expired { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(254,202,87,0.25); }
.token-badge.error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }

.auth-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-accent:hover { background: #5f4dd0; transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-accent:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: #444; }

.btn-green {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,184,148,0.25);
}
.btn-green:hover { background: #00a884; transform: translateY(-1px); }
.btn-green:disabled { background: #2a3a35; color: #4a6a5e; box-shadow: none; cursor: not-allowed; transform: none; }

.btn-red {
  background: var(--red); color: #fff;
  box-shadow: 0 2px 12px rgba(253, 114, 114, 0.25);
}
.btn-red:hover { background: #e55a5a; transform: translateY(-1px); }

.retry-settings {
  display: flex; gap: 14px; margin-top: 14px; align-items: center; flex-wrap: wrap;
}
.retry-label {
  font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px;
}
.retry-input {
  width: 82px; padding: 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-family: inherit;
}
.retry-input:focus { outline: none; border-color: var(--accent); }
.retry-hint {
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 600;
}

/* Quick select chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  transition: all 0.2s;
  font-family: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent); color: var(--accent-light); background: rgba(108,92,231,0.08); }
.chip.active { border-color: var(--accent); color: #fff; background: var(--accent); }

/* Calendar */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell:hover:not(.past):not(.booked) {
  background: var(--surface-hover);
  border-color: #3a3e4e;
}
.cal-cell.today {
  border-color: var(--accent);
  color: var(--accent-light);
}
.cal-cell.past {
  color: var(--text-muted);
  opacity: 0.4;
  cursor: default;
}
.cal-cell.weekend:not(.free):not(.selected):not(.booked):not(.booking) {
  color: var(--accent-secondary, #e88a4a);
}
.cal-cell.selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
  animation: pop 0.2s ease;
}
.cal-cell.free {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}
.cal-cell.free::after {
  content: '';
  position: absolute;
  bottom: 3px; right: 3px;
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
}
.cal-cell.booked {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
  border-color: rgba(255, 193, 7, 0.3);
  cursor: default;
}
.cal-cell.booked::after {
  content: '';
  position: absolute;
  bottom: 3px; right: 3px;
  width: 6px; height: 6px;
  background: #ffc107;
  border-radius: 50%;
}
.cal-cell.booking {
  background: var(--booking-bg);
  color: var(--booking-light);
  border-color: var(--booking-border);
  box-shadow: 0 0 0 1px rgba(99, 200, 255, 0.22) inset, 0 0 18px var(--booking-glow);
  text-shadow: 0 0 10px rgba(223, 246, 255, 0.32);
  animation: pulse 0.8s infinite;
}

.month-header {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Actions bar */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.action-bar .count {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.action-bar .count strong {
  color: var(--accent-light);
  font-weight: 700;
}

/* Status toast */
.toast {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease;
}
.toast.info { background: rgba(108,92,231,0.1); color: var(--accent-light); border: 1px solid rgba(108,92,231,0.2); }
.toast.success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.toast.error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }

/* Log */
.log-panel {
  margin-top: 12px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  color: var(--text-dim);
  line-height: 1.6;
}
.log-panel::-webkit-scrollbar { width: 4px; }
.log-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.hidden { display: none !important; }

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* Legend */
.legend {
  display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim);
}
.legend-dot {
  width: 10px; height: 10px; border-radius: 4px;
}
.legend-dot.selected { background: var(--accent); }
.legend-dot.booked { background: #ffc107; }
.legend-dot.free { background: var(--green); }

/* User info */
.user-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.info-item.full { grid-column: 1 / -1; }
.info-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
}
.info-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.info-value .car-plate {
  display: inline-block;
  background: var(--yellow-bg);
  color: var(--yellow);
  padding: 1px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
  border: 1px solid rgba(254,202,87,0.2);
}
.quota-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.quota-track {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.quota-fill.warn { background: var(--yellow); }
.quota-fill.full { background: var(--red); }
.quota-text {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.9); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
