/* Transcripts Web — colours follow the desktop app (slate header #5F6A72, selection #68ADF3) */
:root {
  --slate: #5f6a72;
  --slate-dark: #4a545b;
  --accent: #2f7fd1;
  --accent-soft: #68adf3;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7680;
  --line: #dde1e5;
  --danger: #c0392b;
  --ok: #2e7d4f;
  --warn: #9a6a00;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .2rem; font-weight: 600; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; margin: 0 0 .8rem; }
h4 { font-size: .95rem; margin: 1.1rem 0 .5rem; color: var(--slate-dark); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt { margin-top: 1rem; }
.pre { white-space: pre-wrap; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* ---- Top bar & layout ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
  height: 56px; padding: 0 1rem; background: var(--slate); color: #fff; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 600; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 6px; background: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.who { font-size: .9rem; text-align: right; line-height: 1.15; }
.who small { display: block; opacity: .8; }
a.who { color: #fff; }
a.who:hover { text-decoration: none; opacity: .85; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 200px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: .8rem 0; }
.sidebar a { display: block; padding: .6rem 1.2rem; color: var(--text); font-size: 1rem; border-left: 3px solid transparent; }
.sidebar a:hover { background: #f0f4f8; text-decoration: none; }
.sidebar a.active { border-left-color: var(--accent); background: #eaf3fd; font-weight: 600; }
.content { flex: 1; min-width: 0; padding: 1.4rem 1.8rem 3rem; max-width: 1280px; }

/* ---- Cards, headings ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1rem; }
.card.narrow { max-width: 640px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head.sticky { position: sticky; top: 56px; z-index: 20; background: var(--bg); padding: .6rem 0; margin-top: -.6rem; }
.page-head .tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.back { font-size: .9rem; }
.hero { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.hero img { width: 72px; height: 72px; border-radius: 12px; }
.hero.small img { width: 56px; height: 56px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.stat .num { font-size: 1.8rem; font-weight: 600; color: var(--slate-dark); }
.stat .lbl { color: var(--muted); }
.actions-row { display: flex; gap: .6rem; margin-bottom: 1rem; }
.notice { background: #fff8e6; border: 1px solid #f0d58c; border-radius: 6px; padding: .6rem .8rem; color: #6b4e00; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); background: #fafbfc; border: 1px dashed var(--line); border-radius: var(--radius); }
.hint { color: var(--muted); font-size: .85rem; margin: .8rem 0 0; }

/* ---- Flash ---- */
.flash { padding: .65rem .9rem; border-radius: 6px; margin-bottom: .8rem; border: 1px solid; }
.flash-ok { background: #ecf7f0; border-color: #b6dfc5; color: var(--ok); }
.flash-error { background: #fdeeee; border-color: #efc0bb; color: var(--danger); }
.flash-warn { background: #fff8e6; border-color: #f0d58c; color: var(--warn); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .48rem .95rem; border: 1px solid var(--line);
  background: #fff; color: var(--text); border-radius: 6px; font: inherit; font-size: .93rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f6f8; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2569b0; }
.btn-danger { color: var(--danger); border-color: #efc0bb; }
.btn-danger:hover { background: #fdeeee; }
.btn-ghost { background: transparent; }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; margin-top: .6rem; }
.btn:disabled { opacity: .5; cursor: default; }
form.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---- Forms ---- */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
label.check, label.radio { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-size: .93rem; font-weight: 400; }
label.check { align-self: end; padding-bottom: .5rem; }
input, select, textarea { font: inherit; font-size: .95rem; color: var(--text); padding: .45rem .6rem; border: 1px solid #c9cfd5;
  border-radius: 6px; background: #fff; width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent-soft); }
input.readonly, input[readonly] { background: #f4f6f8; }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #fafbfc; color: var(--text); border-color: #e3e6e9; }
.req { color: var(--danger); }
.pair { display: flex; gap: .4rem; align-items: center; }
.grid2, .grid3, .grid4 { display: grid; gap: .8rem 1rem; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
/* a two-column cell split 3:1 (e.g. Disposed (if elsewhere) + Cremated) */
.split-3-1 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: .8rem 1rem; }
.cell { display: flex; align-items: end; padding-bottom: .3rem; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.file input { padding: .3rem; }
.events { display: grid; gap: .5rem; }
/* Date, Place, Place details, BDM reference, District: place details is the same width as place */
.ev-head, .ev-row { display: grid; grid-template-columns: 70px 1fr 1.6fr 1.6fr 1fr 1fr; gap: .6rem; align-items: center; }
.ev-head span { font-size: .8rem; color: var(--muted); }
.ev-label { font-weight: 600; color: var(--slate-dark); }
.events + .grid4 { margin-top: 1rem; }
.ev-sub { margin-top: -.15rem; }
.ev-sublabel { display: block; font-size: .85rem; color: var(--slate-dark); font-weight: 600; }
.import-mode { display: grid; gap: .35rem; margin: .4rem 0 .2rem; }
.import-mode label.radio { align-items: flex-start; font-size: .9rem; }
.import-mode label.radio input { width: auto; margin-top: .2rem; flex: none; }
.register-form { max-width: 900px; }
.register-form > label { max-width: 480px; }
.reg-cems { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .8rem; margin: 1rem 0; }
.reg-cems legend, .reg-options legend { font-weight: 600; padding: 0 .3rem; }
.reg-cem-tools { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.reg-cem-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .2rem 1rem; max-height: 320px; overflow: auto; }
.reg-cem-list label.check, .reg-options label.radio { display: flex; flex-direction: row; gap: .5rem; align-items: flex-start; font-size: .92rem; color: var(--text); }
.reg-cem-list input, .reg-options input { width: auto; flex: none; margin-top: .2rem; }
.reg-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.reg-options fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .8rem; margin: 0; display: grid; gap: .35rem; }
.login-guest { margin-top: .6rem; text-align: center; }
.combo { position: relative; display: block; }
.combo input { padding-right: 1.9rem; }
/* the same arrow as a drop-down (select) box, inside the right-hand edge */
.combo-btn { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 1.7rem; border: 0; padding: 0; cursor: pointer;
  border-radius: 0 6px 6px 0; font-size: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23202124' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center; }
fieldset:disabled .combo-btn { cursor: default; opacity: .5; }

/* ---- Search ---- */
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.searchbar input[type=search] { flex: 1 1 280px; width: auto; }
.searchbar select { width: auto; max-width: 260px; }
.searchbar .chk-inline { display: inline-flex; flex-direction: row; align-items: center; color: var(--text); font-size: .93rem; gap: .35rem; white-space: nowrap; margin: 0; font-weight: normal; }
.searchbar .chk-inline input { width: auto; margin: 0; }
.searchbar.big input { font-size: 1.1rem; padding: .7rem .9rem; }
.adv h3 { margin-bottom: .2rem; }
.result-info { color: var(--muted); font-size: .9rem; margin: .2rem 0 .5rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; background: #fff; }
table.grid th { background: var(--slate); color: #fff; text-align: left; font-weight: 500; padding: .55rem .7rem; font-size: .88rem; white-space: nowrap; }
table.grid th a { color: #fff; }
table.grid th a.on::after { content: " ▾"; }
table.grid td { padding: .5rem .7rem; border-top: 1px solid #edf0f2; vertical-align: top; }
table.grid tbody tr:nth-child(even) td { background: #fafbfc; }
table.grid tr.rowlink { cursor: pointer; }
table.grid tr.rowlink:hover td { background: #eaf3fd; }
/* the record the user has just come back from (burials.php#pN) */
table.grid tbody tr { scroll-margin-top: 120px; scroll-margin-bottom: 40px; }
table.grid tbody tr:target td { background: #fff4c2; }
table.grid tbody tr:target td:first-child { box-shadow: inset 4px 0 0 #e0a800; }
table.grid td.num, table.grid th.num { text-align: right; }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.card table.grid { border: 1px solid var(--line); }
table.merge td, table.merge th { vertical-align: top; }
table.merge tbody th { background: #f4f6f8; color: var(--text); width: 18%; }
table.merge tr.diff td { background: #fffbea !important; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: .3rem 1rem .3rem 0; vertical-align: top; }
.pager { display: flex; gap: .3rem; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager a.current { background: var(--accent); color: #fff; border-color: var(--accent); }
ul.plainlist { list-style: none; padding: 0; margin: 0; }
ul.plainlist li { padding: .25rem 0; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: .2rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem 1rem; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { background: #e8ecef; color: var(--muted); border-radius: 10px; padding: 0 .45rem; font-size: .75rem; }
.tab-disabled { padding: .55rem 1rem; color: #b5bcc3; font-size: .9rem; }
.js .tabpanel { display: none; }
.js .tabpanel.active { display: block; }
.js .tabpanel-extra { display: none; }
.js .tabpanel-extra.active { display: block; }
.subform { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .2rem; }
.subform.editing { background: #f5f9fe; margin-left: -1.4rem; margin-right: -1.4rem; padding-left: 1.4rem; padding-right: 1.4rem; padding-bottom: 1rem; }

/* ---- Image ---- */
.thumb { display: inline-block; margin-top: .6rem; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; max-width: 320px; }
.thumb img { display: block; max-width: 100%; max-height: 260px; }
.thumb.missing::after { content: "Image file not found on the server"; display: block; padding: .8rem; color: var(--muted); font-size: .85rem; }
.thumb.missing img { display: none; }

/* ---- Dropdown ---- */
.dropdown { position: relative; }
.dropdown .menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 220px; z-index: 40; }
.dropdown.open .menu { display: block; }
.dropdown .menu a { display: block; padding: .55rem .9rem; color: var(--text); }
.dropdown .menu a:hover { background: #f0f4f8; text-decoration: none; }

/* ---- Place suggestions (as you type) ---- */
.suggest { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: calc(7 * 2.05rem + 2px); overflow-y: auto; overflow-x: hidden; display: none; min-width: 220px; }
.suggest.open { display: block; }
.suggest div { padding: .4rem .7rem; line-height: 1.25rem; height: 2.05rem; box-sizing: border-box; cursor: pointer; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest div:hover, .suggest div.hl { background: #eaf3fd; }
.suggest b { font-weight: 600; color: var(--accent); }

/* ---- Person picker ---- */
.picker { position: relative; flex: 1 1 320px; }
.picker-results { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 280px; overflow: auto; z-index: 40; display: none; }
.picker-results.open { display: block; }
.picker-results div { padding: .45rem .7rem; cursor: pointer; font-size: .9rem; }
.picker-results div:hover, .picker-results div.hl { background: #eaf3fd; }

/* ---- Admin tools ---- */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.tools-grid .card { margin: 0; display: flex; flex-direction: column; }
.tools-grid .card p { flex: 1; color: var(--muted); margin-top: 0; }
.tools-grid .card form { margin-top: .4rem; }
.danger-zone { border-color: #efc0bb; }

/* ---- Login ---- */
body.bare { background: linear-gradient(160deg, #5f6a72, #3f474d); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .8rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card.wide { max-width: 520px; }
.login-card h1 { text-align: center; }
.login-logo { width: 72px; height: 72px; border-radius: 12px; align-self: center; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: -220px; z-index: 25; transition: left .2s; box-shadow: 2px 0 12px rgba(0,0,0,.1); }
  body.nav-open .sidebar { left: 0; }
  .content { padding: 1rem; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: 1fr; }
  .ev-head { display: none; }
  .ev-row { grid-template-columns: 1fr 1fr; }
  .ev-label { grid-column: span 2; }
  .ev-sub > span:first-child { display: none; }
  .ev-sublabel { grid-column: span 2; }
  .who { display: none; }
}
@media (max-width: 560px) {
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* ---- Places: place details shown as a sub-group under their place ---- */
table.grid tr.detail-row td { background: #f7f9fb !important; font-size: .92rem; }
table.grid tr.detail-row td:first-child { padding-left: 1.6rem; }
table.grid tr.detail-row:hover td { background: #eaf3fd !important; }
.detail-mark { color: #a9b3bc; margin-right: .45rem; }
.card h3 .count, td .count { background: #e8ecef; color: var(--muted); border-radius: 10px; padding: 0 .45rem; font-size: .75rem; font-weight: 500; }

/* consecutive form grids keep the same spacing as rows within a grid */
.row-gap { margin-top: .8rem; }

/* Show on map, under the grave condition notes */
.map-btn { margin-top: .5rem; }

/* ---- Date calculator popup ---- */
.h4-row { display: flex; align-items: center; gap: 1rem; margin: 1.1rem 0 .5rem; }
.h4-row h4 { margin: 0; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(31,41,51,.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 4vh 1rem 1rem; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0,0,0,.3); width: 100%; max-width: 520px;
  display: flex; flex-direction: column; max-height: calc(100vh - 2rem); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; background: var(--slate); color: #fff; }
.modal-head h2 { margin: 0; font-size: 1.05rem; color: #fff; }
.modal-close { background: transparent; border: 0; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.modal iframe { border: 0; width: 100%; height: 420px; display: block; flex: 0 0 auto; }
body.modal-open { overflow: hidden; }
body.bare.popup { background: #fff; min-height: 0; overflow: hidden; }
body.popup .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }   /* keep Yrs / Mths / Days side by side */
.dc-popup { padding: 1rem 1.2rem; }
.dc-popup .flash { margin-bottom: 0; }
.dc-use { flex-wrap: wrap; }

/* ---- Chapman codes popup ---- */
.modal.modal-wide { max-width: 680px; }
.cc-popup { padding: .9rem 1.2rem 1.2rem; }
.cc-search { display: flex; align-items: center; gap: .8rem; }
.cc-search input { flex: 1; }
.cc-table td, .cc-table th { padding-top: .3rem; padding-bottom: .3rem; }

/* ---- Cross references: name and Remove on one line, picker and Set below, buttons lined up ---- */
.xref-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem .75rem; align-items: center; max-width: 720px; }
.xref-grid .xref-set { display: contents; }
.xref-grid .picker { flex: none; }
.xref-btn { justify-self: end; }
.xref-btn .btn { min-width: 6.5em; justify-content: center; }

/* ---- Drop-down with "New…" ---- */
.pick-new { margin-top: .35rem; }

/* ---- About page: The Data Store logo, centred at the bottom of the box ---- */
.about-brand { text-align: center; margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.about-brand img { width: 240px; max-width: 70%; height: auto; display: inline-block; }
