:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --panelBorder: #d1d9e2;
  --text: #0e1b2a;
  --muted: #6e7f91;

  /* Matches your one-pager - UNTOUCHED FOR PDF */
  --navy: #0d3a5c;
  --teal: #1a7a88;
  --ink: #0e1b2a;
  --grey: #6e7f91;
  --lightgrey: #8a9bb0;
  --line: #cfe0ee;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --tentative: #c46a1a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), #eef1f5);
  color: var(--text);
  background-attachment: fixed;
}

.app {
  max-width: 1100px;
  margin: 22px auto 60px;
  padding: 0 16px;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--panelBorder);
  border-radius: 14px;
  padding: 16px 16px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* FIRESTORE MIGRATION: Updated to style pagination buttons */
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--panelBorder);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: #0092aa;
  /* ECF Primary */
  color: white;
  border-color: #055068;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn.secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.btn.secondary:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.08);
}

.status-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.hint {
  font-size: 12px;
  color: rgba(110, 127, 145, 0.85);
  /* Adjusted for light UI */
  text-align: right;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: #055068;
  /* Adjusted for light UI visibility */
}

.preview-shell {
  margin-top: 18px;
}

.preview-label {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}

.capture-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* FIRESTORE MIGRATION: Multi-page display logic */
.page-wrap {
  display: none;
  /* Hide inactive pages by default */
}

.page-wrap.active {
  display: block;
  /* Show only current page */
}

/* When exporting, stack all pages temporarily */
.capture-wrap.pdf-exporting .page-wrap {
  display: block;
  margin-bottom: 24px;
}

/* -------- PDF STYLES REMAIN UNCHANGED BELOW THIS LINE -------- */

/* A4 at ~96dpi */
.page.a4 {
  width: 794px;
  height: 1123px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

/* Header */
.page-header {
  background: var(--navy);
  color: #fff;
  padding: 20px 28px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 6px solid var(--teal);
  box-shadow: 0 2px 0 rgba(26, 122, 136, 0.30);
}

.title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.1px;
}

.subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 600;
}

.pill {
  background: #ffffff;
  color: var(--navy);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.page-inner {
  padding: 22px 28px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Two-column flow like your PDF */
.content {
  flex: 1;
  columns: 2;
  column-gap: 34px;
  column-fill: auto;
  color: var(--ink);
}

/* Month block should not split */
.month {
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 6px;
}

/* month bar like your reference */
.month-title {
  display: block;
  width: 100%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.6px;
  font-size: 12px;
  padding: 5px 12px;
  margin: 0 0 2px 0;
}

/* row: less padding + same separator line */
.event {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 6px;
  padding: 5px 0 6px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.date {
  font-size: 11px;
  color: var(--navy);
  font-weight: 800;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
}

.event-right {
  width: 100%;
  padding: 2px 6px;
  border-radius: 0;
  background: transparent;
  border-left: 2px solid transparent;
}

.summary {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
}

.subline {
  font-size: 11px;
  color: var(--grey);
  line-height: 1.2;
  margin-top: 2px;
}

.subline.note {
  font-style: italic;
  color: var(--grey);
}

.link-row {
  margin-top: 3px;
  display: block;
  gap: 6px;
  max-width: 100%;
}

.link-btn {
  display: inline-block;
  margin-right: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 600;
  font-size: 10.5px;
  color: var(--grey);
  text-decoration: underline;

  /* wrap safely */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
}

.link-btn:hover {
  background: rgba(26, 122, 136, 0.16);
}

/* FIRESTORE MIGRATION: Category Legend Styles */
.legend-wrap {
  margin-top: auto;
  padding-top: 10px;
}

.legend {
  display: flex;
  flex-direction: column;
  /* Stack vertically to handle longer explanations */
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.legend-item {
  display: flex;
  align-items: flex-start;
  /* Align to top in case text wraps to multiple lines */
  gap: 8px;
  font-size: 10px;
  color: var(--navy);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  margin-top: 2px;
  /* Align dot nicely with the first line of text */
}

.legend-title {
  font-weight: 700;
  text-transform: uppercase;
}

.legend-expl {
  font-weight: 400;
  color: var(--grey);
}

.footer {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--lightgrey);
}

.preview-note {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(110, 127, 145, 0.85);
  /* Adjusted for light UI */
  text-align: center;
}

@media (max-width: 860px) {
  .input-row {
    flex-wrap: wrap;
  }
}