@font-face {
  font-family: Qomra;
  src: url("/assets/qomra-regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Qomra;
  src: url("/assets/qomra-bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --forest: #002623;
  --green: #054239;
  --leaf: #428177;
  --gold: #b9a779;
  --wheat: #edebe0;
  --paper: #f8f7f2;
  --white: #fff;
  --ink: #161616;
  --muted: #52625d;
  --border: #dcded3;
  --danger: #6b1f2a;
  --success: #095349;
  --focus: #428177;
  --radius: 14px;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.65 Qomra, Tahoma, sans-serif;
}
html { scrollbar-gutter: stable; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { color: var(--forest); line-height: 1.25; }
h1 { font-size: clamp(2.35rem, 5vw, 3.65rem); }
h2 { font-size: 1.42rem; }
h3 { font-size: 1.18rem; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
label { display: grid; gap: 6px; font-weight: 700; }
input:not([type="checkbox"], [type="radio"]), select {
  min-width: 0;
  width: 100%;
  padding: 10px 13px;
  min-height: 46px;
  border: 1px solid #bcc9bf;
  border-radius: 8px;
  color: var(--forest);
  background: var(--white);
}
input[type="checkbox"] { accent-color: var(--green); width: 17px; height: 17px; margin: 0; }
input[type="file"] { font-weight: 400; }
input::file-selector-button {
  font: inherit; color: var(--green); background: #ecf3ef; border: 0; border-radius: 5px;
  margin-inline-end: 10px; padding: 3px 8px; cursor: pointer;
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: fit-content;
  padding: 10px 17px; min-height: 46px; border: 1px solid transparent; border-radius: 8px; font-weight: 700;
}
.button svg { flex: 0 0 auto; width: 19px; height: 19px; }
.primary { background: var(--green); color: var(--white); }
.primary:hover:not(:disabled) { background: var(--forest); }
.secondary { background: #eef4ef; color: var(--green); border-color: #d2e0d7; }
.secondary:hover:not(:disabled) { background: #dfece3; }
.quiet { background: transparent; color: var(--muted); }
.quiet:hover { background: var(--paper); color: var(--forest); }
.button:disabled { color: #576960; background: #e8eeea; border-color: #e8eeea; }
.full { width: 100%; }
.eyebrow { color: var(--green); font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 9px; }
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--gold); }
.subtle { color: var(--muted); }
.section-icon {
  background: #eef4ef; color: var(--green); border-radius: 11px; display: inline-grid;
  flex: 0 0 46px; place-items: center; width: 46px; height: 46px;
}
.message { padding: 9px 12px; background: #eef4ef; border-radius: 8px; color: var(--green); overflow-wrap: anywhere; }
.message[data-tone="error"] { background: #f8ecee; color: var(--danger); }
.message[data-tone="notice"] { background: #f2ecdb; color: #58451f; }
.message[data-tone="success"] { background: #e5f3eb; color: var(--success); }
.form-stack { display: grid; gap: 15px; }
.site-footer {
  margin-top: auto; display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 12px;
  border-top: 1px solid var(--border); padding: 18px; font-size: .87rem; color: var(--muted);
}
.site-footer span:first-child { font-weight: 700; color: var(--green); }

.guest { justify-content: center; }
.guest .site-footer { margin-top: 0; }
.login-shell {
  display: grid; grid-template-columns: 1fr 1fr; width: min(1020px, calc(100% - 52px)); min-height: 540px;
  margin: auto; margin-block: max(28px, 5vh); overflow: hidden; border-radius: 20px;
  background: var(--white); border: 1px solid var(--border);
}
.brand-panel {
  position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column;
  justify-content: space-between; gap: 55px; padding: 42px 43px 95px; background: var(--forest); color: var(--white);
}
.brand-lockup { display: flex; align-items: center; gap: 13px; font-weight: 700; }
.brand-lockup img { object-fit: contain; }
.brand-lockup small { display: block; font-weight: 400; color: #e2e6d9; }
.brand-title { position: relative; z-index: 1; }
.brand-title .eyebrow { color: #e5d3a9; }
.brand-title h1 { color: var(--white); font-size: clamp(2.8rem, 5.5vw, 4.6rem); margin-block: 10px; }
.brand-title > p:last-child { color: #e2e6d9; font-size: 1.08rem; }
.brand-panel::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("/assets/ornament.svg") no-repeat center / cover; opacity: .23;
}
.login-content { display: grid; align-items: center; padding: 42px clamp(26px, 6vw, 70px); }
.login-inner { display: grid; gap: 10px; }
.login-inner h2 { font-size: 2.1rem; margin-top: 8px; }
.login-inner form { margin-top: 12px; }

.workspace { display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.workspace-content { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; }
.sidebar {
  position: sticky; inset-block-start: 0; height: 100dvh; margin: 0; padding: 16px;
  display: flex; flex-direction: column; isolation: isolate; overflow-y: auto; scrollbar-gutter: stable;
  background: var(--forest); color: var(--white); border: 0; border-inline-end: 1px solid #2c5048;
}
.sidebar::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("/assets/ornament.svg") no-repeat center / cover; opacity: .14;
}
.sidebar :focus-visible { outline-color: var(--gold); }
.sidebar-brand { display: flex; justify-content: center; align-items: center; gap: 10px; }
.wordmark { display: flex; align-items: center; gap: 11px; line-height: 1.25; }
.wordmark strong { color: var(--gold); }
.wordmark small { display: block; color: #e2e6d9; font-size: .81rem; margin-top: 4px; }
.wordmark-emblem {
  width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--gold); background: var(--white); flex: 0 0 52px;
}
.sidebar-divider { display: flex; align-items: center; gap: 10px; margin-block: 15px 24px; color: var(--gold); }
.sidebar-divider::before, .sidebar-divider::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .5; }
.sidebar-divider span { width: 8px; height: 8px; background: currentColor; transform: rotate(45deg); }
.sidebar-nav { display: grid; gap: 20px; padding-block-end: 22px; }
.nav-group p { color: #c3d4cc; font-size: .84rem; margin-block-end: 6px; padding-inline: 9px; }
.nav-group a {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; min-height: 44px;
  border-radius: 10px; color: #edf3ef; font-weight: 700;
}
.nav-group a:hover { background: #173d36; }
.nav-group a[aria-current="page"] { background: var(--gold); color: var(--forest); }
.nav-group a svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-account {
  margin-block-start: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 9px; background: #103b35; border: 1px solid #48766b; border-radius: 10px;
}
.sidebar-account strong { display: block; overflow-wrap: anywhere; }
.sidebar-account small { display: block; color: #e5d3a9; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px; background: #103b35;
  border: 1px solid #48766b; border-radius: 8px; color: var(--white);
}
.icon-button:hover { background: #21534b; }
.sidebar-close, .mobile-navigation { display: none; }
.sidebar[popover]:not(:popover-open) { display: none; }
.sidebar::backdrop { background: rgb(0 38 35 / .42); }
.container { width: min(1120px, calc(100% - 48px)); margin-inline: auto; padding-block: clamp(30px, 6vw, 57px) 60px; }
.page-intro { margin-bottom: 29px; }
.page-intro h1 { margin-block: 4px 6px; }
.page-intro > p:last-child { color: var(--muted); font-size: 1.08rem; }
.search-container { max-width: 820px; }
.panel { padding: clamp(18px, 3.4vw, 31px); background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.panel-heading p { margin-top: 3px; }
.lookup-mode { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.lookup-mode legend { padding: 0; margin-block-end: 6px; color: var(--muted); font-size: .89rem; }
.lookup-mode > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lookup-mode label {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 8px; color: var(--green); cursor: pointer;
  text-align: center; line-height: 1.35;
}
/* both forms share one grid cell: panel height stays the tallest of the two, so switching tabs never shifts layout */
.lookup-forms { display: grid; align-items: start; }
.lookup-forms > .search-form { grid-area: 1 / 1; min-width: 0; display: grid; align-content: start; gap: 12px; }
.lookup-forms > .search-form[hidden] { display: grid !important; visibility: hidden; pointer-events: none; }
.lookup-forms .search-form > label { margin-bottom: 0; }
.lookup-mode label:has(:checked) { border-color: var(--leaf); background: #eef4ef; }
.lookup-mode input { accent-color: var(--green); margin: 0; }
.name-lookup-form { display: grid; gap: 12px; }
.name-search-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.search-row input[aria-invalid="true"] { border-color: var(--danger); }
.search-form > label { margin-bottom: 5px; }
.search-row { display: flex; gap: 9px; }
.search-row input { flex: 1; font-family: ui-monospace, monospace; font-size: 1.28rem; letter-spacing: .18em; text-align: center; }
.input-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--muted); font-size: .86rem; }
.input-meta bdi { font: .78rem/2 ui-monospace, monospace; }
.lookup-panel > .message { margin-top: 13px; }
.record { padding-top: 18px; border-top: 1px solid var(--border); margin-top: 20px; }
.record-heading { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; }
.badge { border-radius: 999px; background: var(--paper); color: var(--muted); padding: 3px 10px; font-size: .83rem; white-space: nowrap; }
.badge[data-tone="success"] { background: #e5f3eb; color: var(--success); }
.badge[data-tone="pending"] { background: #f3edde; color: #58451f; }
.record-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 8px; }
.record-grid > div { min-width: 0; padding: 10px 12px; background: var(--paper); border-radius: 8px; }
.record-grid dt { color: var(--muted); font-size: .88rem; }
.record-grid dd { font-weight: 700; overflow-wrap: anywhere; color: var(--forest); }
.record-actions { display: flex; gap: 10px; margin-top: 19px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 20px; }
#admin-notice { margin-bottom: 17px; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.province-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.province-picker legend { padding: 0; font-weight: 700; margin-bottom: 7px; }
.province-options { display: flex; flex-wrap: wrap; gap: 7px; }
.province-options label, .toggle-label { display: flex; align-items: center; gap: 6px; }
.province-options label { padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; font-weight: 400; cursor: pointer; }
.province-options label:has(:checked) { border-color: var(--leaf); background: #edf5ef; color: var(--green); }
.export-panel { margin-top: 20px; }
.export-form { display: grid; gap: 16px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.employees { margin-top: 20px; }
.employee { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.employee summary { cursor: pointer; padding: 11px 14px; }
.employee summary bdi { margin-inline-start: 10px; color: var(--muted); overflow-wrap: anywhere; }
.employee summary .badge { float: left; }
.employee form { border-top: 1px solid var(--border); padding: 16px; }
.import-issues { padding-inline-start: 21px; margin-block: 0; color: #58451f; }
.empty { color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; padding: 16px; }
.error-panel h1 { font-size: 1.8rem; margin-bottom: 16px; }

@media (max-width: 900px) {
  .workspace { display: block; }
  .workspace:has(.sidebar[popover]) .mobile-navigation {
    display: flex; align-items: center; gap: 10px; padding: 9px 14px;
    background: var(--forest); color: var(--white); font-weight: 700;
  }
  .sidebar { position: relative; height: auto; }
  .sidebar[popover] {
    position: fixed; inset: auto; inset-block: 0; inset-inline-start: 0;
    width: min(290px, calc(100vw - 36px)); max-width: none; max-height: none; height: 100dvh;
  }
  .sidebar[popover] .sidebar-brand { justify-content: space-between; }
  .sidebar[popover] .sidebar-close { display: grid; }
}
@media (max-width: 790px) {
  .admin-grid { grid-template-columns: 1fr; }
  .login-shell { min-height: 0; }
  .brand-panel { padding: 28px 25px 75px; }
}
@media (max-width: 580px) {
  .login-shell { width: calc(100% - 28px); grid-template-columns: 1fr; margin-block: 14px 24px; }
  .brand-panel { gap: 18px; padding: 17px 19px 33px; }
  .brand-lockup img { width: 42px; height: 42px; }
  .login-content { padding: 23px; }
  .login-inner > .section-icon { display: none; }
  .container { width: calc(100% - 28px); }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-grid > div:first-child { grid-column: 1 / -1; }
  .field-pair, .name-search-fields { grid-template-columns: 1fr; }
}
