:root {
  --ink: #1f2933;
  --muted: #607080;
  --paper: #fffaf2;
  --line: #d9e2e8;
  --blue: #315c85;
  --green: #1f7a5a;
  --yellow: #f2b84b;
  --coral: #d45b49;
  --violet: #7752a0;
  --shadow: 0 18px 40px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(49, 92, 133, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(49, 92, 133, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 22px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.12);
  background: rgba(255, 250, 242, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 38px;
  line-height: 1.05;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
}

.actions,
.dialog-actions,
.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.08);
}

.button.primary {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.74);
}

.button.danger {
  color: white;
  border-color: #a43f33;
  background: #a43f33;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px 36px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
}

.panel {
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.sidebar-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel h2,
.workspace h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfc;
}

.stat strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: 10px;
}

.check-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 14px;
}

.check-item input {
  margin-top: 3px;
  accent-color: var(--green);
}

.tips {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.view-tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  padding: 8px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.view-tab span {
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(31, 41, 51, 0.08);
}

.view-tab.active {
  border-color: rgba(49, 92, 133, 0.18);
  color: var(--blue);
  background: linear-gradient(135deg, rgba(49, 92, 133, 0.14), rgba(242, 184, 75, 0.18));
}

.view-tab.active span {
  color: white;
  background: var(--blue);
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 0 2px;
}

.board-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 999px;
}

.dot.go {
  background: var(--green);
}

.dot.free {
  background: var(--blue);
}

.dot.booked {
  background: var(--coral);
}

.day-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
  align-items: start;
}

.day {
  min-width: 0;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 8px;
  overflow: clip;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

/* Activities strip scroll needs the rounded corners preserved but not clipped */
.day-view .day { overflow: visible; }

.day-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: white;
  background: var(--blue);
}

.complete-day-btn {
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 6px 12px;
  color: white;
  background: rgba(255,255,255,0.18);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  text-align: right;
}

.day-header.go-pass {
  background: var(--green);
}

.day-header.special {
  background: var(--coral);
}

.day-header h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

.day-header p {
  margin: 0;
  opacity: 0.88;
  font-size: 13px;
}

.day-score {
  text-align: right;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.activities {
  display: grid;
  gap: 10px;
  min-height: 80px;
  padding: 12px;
}

.day-tools {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
}

.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--blue);
  background: #f8fbfc;
  font-size: 13px;
  font-weight: 900;
}

.activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  cursor: grab;
}

.activity:active {
  cursor: grabbing;
}

.activity.dragging {
  opacity: 0.55;
  outline: 2px dashed var(--yellow);
}

.activity-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.activity-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pool-header,
.pool-empty {
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 12px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.pool-header p,
.pool-empty p {
  margin-bottom: 0;
  color: var(--muted);
}

.pool-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.pool-card {
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 12px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 252, 0.92));
  box-shadow: var(--shadow);
}

.pool-card h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.pool-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin-top: 14px;
}

.pool-day-select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font-weight: 700;
}

.mini-icon {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  background: #f8fbfc;
  font-weight: 900;
}

.activity h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.time-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  color: white;
  background: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.desc {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
  color: #314252;
  background: #f3f7f8;
  font-size: 12px;
  font-weight: 800;
}

.tag.go-city {
  color: #0f5138;
  background: #dff4e9;
}

.tag.booked {
  color: #7a2e25;
  background: #ffe4df;
}

.tag.optional {
  color: #60430f;
  background: #fff1c7;
}

.tag.metro-tag {
  color: #143f61;
  background: #dceefa;
  border-color: rgba(49, 92, 133, 0.22);
}

.tag.walk-tag {
  color: #425466;
  background: #eef3f1;
}

.tag.near-home {
  color: #8d1f1f;
  background: #fde3e3;
  border-color: rgba(173, 41, 41, 0.25);
}

.map-link {
  border: 1px solid rgba(49, 92, 133, 0.22);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--blue);
  background: #eaf3fb;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.day-notes {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fbf7ec;
}

.day-notes label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.day-notes textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--ink);
  background: white;
}

.plan-select {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}

.export-dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(31, 41, 51, 0.35);
}

.export-dialog::backdrop {
  background: rgba(31, 41, 51, 0.42);
}

.export-dialog form {
  padding: 18px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.dialog-head h2 {
  margin: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

#exportText {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfbfb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.dialog-actions.split {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: white;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.form-grid .check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
}

.form-grid .check-field input {
  width: auto;
  accent-color: var(--green);
}


/* ── Login ─────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(90deg, rgba(49,92,133,0.08) 1px, transparent 1px),
    linear-gradient(rgba(49,92,133,0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  z-index: 100;
}

.login-card {
  width: min(400px, calc(100vw - 32px));
  border: 1px solid rgba(31,41,51,0.12);
  border-radius: 16px;
  padding: 36px 32px;
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  margin-bottom: 16px;
}

.login-card h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

.login-sub {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

.login-label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-label input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  font-size: 15px;
  font-weight: 500;
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  font-size: 15px;
}

.login-error {
  margin-bottom: 14px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #7a2e25;
  background: #ffe4df;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.login-register-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.login-register-hint a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.sync-indicator {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.7;
}

/* ── View mode toggle ─────────────────────────────────────────── */
.view-mode-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.mode-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.mode-btn.active {
  border-color: rgba(49,92,133,0.3);
  color: var(--blue);
  background: rgba(49,92,133,0.1);
}

/* ── Day view (Por día) ───────────────────────────────────────── */
.day-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(31,41,51,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
}

.day-nav-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 900;
  color: var(--blue);
  background: white;
  cursor: pointer;
}

.day-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.day-nav-info {
  flex: 1;
  text-align: center;
}

.day-nav-title {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.day-nav-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

/* Horizontal activity strip in day view */
.activities-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.activities-strip .activity {
  flex: 0 0 min(320px, 82vw);
  scroll-snap-align: start;
}

/* ── Completed days ───────────────────────────────────────────── */
.completed-days-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.completed-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.9);
}

.completed-day-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.completed-day-header span:last-child {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.completed-day-header.go-pass { color: var(--green); }
.completed-day-header.special { color: var(--coral); }

/* ── Mobile responsive (iPhone 11: 414px, iPhone 15: 393px) ──── */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px 14px;
    gap: 12px;
  }

  h1 { font-size: 28px; }

  .actions { gap: 8px; }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px 16px 24px;
    gap: 16px;
  }

  .sidebar { display: none; } /* Hidden on mobile — info secundaria */

  .view-tabs {
    gap: 6px;
    padding: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .view-tab {
    padding: 9px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .view-mode-toggle { margin-bottom: 10px; }

  .day-board {
    grid-template-columns: 1fr;
  }

  .day-header h3 { font-size: 15px; }
  .day-header p  { font-size: 12px; }

  .activity { touch-action: pan-y; }

  .activity-head { gap: 8px; }

  .activity h4 { font-size: 14px; }

  .mini-icon {
    width: 36px;
    height: 36px;
  }

  /* Vertical stack on mobile — more readable than horizontal scroll */
  .activities-strip {
    display: grid;
    overflow-x: unset;
    scroll-snap-type: unset;
  }

  .activities-strip .activity {
    flex: unset;
    scroll-snap-align: unset;
  }

  .day-nav-btn {
    min-width: 48px;
    min-height: 48px;
    font-size: 20px;
  }

  .day-nav-title { font-size: 14px; }

  .pool-list { grid-template-columns: 1fr; }

  .pool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .completed-day-row {
    flex-wrap: wrap;
  }

  .form-grid { grid-template-columns: 1fr; }

  .dialog-actions.split {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .export-dialog {
    width: calc(100vw - 16px);
  }
}

@media (max-width: 430px) {
  .topbar { padding: 14px 14px 12px; }

  h1 { font-size: 24px; }

  .subtitle { font-size: 12px; }

  .button { padding: 9px 12px; font-size: 13px; }

  .view-tab span {
    min-width: 18px;
    padding: 2px 5px;
    font-size: 11px;
  }

  .activities-strip .activity {
    flex: 0 0 92vw;
  }
}

/* ── Search ───────────────────────────────────────────────────── */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 40px 11px 14px;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(31,41,51,0.08);
  -webkit-appearance: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49,92,133,0.12);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(31,41,51,0.1);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-results {
  display: grid;
  gap: 10px;
}

.search-count {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-result-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: white;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.search-day-badge {
  border-radius: 999px;
  padding: 3px 9px;
  color: white;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.search-day-badge.muted {
  background: var(--muted);
}

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

@media (max-width: 768px) {
  .search-input { font-size: 16px; } /* Prevent iOS zoom on focus */
}

/* ── Booked list ──────────────────────────────────────────────── */
.booked-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.booked-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  background: white;
}

.booked-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.booked-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}

.booked-info span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
