/* FWC Service Planner
   One typeface (Atkinson Hyperlegible, chosen for legibility in a dim booth and on phones).
   Liturgical purple is the single accent; the order of service is the page's centerpiece. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-latin-400-normal.82a5516b3709.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-latin-700-normal.833b135521b5.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --page: #f3f5f8;
  --surface: #ffffff;
  --ink: #18233b;
  --ink-soft: #55607a;
  --line: #d7dce4;
  --accent: #5b3a8c;
  --accent-ink: #ffffff;
  --accent-soft: #efe9f7;
  --danger: #a3262e;
  --danger-soft: #fbeaeb;
  --ok: #1f6b45;
  --ok-soft: #e5f4ec;
  --warn-bg: #fbe9c2;
  --warn-ink: #5c3b00;
  --focus: #2f6fe0;
  --radius-s: 6px;
  --radius-m: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #12151c;
    --surface: #1b2029;
    --ink: #e7eaf0;
    --ink-soft: #a3abbc;
    --line: #2f3644;
    --accent: #b9a2e6;
    --accent-ink: #1b1428;
    --accent-soft: #2a2238;
    --danger: #f08a90;
    --danger-soft: #3a1d21;
    --ok: #79d3a3;
    --ok-soft: #173126;
    --warn-bg: #3d2f12;
    --warn-ink: #f5d58f;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}
h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 21px;
  font-weight: 700;
}
h3 {
  font-size: 17px;
  font-weight: 700;
}

p {
  margin: 0 0 0.75em;
}

.muted {
  color: var(--ink-soft);
}
.small {
  font-size: 15px;
}
.nowrap {
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Top bar ------------------------------------------------------------ */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.brand span {
  color: var(--accent);
}
.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  font-size: 15px;
}
.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--accent-soft);
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--ink-soft);
}
.who form {
  margin: 0;
}

.banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 10px 20px;
  text-align: center;
  font-weight: 700;
}

/* ---- Page frame --------------------------------------------------------- */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}
.narrow {
  max-width: 640px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head .sub {
  margin-top: 6px;
  color: var(--ink-soft);
}
.back {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 15px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 20px;
}
.panel + .panel {
  margin-top: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ---- Messages ------------------------------------------------------------ */

.messages {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}
.messages li {
  padding: 10px 14px;
  border-radius: var(--radius-s);
  margin-bottom: 8px;
  background: var(--accent-soft);
}
.messages .success {
  background: var(--ok-soft);
  color: var(--ok);
}
.messages .error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---- Buttons & forms ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--ink-soft);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  border-color: var(--danger);
}
.btn-small {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 15px;
}
.btn-link {
  background: none;
  border: none;
  padding: 0;
  min-height: 0;
  color: var(--accent);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-form {
  display: inline;
  margin: 0;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.field {
  margin-bottom: 18px;
}
.field .help {
  font-size: 15px;
  color: var(--ink-soft);
  margin-top: 4px;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 9px 12px;
  min-height: 44px;
}
textarea {
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
}
.checks li {
  margin: 4px 0;
}
.checks label,
label.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
}
.checks input,
label.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: none;
}
.errorlist {
  color: var(--danger);
  list-style: none;
  padding: 0;
  margin: 4px 0;
  font-size: 15px;
}

/* ---- Services list -------------------------------------------------------- */

.search {
  display: flex;
  gap: 8px;
  flex: 1 1 320px;
  max-width: 440px;
}
.page-head > .btn-row {
  flex: 1 1 auto;
  justify-content: flex-end;
}
.service-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.service-list li {
  border-bottom: 1px solid var(--line);
}
.service-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 4px;
  border-left: 4px solid transparent;
  color: var(--ink);
  text-decoration: none;
}
.service-row:hover {
  background: var(--accent-soft);
}
.datechip {
  text-align: center;
  line-height: 1.05;
}
.datechip .day {
  display: block;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.datechip .mon {
  display: block;
  font-size: 14px;
  color: var(--ink-soft);
}
.service-row .title {
  font-weight: 700;
  font-size: 18px;
}
.service-row .meta {
  font-size: 15px;
  color: var(--ink-soft);
}
.service-row .count {
  font-size: 15px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.next-up {
  border-left-color: var(--accent);
}
.section-gap {
  margin-top: 40px;
}
.empty {
  padding: 28px 0;
  color: var(--ink-soft);
}

/* ---- Service page --------------------------------------------------------- */

.service-head h1 {
  font-size: 34px;
}
.service-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .service-grid {
    grid-template-columns: 1fr;
  }
  .service-head h1 {
    font-size: 28px;
  }
}
.service-grid > .panel + .panel {
  margin-top: 0;
}
.notes {
  white-space: pre-wrap;
}

/* The run sheet: the memorable part of the app. */
.runsheet {
  list-style: none;
  margin: 0;
  padding: 0;
}
.runsheet .sec {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 19px;
}
.runsheet .sec:first-child {
  margin-top: 0;
}
.runsheet .sec::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--accent);
  opacity: 0.35;
}
.runsheet .row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.runsheet .row:last-child {
  border-bottom: none;
}
.runsheet .time {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: break-word;
  hyphens: none;
}
.runsheet .what {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}
.runsheet .item-notes {
  color: var(--ink-soft);
  font-size: 16px;
  margin-top: 4px;
  white-space: pre-wrap;
}
.runsheet .linked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.filechip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
}
.filechip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filechip:hover {
  outline: 1px solid var(--accent);
}

/* Files */
.files {
  list-style: none;
  margin: 0;
  padding: 0;
}
.files > li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.files > li:last-child {
  border-bottom: none;
}
.file-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.file-kind {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-s);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.file-main {
  flex: 1;
  min-width: 0;
}
.file-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.file-meta {
  font-size: 14px;
  color: var(--ink-soft);
}
.file-notes {
  margin-top: 6px;
  font-size: 16px;
  white-space: pre-wrap;
}
@media (max-width: 560px) {
  .runsheet .row {
    grid-template-columns: 5.25rem 1fr;
    gap: 12px;
  }
  .runsheet .time {
    font-size: 17px;
  }
  .runsheet .what {
    font-size: 18px;
  }
  .file-top {
    flex-wrap: wrap;
  }
  .file-top > .btn {
    margin-left: 56px;
  }
  .file-main {
    flex-basis: calc(100% - 56px);
  }
}
details.manage {
  margin-top: 8px;
}
details.manage summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 15px;
}
details.manage[open] summary {
  margin-bottom: 8px;
}

/* ---- Upload --------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-m);
  padding: 32px 20px;
  text-align: center;
  background: var(--surface);
}
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone input[type="file"] {
  display: none;
}
.queue {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}
.queue li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px;
  margin-bottom: 10px;
}
.queue .qhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.queue .qname {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.queue textarea {
  margin-top: 8px;
  min-height: 44px;
}
.bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.bar > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}
.qstatus {
  font-size: 15px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.qstatus.done {
  color: var(--ok);
}
.qstatus.failed {
  color: var(--danger);
}

/* ---- Order editor ---------------------------------------------------------- */

.editor {
  list-style: none;
  margin: 0;
  padding: 0;
}
.editor > li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 12px;
  margin-bottom: 8px;
}
.editor > li.is-header {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}
.handle {
  cursor: grab;
  touch-action: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-s);
  color: var(--ink-soft);
  font-size: 22px;
  user-select: none;
  min-height: 44px;
}
.handle:hover {
  background: var(--page);
}
.sortable-ghost {
  opacity: 0.4;
}
.ed-summary {
  display: flex;
  gap: 14px;
  align-items: baseline;
  min-height: 28px;
}
.ed-time {
  flex: none;
  min-width: 5.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ed-title {
  font-weight: 700;
  font-size: 18px;
}
.ed-header {
  color: var(--accent);
}
.ed-notes {
  color: var(--ink-soft);
  font-size: 15px;
  margin-top: 2px;
}
.editor .linked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.editor .grid2,
.editor-add .grid2 {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 8px;
}
@media (max-width: 560px) {
  .ed-summary {
  display: flex;
  gap: 14px;
  align-items: baseline;
  min-height: 28px;
}
.ed-time {
  flex: none;
  min-width: 5.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ed-title {
  font-weight: 700;
  font-size: 18px;
}
.ed-header {
  color: var(--accent);
}
.ed-notes {
  color: var(--ink-soft);
  font-size: 15px;
  margin-top: 2px;
}
.editor .linked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.editor .grid2,
.editor-add .grid2 {
    grid-template-columns: 1fr;
  }
}
.editor .field {
  margin-bottom: 8px;
}
.editor details.manage label {
  font-size: 14px;
  margin-bottom: 2px;
  color: var(--ink-soft);
}
.save-state {
  font-size: 15px;
  color: var(--ok);
  min-height: 1.5em;
}

/* ---- Tables (log, trash, passwords) ---------------------------------------- */

.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--ink-soft);
  font-weight: 700;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.filters .field {
  margin: 0;
}
.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

/* ---- Login ------------------------------------------------------------------ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login {
  width: 100%;
  max-width: 400px;
}
.login h1 {
  font-size: 28px;
  margin-bottom: 4px;
}
.login .church {
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 24px;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ok);
}
.status-dot.off {
  background: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media print {
  .topbar,
  .banner,
  .btn,
  details.manage,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel {
    border: none;
    padding: 0;
  }
  .service-grid {
    grid-template-columns: 1fr;
  }
}
