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

:root {
  --bg: #080b14;
  --surface: #0f1422;
  --surface2: #161c2e;
  --surface3: #1d2540;
  --border: #242d4a;
  --border-hover: #3a4570;
  --primary: #7c6bff;
  --primary-light: #9d8fff;
  --primary-dim: rgba(124,107,255,0.12);
  --danger: #ff4d6d;
  --success: #3ecf8e;
  --warn: #f5a623;
  --text: #e8edf8;
  --muted: #6b7494;
  --muted2: #8b93b8;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── AUTH ─────────────────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124,107,255,0.18) 0%, transparent 60%),
    var(--bg);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.03);
}

.logo {
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, #fff 30%, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 13px;
}

.tabs {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 24px;
  gap: 3px;
}

.tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,107,255,0.35);
}

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

input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,107,255,0.15);
}

input::placeholder, textarea::placeholder { color: var(--muted); }

textarea { resize: vertical; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 12px rgba(124,107,255,0.3);
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 20px rgba(124,107,255,0.4);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface2);
  color: var(--muted2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); }

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.btn-icon:hover { background: var(--surface3); border-color: var(--border); color: var(--text); }
.btn-icon.danger:hover { background: rgba(255,77,109,0.12); border-color: rgba(255,77,109,0.3); color: var(--danger); }

.error-msg {
  color: #ff7a92;
  font-size: 12.5px;
  min-height: 16px;
}

/* ─── NAVBAR ────────────────────────────────────────────────────────────────── */

.navbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  height: 58px;
  background: rgba(15,20,34,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-logo {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.4px;
  background: linear-gradient(135deg, #fff 30%, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: 8px;
}

.nav-links { display: flex; gap: 2px; flex: 1; }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--primary-dim); color: var(--primary-light); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); background: rgba(255,77,109,0.06); }

/* ─── VIEWS ─────────────────────────────────────────────────────────────────── */

.view {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 28px 60px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.view-header h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: #fff;
}

/* ─── DUBAI COUNTER ──────────────────────────────────────────────────────────── */

.dubai-counter {
  background: linear-gradient(135deg, rgba(30,36,64,0.9) 0%, rgba(20,26,50,0.9) 100%);
  border: 1px solid rgba(124,107,255,0.25);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative;
  overflow: hidden;
}

.dubai-counter::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,107,255,0.4), transparent);
}

.dubai-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.dubai-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.1px;
}

.dubai-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.dubai-badge.on-track { background: rgba(62,207,142,0.15); color: var(--success); border: 1px solid rgba(62,207,142,0.3); }
.dubai-badge.off-track { background: rgba(245,166,35,0.12); color: var(--warn); border: 1px solid rgba(245,166,35,0.3); }
.dubai-badge.complete { background: rgba(62,207,142,0.18); color: var(--success); border: 1px solid rgba(62,207,142,0.4); }

.dubai-nums {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.dubai-num {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}

.dubai-num.highlight .dubai-num-val { color: var(--primary-light); }
.dubai-num.warn .dubai-num-val { color: var(--warn); }
.dubai-num.success .dubai-num-val { color: var(--success); }

.dubai-num-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 4px;
}

.dubai-num-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.3;
}

.dubai-bar-wrap { }

.dubai-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted2);
  margin-bottom: 8px;
}

.dubai-bar-outer {
  height: 8px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
}

.dubai-bar-inner {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 4px;
}

.dubai-bar-inner.bar-low { background: linear-gradient(90deg, var(--warn), #f5a623cc); }
.dubai-bar-inner.bar-good { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.dubai-bar-inner.bar-complete { background: linear-gradient(90deg, var(--success), #5de8a8); }

/* ─── STATS GRID ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: default;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.stat-flag { font-size: 32px; margin-bottom: 12px; display: block; }

.stat-country {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-days { margin-bottom: 4px; }
.stat-days-num { font-size: 28px; font-weight: 800; color: var(--primary-light); letter-spacing: -1px; }
.stat-days-label { font-size: 13px; color: var(--muted); font-weight: 400; }

.stat-trips { font-size: 11.5px; color: var(--muted); }

/* ─── TOTAL BAR ──────────────────────────────────────────────────────────── */

.total-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted2);
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.total-bar strong { color: #fff; font-size: 15px; font-weight: 700; margin-left: 4px; }

/* ─── TRIPS LIST ─────────────────────────────────────────────────────────── */

.trip-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.trip-item:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.trip-flag { font-size: 28px; flex-shrink: 0; margin-top: 2px; }

.trip-info { flex: 1; min-width: 0; }

.trip-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}

.trip-dates {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

.trip-days-badge {
  display: inline-block;
  background: var(--primary-dim);
  color: var(--primary-light);
  border: 1px solid rgba(124,107,255,0.2);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.2px;
}

.trip-notes {
  font-size: 13px;
  color: var(--muted2);
  line-height: 1.6;
  white-space: pre-wrap;
}

.trip-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.03);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 26px 0;
  margin-bottom: 22px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
}

.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}
.modal-close:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }

#trip-form {
  padding: 0 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted2);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--muted);
}

.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.7; }
.empty-state p { margin-bottom: 22px; font-size: 14.5px; color: var(--muted2); }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
/* ─── TABLET ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dubai-nums { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .view { padding: 24px 20px 48px; }
  .modal { max-width: 100%; border-radius: 16px 16px 0 0; align-self: flex-end; max-height: 95vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ─── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Auth */
  #auth-screen { padding: 16px; align-items: flex-end; padding-bottom: 0; background: var(--bg); }
  .auth-card {
    padding: 28px 20px 36px;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    width: 100%;
    max-width: 100%;
  }

  /* Navbar */
  .navbar { padding: 0 14px; height: 52px; gap: 8px; }
  .nav-logo { font-size: 14px; }
  .nav-btn { padding: 6px 10px; font-size: 13px; }
  .nav-user span { display: none; }
  .btn-logout { padding: 5px 10px; font-size: 12px; }

  /* View */
  .view { padding: 20px 14px 60px; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .view-header h1 { font-size: 19px; }
  .view-header .btn-primary { width: 100%; text-align: center; }

  /* Dubai counter */
  .dubai-counter { padding: 18px 16px; }
  .dubai-title-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .dubai-nums { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dubai-num { padding: 12px; }
  .dubai-num-val { font-size: 22px; }
  .dubai-bar-label { flex-direction: column; gap: 2px; font-size: 11px; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px 14px; }
  .stat-flag { font-size: 26px; margin-bottom: 8px; }
  .stat-days-num { font-size: 24px; }

  /* Total bar */
  .total-bar { flex-direction: column; gap: 6px; padding: 14px 16px; font-size: 13px; }

  /* Trips */
  .trip-item { padding: 14px 14px; gap: 12px; }
  .trip-flag { font-size: 24px; }
  .trip-title { font-size: 14px; }

  /* Modal — bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-header { padding: 20px 20px 0; }
  #trip-form { padding: 0 20px 32px; }
  .form-row { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}
