:root {
  --navy: #1e3f63;
  --navy-dark: #15304d;
  --blue: #3f7ea6;
  --sky-light: #a9c9e3;
  --sky-mid: #e6d3c2;
  --sunset: #f0a868;
  --cream: #fdfcfa;
  --page-bg: #f8f9fb;
  --ink: #2a2a2a;
  --muted: #6b7280;
  --border: #dfe3e8;
  --tint: #eef4f8;
  --stripe: #f3f5f7;
  --success-bg: #e6f7ec;
  --success-border: #b6e3c6;
  --success-text: #1f6d3e;
  --error-bg: #fdecea;
  --error-border: #f3b4ac;
  --error-text: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* Site-wide background photo, shown as-is (all pages except the login /
     register screens, which set their own). */
  background:
    url("../img/allpages-bg.png") center top / cover no-repeat fixed,
    var(--page-bg);
  color: var(--ink);
  margin: 0;
  padding: 0 1rem 3rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  background: #fff;
  margin-left: -1rem;
  margin-right: -1rem;
  padding: 0 1rem;
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .9rem 0;
  display: flex;
  align-items: center;
  gap: .75rem 1.25rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--navy);
  text-decoration: none;
}

.brand__icon { width: 30px; height: auto; display: block; }

.brand__text {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: .02em;
}

.header-account {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .85rem;
  color: var(--muted);
  margin-left: auto;
}

.header-account__logout {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.header-account__logout:hover { text-decoration: underline; }

/* ---- Main navigation menu bar ---- */
.mainnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .15rem;
}

.mainnav__item {
  display: inline-block;
  padding: .4rem .7rem;
  color: var(--navy);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}
.mainnav__item::-webkit-details-marker { display: none; }
.mainnav > a.mainnav__item:hover,
.mainnav__dd > summary:hover { background: var(--tint); }
.mainnav__item.is-active { color: var(--navy); background: var(--sky-light); }

.mainnav__dd { position: relative; }
.mainnav__dd > summary::after {
  content: "\25BE";
  font-size: .7em;
  margin-left: .3rem;
  opacity: .65;
}
.mainnav__dd[open] > summary { background: var(--tint); }

.mainnav__menu {
  position: absolute;
  top: calc(100% + .3rem);
  left: 0;
  z-index: 50;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: .3rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(20, 40, 65, .16);
}
.mainnav__menu a {
  padding: .5rem .65rem;
  border-radius: 6px;
  color: var(--navy);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.mainnav__menu a:hover { background: var(--tint); }

/* Keep the last dropdown's menu from spilling off the right edge. */
.mainnav__dd:last-child .mainnav__menu { left: auto; right: 0; }

.admin-tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.admin-tabs a {
  padding: .6rem 0;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}

.admin-tabs a.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

.admin-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-panel h2 {
  margin-top: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--navy);
  font-size: 1.15rem;
}

.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1 1 200px; }

.pill-group { display: flex; flex-wrap: wrap; gap: .5rem; }

.pill-checkbox {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: .85rem;
  cursor: pointer;
}

.tag {
  display: inline-block;
  background: var(--tint);
  color: var(--navy);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .8rem;
  margin: 0 .25rem .25rem 0;
}

/* Breakdown bar (e.g. Wedding Documents: counts per month / per semester) */
.totals-bar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--tint);
  padding: .6rem .8rem;
  margin: 0 0 1rem;
}
.totals-bar__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem; }
.totals-bar__row + .totals-bar__row { margin-top: .45rem; }
.totals-bar__label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--navy);
  margin-right: .3rem;
}

.admin-badge {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: .1rem .55rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-danger { background: #b3261e; }
.btn-danger:hover { background: #8f1e18; }
.text-muted { color: var(--muted); font-size: .85rem; }

.file-multi__list { list-style: none; padding: 0; margin: .5rem 0 0; }
.file-multi__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .4rem .3rem .4rem .6rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: .35rem;
  font-size: .9rem;
}
.file-multi__name { word-break: break-all; }
.file-multi__remove {
  flex: none;
  background: transparent;
  color: #b3261e;
  border: none;
  padding: .1rem .5rem;
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}
.file-multi__remove:hover { background: #f7dedc; }
.file-multi__clear { margin-top: .25rem; }

main { max-width: 900px; margin: 0 auto; }

.ru { color: #888; font-weight: 400; }

fieldset {
  border: none;
  background: var(--tint);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

legend {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 .4rem;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
}

.field { margin-bottom: 1rem; }
label { display: block; font-size: .95rem; margin-bottom: .3rem; }
.req { color: #c0392b; }

input[type=text], input[type=email], input[type=number], input[type=password],
input[type=date], input[type=time], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(63, 126, 166, .15);
}

textarea { min-height: 5rem; resize: vertical; }
label.inline { display: inline-block; margin-right: 1rem; font-weight: 400; }

/* dd/mm/yyyy text field with a native calendar picker under the 📅 icon. The
   transparent <input type="date"> overlays only the icon area, so clicking it
   opens the browser picker without changing the visible text field. */
.date-field { position: relative; }
.date-field .date-field__text { padding-right: 2.2rem; }
.date-field .date-field__pick {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 2.2rem; display: grid; place-items: center;
}
.date-field .date-field__icon { font-size: .95rem; opacity: .6; pointer-events: none; line-height: 1; }
.date-field .date-field__native {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; background: transparent;
  opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.date-field .date-field__native::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; opacity: 0; cursor: pointer;
}
.date-field .date-field__native::-webkit-datetime-edit,
.date-field .date-field__native::-webkit-inner-spin-button,
.date-field .date-field__native::-webkit-clear-button { display: none; }

button, .btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: .7rem 1.6rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
  transition: background .15s ease;
}

button:hover, .btn:hover { background: var(--navy-dark); }

/* Small pill icon action (scan / save cells) */
button.icon-btn {
  background: var(--sky-light);
  color: var(--navy);
  border: 0;
  padding: .32rem .55rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  transition: background .12s ease, color .12s ease;
}
button.icon-btn:hover { background: var(--blue); color: #fff; }
button.icon-btn:active { transform: translateY(1px); }

/* Soft outline button (bulk "Scan amounts from PDFs") */
button.btn-soft, .btn-soft {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--blue);
  padding: .5rem 1.1rem;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .12s ease, color .12s ease;
}
button.btn-soft:hover, .btn-soft:hover { background: var(--blue); color: #fff; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }

thead th {
  background: var(--tint);
  color: var(--navy);
}

th, td {
  text-align: left;
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

.flash {
  padding: .6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.flash--error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

/* ---- Wedding Schedule list: wide table + per-row action menu ---- */

/* Break out of the centered 900px main column so the wide table has room. */
.table-wide {
  width: 94vw;
  max-width: 1400px;
  margin-left: 50%;
  transform: translateX(-50%);
}
/* Scroll box for the wide table: both axes, capped height so the header can
   freeze against its top. */
.table-wide .table-scroll {
  overflow: auto;
  max-height: 78vh;
}
.table-wide table { font-size: .82rem; }
.table-wide th,
.table-wide td { padding: .45rem .55rem; }
.table-wide td.nowrap,
.table-wide th.nowrap { white-space: nowrap; }

/* Frozen column headers. box-shadow (not border) draws the divider because a
   collapsed-border bottom edge doesn't stay put while the header is sticky. */
.sched-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--tint);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* Keep the grand-total row pinned to the bottom of the scroll box. */
.sched-table tr.grand-total td {
  position: sticky;
  bottom: 0;
  z-index: 2;
}

/* Zebra striping on data rows: white / light grey for readability. Total rows
   keep their own colour (they never get .stripe). */
.sched-table tbody tr.stripe td { background: var(--stripe); }

/* Whole row is a link to the edit page. Hover wins over the stripe. */
tr[data-edit-url] { cursor: pointer; }
.sched-table tbody tr[data-edit-url]:hover td { background: var(--tint); }

/* Kebab button + pop-up menu (used by both the button and right-click). */
.row-menu__btn {
  background: none;
  color: var(--navy);
  border: 1px solid var(--border);
  padding: .1rem .5rem;
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.row-menu__btn:hover { background: var(--tint); }

.row-menu__list {
  position: fixed;
  z-index: 100;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  padding: .3rem;
}
.row-menu__list a,
.row-menu__list button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--ink);
  border: none;
  padding: .5rem .6rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.row-menu__list a:hover,
.row-menu__list button:hover { background: var(--tint); }
.row-menu__list form { margin: 0; }
.row-menu__list button[type=submit] { color: var(--error-text); }

/* Paired sub-fields on the schedule form (select + amount, time range, etc.) */
.field-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.field-row > select,
.field-row > input { width: auto; flex: 1 1 12rem; min-width: 7rem; }
.field-row > select.compact,
.field-row > input.compact { flex: 0 0 8.5rem; min-width: 0; }
.field-row > .sep { flex: 0 0 auto; color: var(--muted); }

/* Sortable column headers */
.sort-link { color: var(--navy); text-decoration: none; display: inline-block; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }

/* Monthly subtotal + grand total rows in the schedule list */
.sched-table tr.month-total td {
  background: var(--sky-light);
  font-weight: 600;
  border-top: 2px solid var(--blue);
}
.sched-table tr.year-total td {
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  border-top: 2px solid var(--navy);
}
.sched-table tr.grand-total td {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

/* Canceled weddings: red text throughout the row. */
.sched-table tr.canceled td { color: var(--error-text); }

/* ---- Schedule calendar view ---- */
table.cal { table-layout: fixed; width: 100%; border-collapse: collapse; min-width: 40rem; }
table.cal th {
  background: var(--tint);
  color: var(--navy);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .4rem;
  text-align: center;
  border: 1px solid var(--border);
}
table.cal td.cal-day {
  border: 1px solid var(--border);
  vertical-align: top;
  height: 6.5rem;
  padding: .25rem .3rem .35rem;
}
.cal-num { font-size: .78rem; color: var(--muted); text-align: right; }
.cal-num__link { color: inherit; text-decoration: none; }
.cal-num__link:hover { text-decoration: underline; }
td.cal-out { background: var(--stripe); }
td.cal-out .cal-num { opacity: .45; }
td.cal-today { outline: 2px solid var(--blue); outline-offset: -2px; }
td.cal-today .cal-num { color: var(--blue); font-weight: 700; }
.cal-ev {
  display: block;
  font-size: .76rem;
  line-height: 1.3;
  background: var(--sky-light);
  color: var(--navy);
  border-radius: 4px;
  padding: .12rem .3rem;
  margin-top: .18rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.cal-ev:hover { background: var(--blue); color: #fff; }
.cal-ev.canceled {
  background: var(--error-bg);
  color: var(--error-text);
  text-decoration: line-through;
}
.cal-t { font-weight: 700; }

/* ==========================================================================
   Responsive: tablet / mobile
   ========================================================================== */

/* Hamburger toggle for the main nav — hidden on desktop, shown once the nav
   itself collapses below the ~860px breakpoint. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 38px;
  height: 34px;
  padding: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--navy);
  border-radius: 1px;
  transition: transform .15s ease, opacity .15s ease;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
  body { padding: 0 .75rem 2.5rem; }
  main { max-width: 100%; }
  .table-wide { width: 100%; margin-left: 0; transform: none; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; order: 2; margin-left: auto; }
  .header-account { order: 3; margin-left: .6rem; font-size: .8rem; gap: .6rem; }

  /* The nav itself collapses into a full-width panel under the header,
     opened by .nav-toggle (JS toggles .is-open on both). */
  .mainnav {
    display: none;
    order: 4;
    flex-basis: 100%;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid var(--border);
    margin-top: .75rem;
    padding-top: .4rem;
  }
  .mainnav.is-open { display: flex; }
  .mainnav > a.mainnav__item,
  .mainnav__dd > summary.mainnav__item {
    width: 100%;
    padding: .7rem .5rem;
    border-radius: 6px;
  }
  .mainnav__dd { width: 100%; }
  .mainnav__menu {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    min-width: 0;
    padding-left: 1rem;
    margin-bottom: .3rem;
  }
  .mainnav__dd:last-child .mainnav__menu { left: auto; right: auto; }
}

@media (max-width: 640px) {
  .header-account__email {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand__text { font-size: 1.05rem; }

  fieldset { padding: 1rem 1rem; }
  .admin-panel { padding: 1rem; }

  button, .btn { padding: .65rem 1.2rem; }
}

/* Tab bar on the admin pages: wrap instead of overflowing the viewport. */
.admin-tabs { flex-wrap: wrap; row-gap: .5rem; }

/* Any plain (non .table-wide, non calendar) table scrolls horizontally
   rather than squeezing its columns unreadably narrow. */
@media (max-width: 900px) {
  main table:not(.table-wide table):not(table.cal) {
    display: block;
    width: auto;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  main table:not(.table-wide table):not(table.cal) th,
  main table:not(.table-wide table):not(table.cal) td {
    white-space: nowrap;
  }
}

/* iOS Safari renders a fixed background photo poorly / with jank — fall back
   to a normal scrolling background below tablet width. */
@media (max-width: 900px) {
  body { background-attachment: scroll, scroll; }
}
