:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #1e40af;
  --accent-soft: #dbeafe;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f766e 100%);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 25px rgba(0,0,0,.15);
}
.login-card h1 {
  margin: 0 0 .25rem;
  font-size: 1.6rem;
  text-align: center;
}
.login-subtitle {
  margin: 0 0 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
}
.login-card label {
  display: block;
  margin-bottom: 1rem;
  font-size: .9rem;
  color: var(--muted);
}
.login-card input {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.login-card button {
  width: 100%;
  padding: .75rem;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.login-card button:hover { background: #1e3a8a; }
.alert {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: .6rem .8rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .9rem;
}

/* ===== Header ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-header h1 {
  margin: 0;
  font-size: 1.25rem;
}
.subtitle {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .85rem;
}
.logout-form {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
}
.user-chip {
  background: var(--accent-soft);
  color: var(--accent);
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  text-transform: capitalize;
}
.link-button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  padding: .25rem .5rem;
}
.link-button:hover { color: var(--accent); text-decoration: underline; }

.tabs {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  padding: 0 1.25rem;
  overflow-x: auto;
}
.tabs a {
  padding: .75rem 1rem;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Container ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.intro, .map-intro, .budget-intro {
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

h2 { margin-top: 2rem; }
h3 { margin-bottom: .5rem; }

/* ===== Itinerary ===== */
.day-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .25rem;
}
.day-num {
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 999px;
  letter-spacing: .02em;
}
.day-date {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
}
.day-card h3 {
  margin: .25rem 0 .5rem;
  font-size: 1.05rem;
}
.day-summary {
  margin: 0 0 .75rem;
  font-size: .92rem;
}
.day-meta {
  border-top: 1px solid var(--border);
  padding-top: .75rem;
  display: grid;
  gap: .35rem;
  font-size: .85rem;
}
.meta-label {
  color: var(--muted);
  margin-right: .25rem;
}
.day-stops { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.stop-pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
}

.day-list > li { list-style: none; }
.day-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.day-card-link:hover {
  text-decoration: none;
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(30,64,175,.12);
}
.day-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .75rem;
  padding-top: .65rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
}
.comment-badge {
  background: #f3f4f6;
  color: var(--muted);
  padding: .15rem .55rem;
  border-radius: 999px;
}
.comment-badge.has {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.day-cta {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Day detail ===== */
.breadcrumb {
  margin-bottom: 1rem;
  font-size: .9rem;
}
.day-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.day-detail-head h2 {
  margin: .35rem 0 .5rem;
  font-size: 1.5rem;
}
.day-detail-head .day-summary { margin-bottom: 1rem; }
.day-section {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.day-section h3 {
  margin-top: 0;
  font-size: 1.05rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.day-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .9rem 1rem;
  font-size: .95rem;
  line-height: 1.6;
}
.edit-details {
  margin-top: 1rem;
}
.edit-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: .9rem;
  padding: .4rem 0;
}
.details-form, .comment-form {
  margin-top: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.details-form textarea, .comment-form textarea {
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: .95rem;
  resize: vertical;
}
.details-form textarea:focus, .comment-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.form-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}
.form-actions button {
  padding: .55rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.form-actions button:hover { background: #1e3a8a; }

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.comment {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .85rem;
}
.comment-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
  font-size: .8rem;
}
.comment-author {
  font-weight: 700;
  color: var(--accent);
  text-transform: capitalize;
}
.comment-date {
  color: var(--muted);
}
.comment-del { margin-left: auto; }
.comment-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: .95rem;
  line-height: 1.5;
}

.comment-form { margin-top: 1rem; }

.day-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
}
.day-nav-link {
  color: var(--accent);
  font-weight: 500;
}
.day-nav-link.right { text-align: right; }

/* ===== Map ===== */
.map {
  height: 70vh;
  min-height: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #e5e7eb;
}
.map-legend {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
.map-legend summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
}
.map-legend ul {
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .35rem;
  font-size: .85rem;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: .4rem;
  vertical-align: middle;
}
.dot-city     { background: #2563eb; }
.dot-castle   { background: #7c3aed; }
.dot-nature   { background: #16a34a; }
.dot-ferry    { background: #0891b2; }
.dot-landmark { background: #ea580c; }
.dot-other    { background: #6b7280; }

/* ===== Budget ===== */
.budget-group {
  margin-top: 1.5rem;
  margin-bottom: .5rem;
  font-size: 1rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.budget-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.budget-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.budget-table tr:last-child td { border-bottom: 0; }
.budget-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 8rem;
}
.budget-summary { font-size: 1rem; }
.budget-summary .row-total td {
  background: var(--accent-soft);
  font-weight: 600;
}

/* ===== Notes ===== */
.note-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1rem 2.5rem;
  margin: 0 0 1.25rem;
}
.note-list li { margin-bottom: .5rem; }

.muted-small { color: var(--muted); font-size: .85rem; margin-top: 0; }

.booking-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.booking-table th, .booking-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
  text-align: left;
}
.booking-table th {
  background: #f9fafb;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.booking-table tr:last-child td { border-bottom: 0; }
.booking-confirmed td { background: #ecfdf5; }
.booking-paid td      { background: #d1fae5; }
.booking-researching td { background: #fef9c3; }
.booking-table select {
  padding: .3rem .4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: .85rem;
}
.details-input {
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .85rem;
  width: 100%;
  max-width: 280px;
}
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
}
.row-meta { font-size: .75rem; color: var(--muted); }

.todo-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  margin: 0 0 1rem;
  list-style: none;
}
.todo-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .65rem;
  border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: 0; }
.todo-item.done .todo-label {
  text-decoration: line-through;
  color: var(--muted);
}
.todo-toggle {
  background: none;
  border: 0;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 .15rem;
  color: var(--accent);
  line-height: 1;
}
.todo-label { flex: 1; font-size: .95rem; }
.todo-meta { font-size: .75rem; color: var(--muted); }
.todo-del { margin-left: auto; }
.link-button.mini { font-size: .75rem; padding: .1rem .35rem; }

.add-todo {
  display: flex;
  gap: .5rem;
  margin-bottom: 2rem;
}
.add-todo input {
  flex: 1;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
}
.add-todo button {
  padding: .55rem 1rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.add-todo button:hover { background: #1e3a8a; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: .85rem;
}

/* ===== Mobile tweaks ===== */
@media (max-width: 640px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .site-header h1 { font-size: 1.1rem; }
  .day-list { grid-template-columns: 1fr; }
  .map { height: 60vh; }
  .day-detail { padding: 1rem; }
  .day-detail-head h2 { font-size: 1.25rem; }
  .day-nav { flex-direction: column; }
  .day-nav-link.right { text-align: left; }
}
