:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #718096;
  --primary: #635bff;
  --primary-dark: #5048e5;
  --success: #19a974;
  --success-soft: #e9fbf4;
  --border: #e6eaf0;
  --shadow: 0 18px 45px rgba(25, 35, 58, 0.08);
  --radius: 22px;
}

body.dark {
  --bg: #101317;
  --card: #1b212b;
  --text: #eef2f8;
  --muted: #a8b3c3;
  --border: #313946;
  --shadow: 0 18px 45px rgba(0,0,0,.35);
}

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

body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 32px 18px;
}

button, input, textarea { font: inherit; }

.container { width: min(1180px, 100%); margin: 0 auto; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #8b84ff);
  color: white;
  font-size: 24px;
  box-shadow: 0 12px 25px rgba(99, 91, 255, 0.25);
}

.brand h1 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.8px; }
.brand p, .trip-header-title p { color: var(--muted); margin-top: 3px; font-size: 14px; }

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.theme-toggle,
.reset-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.trip-id {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  color: var(--primary);
}

.trip-card,
.milestones-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.trip-card { overflow: hidden; margin-bottom: 22px; }
.trip-header { padding: 26px; }

.trip-header-title,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.trip-header-title h2, .section-title h2 { font-size: 20px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #fff7e6;
  color: #a56b00;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }

.trip-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.info-item {
  min-height: 96px;
  padding: 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 92%, var(--primary) 8%);
  border: 1px solid var(--border);
}

.info-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.info-value { font-size: 15px; line-height: 1.35; font-weight: 800; }

.progress-section { padding: 0 26px 26px; }

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 14px;
}

.progress-title { font-weight: 800; }
.progress-number { color: var(--primary); font-weight: 900; }

.progress-track {
  height: 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, var(--card) 30%);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b84ff);
  border-radius: inherit;
  transition: width .35s ease;
}

.milestones-card { padding: 26px; }

.milestone-list { display: grid; gap: 14px; }

.milestone {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  transition: .2s ease;
}

.milestone.completed {
  background: var(--success-soft);
  border-color: rgba(25,169,116,.28);
}

body.dark .milestone.completed {
  background: rgba(25,169,116,.14);
}

.milestone.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.milestone-number {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--border) 70%, var(--card) 30%);
  color: var(--muted);
  font-weight: 900;
}

.milestone.completed .milestone-number { background: var(--success); color: white; }

.milestone-title { font-size: 16px; font-weight: 900; margin-bottom: 5px; }
.milestone-meta { color: var(--muted); font-size: 13px; }

.milestone-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(25,169,116,.12);
  color: #16865e;
  font-size: 12px;
  font-weight: 800;
}

.milestone-comments { margin-top: 7px; font-size: 13px; display:none; }

.milestone-action {
  min-width: 155px;
  border: none;
  border-radius: 13px;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.milestone-action:disabled { background: #c9ced8; cursor: not-allowed; }
.milestone.completed .milestone-action { background: var(--success); }

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(16,24,40,.55);
  backdrop-filter: blur(5px);
  z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: min(520px, 100%);
  background: var(--card);
  color: var(--text);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(16,24,40,.24);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header p { color: var(--muted); font-size: 13px; }

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}

.modal-body { padding: 22px; }
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 900;
}

.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--card);
  outline: none;
}

textarea.form-control { min-height: 100px; resize: vertical; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 22px;
}

.modal-btn {
  border: none;
  border-radius: 13px;
  padding: 12px 17px;
  font-weight: 900;
  cursor: pointer;
}

.modal-btn.cancel { background: #eef1f5; color: #556070; }
.modal-btn.confirm { background: var(--success); color: white; }
.modal-btn:disabled { opacity: .65; cursor: wait; }

.request-message {
  display: none;
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 13px;
}

.request-message.visible { display: block; }
.request-message.error { background: #fff0f0; color: #b42318; border: 1px solid #f5c2c0; }
.request-message.success { background: var(--success-soft); color: #16865e; border: 1px solid rgba(25,169,116,.25); }

.button-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 7px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: white;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .7s linear infinite;
}

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

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244,247,251,.92);
  backdrop-filter: blur(4px);
}

body.dark .app-loading { background: rgba(16,19,23,.94); }
.app-loading.hidden { display: none; }

.loading-box {
  width: min(420px, calc(100% - 32px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

.loading-box p { color: var(--muted); font-size: 13px; }

.pod-uploader {
  display: none;
  margin-top: 18px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.pod-uploader.visible { display: block; }
.pod-uploader-title { font-size: 14px; font-weight: 900; margin-bottom: 6px; }
.pod-uploader-help { color: var(--muted); font-size: 12px; margin-bottom: 13px; }
.pod-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pod-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.pod-picker {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
}

.pod-picker.secondary { background: var(--card); color: var(--text); }

.pod-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin-top: 14px;
}

.pod-preview {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1/1;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #eef1f5;
}

.pod-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pod-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: rgba(17,24,39,.82);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.pod-file-name {
  position: absolute;
  inset: auto 0 0;
  padding: 18px 7px 6px;
  color: #fff;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(transparent,rgba(0,0,0,.72));
}

.pod-counter { display: none; margin-top: 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.pod-counter.visible { display: block; }

@media (max-width: 980px) {
  .trip-info { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  body { padding: 20px 12px; }
  .topbar, .trip-header-title, .section-title { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .trip-info { grid-template-columns: 1fr; }
  .milestone { grid-template-columns: 48px 1fr; }
  .milestone-action { grid-column: 1 / -1; width: 100%; }
  .trip-header, .milestones-card { padding: 20px; }
  .progress-section { padding: 0 20px 20px; }
  .pod-preview-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
