/* ── Brand tokens ─────────────────────────────────────────────────────── */
:root {
  --blue:        #003366;
  --blue-mid:    #004a8f;
  --blue-light:  #1a4a7a;
  --gold:        #C5A059;
  --gold-light:  #e8c97a;
  --canvas:      #FAFAFA;
  --surface:     #FFFFFF;
  --slate:       #64748B;
  --border:      #F1F5F9;
  --border-gold: #F0D99A;
  --highlight:   #FFF8EE;
  --r:           12px;
  --r-sm:        8px;
  --r-xs:        6px;
  --shadow:      0 1px 4px rgba(0,51,102,0.08);
  --shadow-md:   0 4px 20px rgba(0,51,102,0.14);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--canvas);
  color: var(--blue);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── App header ───────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 60%, var(--blue) 100%);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.app-header::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 90px; height: 90px;
  background: rgba(197,160,89,0.12);
  border-radius: 50%;
  pointer-events: none;
}

.app-header-left { display: flex; align-items: center; gap: 11px; }
.app-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.app-logo {
  width: 40px; height: 40px;
  background: rgba(197,160,89,0.2);
  border: 2px solid var(--gold);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.app-title {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
}
.app-tagline {
  font-size: 9px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 3px;
}

.gold-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

/* ── Container ────────────────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 18px 14px 40px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary  { background: var(--blue);   color: #fff; }
.btn-primary:hover  { background: var(--blue-mid); }
.btn-gold     { background: var(--gold);   color: #fff; }
.btn-gold:hover     { opacity: 0.9; }
.btn-ghost    { background: transparent; color: var(--blue); border: 1px solid #E2E8F0; }
.btn-ghost:hover    { background: var(--border); }
.btn-danger   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.btn-danger:hover   { background: #FECACA; }

.btn-sm   { padding: 7px 13px; font-size: 12px; }
.btn-icon { padding: 7px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Form elements ────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.form-hint {
  font-size: 10px;
  color: var(--slate);
  margin-top: -2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #E2E8F0;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--blue);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,51,102,0.08);
}
.form-input::placeholder,
.form-textarea::placeholder { color: #CBD5E1; }
.form-textarea { resize: vertical; min-height: 64px; line-height: 1.5; }

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

/* ── Tags ─────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.tag-time     { background: #EEF2FF; color: #4338CA; }
.tag-meal     { background: #F0FDF4; color: #166534; }
.tag-budget   { background: var(--highlight); color: #92400E; }
.tag-activity { background: #F0F9FF; color: #075985; }
.tag-stay     { background: #F5F3FF; color: #5B21B6; }
.tag-travel   { background: #F8FAFC; color: #475569; }
.tag-nature   { background: #F0FDF4; color: #166534; }

/* ── Dashboard plan cards ─────────────────────────────────────────────── */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

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

.plan-card {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
}
.plan-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.plan-card-header {
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.plan-card-badge {
  background: rgba(197,160,89,0.25);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 6px;
}
.plan-card-meta {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.04em;
}

.plan-card-body { padding: 12px 14px 10px; }
.plan-card-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
}
.plan-card-location {
  font-size: 11px;
  color: var(--slate);
  font-weight: 500;
  margin-bottom: 6px;
}
.plan-card-stats {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.plan-card-actions {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 8px;
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty-state h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.empty-state p  { font-size: 13px; color: var(--slate); }

/* ── Editor ───────────────────────────────────────────────────────────── */
.editor-section {
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.editor-section-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--blue), var(--blue-mid));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.editor-section-title {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.editor-section-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Day tabs */
.day-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--slate);
  transition: all 0.15s;
}
.day-tab.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* Stop cards in editor */
.stop-editor-card {
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.stop-editor-card.is-highlight {
  background: var(--highlight);
  border-color: var(--border-gold);
}

.stop-editor-top {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.stop-editor-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 8px;
}
.stop-editor-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.stop-editor-actions {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.02em;
}
.toggle-label input[type=checkbox] { accent-color: var(--gold); width: 14px; height: 14px; }

.add-stop-btn {
  width: 100%;
  padding: 10px;
  border: 2px dashed #CBD5E1;
  border-radius: var(--r-sm);
  background: none;
  color: var(--slate);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: 'Inter', sans-serif;
}
.add-stop-btn:hover { border-color: var(--blue); color: var(--blue); }

.stops-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal {
  background: var(--surface);
  border-radius: var(--r) var(--r) 0 0;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-md);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.modal-body  { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(10px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ── Viewer (web layout) ──────────────────────────────────────────────── */
.view-header {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 60%, var(--blue) 100%);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.view-header::after {
  content: '';
  position: absolute;
  top: -24px; right: -24px;
  width: 100px; height: 100px;
  background: rgba(197,160,89,0.12);
  border-radius: 50%;
  pointer-events: none;
}
.view-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.view-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.view-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 4px;
}
.view-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.view-header-badges  { display: flex; gap: 8px; flex-wrap: wrap; }

.view-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 5px 11px;
  text-align: center;
}
.view-badge .b-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  display: block;
}
.view-badge .b-value {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  display: block;
  margin-top: 1px;
  letter-spacing: -0.01em;
}

.view-days { display: flex; flex-direction: column; gap: 0; }

.view-day-card {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.view-day-header {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.view-day1 .view-day-header { background: linear-gradient(135deg, #003366, #004a8f); }
.view-day2 .view-day-header { background: linear-gradient(135deg, #1a4a7a, #003366); }
.view-day3 .view-day-header { background: linear-gradient(135deg, #004a8f, #1a4a7a); }
.view-day4 .view-day-header { background: linear-gradient(135deg, #003366, #002855); }
.view-day5 .view-day-header { background: linear-gradient(135deg, #002855, #003366); }
.view-day6 .view-day-header { background: linear-gradient(135deg, #003a6b, #004a8f); }
.view-day7 .view-day-header { background: linear-gradient(135deg, #004a8f, #003a6b); }

.view-day-num {
  font-size: 32px;
  font-weight: 900;
  color: rgba(255,255,255,0.15);
  letter-spacing: -0.04em;
  line-height: 1;
  flex-shrink: 0;
}
.view-day-info { flex: 1; padding: 0 10px; }
.view-day-info h2 {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.view-day-theme {
  font-size: 9px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-top: 2px;
}
.view-day-date {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: var(--r-xs);
  white-space: nowrap;
}

.view-stops { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }

.view-stop {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--canvas);
  border: 1px solid var(--border);
}
.view-stop.is-highlight {
  background: var(--highlight);
  border-color: var(--border-gold);
}
.view-stop-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.view-stop-body { flex: 1; min-width: 0; }
.view-stop-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.view-stop-place {
  font-size: 11px;
  font-weight: 500;
  color: var(--slate);
  margin-top: 1px;
}
.view-stop-notes {
  font-size: 11px;
  color: var(--slate);
  margin-top: 3px;
  line-height: 1.45;
}
.view-stop-tags {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.view-footer {
  background: var(--blue);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.view-footer-text {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.view-footer-gold {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Print actions bar ────────────────────────────────────────────────── */
.print-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (min-width: 520px) {
  .plans-grid { grid-template-columns: 1fr 1fr; }
  .app-header  { padding: 16px 24px; }
  .container   { padding: 22px 20px 50px; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--r); }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 768px) {
  .app-title { font-size: 20px; }
  .app-logo  { width: 44px; height: 44px; font-size: 20px; }
  .view-title { font-size: 24px; }
}

/* ── Viewer base (mobile) ─────────────────────────────────────────────── */
.view-wrapper   { min-height: 100vh; display: flex; flex-direction: column; }
.view-days-web  { display: flex; flex-direction: column; }

/* ── Desktop viewer: 3-column grid, wraps to row 2 for days 4–6 ──────── */
@media (min-width: 720px) {
  .view-days-web {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 14px 16px;
    background: var(--canvas);
  }

  /* Each day card becomes a column */
  .view-day-card {
    border-bottom: 1px solid var(--border);
    border-radius: var(--r);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Day header slightly more compact */
  .view-day-header { padding: 10px 14px; }
  .view-day-num    { font-size: 26px; }
  .view-day-info h2 { font-size: 11px; }
  .view-day-date   { font-size: 9px; padding: 3px 8px; }

  /* Stops scroll within the card */
  .view-stops {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    gap: 5px;
    max-height: 480px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .view-stops::-webkit-scrollbar       { width: 4px; }
  .view-stops::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* Stop items slightly more compact */
  .view-stop      { padding: 8px 10px; gap: 8px; }
  .view-stop-name { font-size: 11px; }
  .view-stop-notes,
  .view-stop-place { font-size: 10px; }
  .view-stop-icon { font-size: 14px; width: 18px; }
  .tag            { font-size: 9px; padding: 2px 6px; }
  .view-stop-tags { gap: 4px; margin-top: 4px; }
}

/* ── Print styles (A4 Portrait, 3-col grid) ───────────────────────────── */
@media print {
  .print-bar,
  .view-header-actions,
  .no-print { display: none !important; }

  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page { size: A4; margin: 10mm; }

  .view-wrapper {
    min-height: unset;
    overflow: visible;
  }

  /* Compact header */
  .view-header        { padding: 10px 14px 8px; }
  .view-header-top    { margin-bottom: 6px; }
  .view-title         { font-size: 17px; }
  .view-subtitle      { font-size: 8px; }
  .view-header-badges { gap: 5px; flex-wrap: wrap; }
  .view-badge         { padding: 4px 8px; }
  .view-badge .b-label { font-size: 6.5px; }
  .view-badge .b-value { font-size: 9.5px; }

  /* 3-column grid — mirrors the desktop web view */
  .view-days-web {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 7px !important;
    padding: 10px 0 0 !important;
    background: transparent !important;
  }

  /* Day cards — no scroll clipping, allow page breaks between rows */
  .view-day-card {
    display: flex !important;
    flex-direction: column;
    border: 1px solid #E2E8F0 !important;
    border-radius: 8px;
    overflow: visible !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .view-day-header  { padding: 7px 10px; }
  .view-day-num     { font-size: 20px; }
  .view-day-info h2 { font-size: 9px; }
  .view-day-theme   { font-size: 7px; }
  .view-day-date    { font-size: 7.5px; padding: 2px 6px; }

  /* Stops: let them expand fully */
  .view-stops {
    flex: 1;
    overflow: visible !important;
    max-height: none !important;
    padding: 5px 7px;
    gap: 4px;
  }

  .view-stop       { padding: 4px 6px; gap: 5px; }
  .view-stop-icon  { font-size: 10px; width: 14px; }
  .view-stop-name  { font-size: 8px; }
  .view-stop-place,
  .view-stop-notes { font-size: 7px; }
  .tag             { font-size: 6.5px; padding: 1px 4px; }
  .view-stop-tags  { gap: 3px; margin-top: 2px; }

  /* Footer stays with last row */
  .view-footer {
    padding: 8px 14px;
    flex-wrap: wrap;
    gap: 5px;
    break-before: avoid;
    page-break-before: avoid;
  }
  .view-footer-text { font-size: 7.5px; }
  .view-footer-gold { font-size: 8px; }
}
