/* Shared design tokens + components (public site and staff portal) */
:root {
  --bg: #f2f6fc; --surface: #fff; --ink: #14294a; --mut: #52627c;
  --brand: #22559a; --brand-2: #4a86d8; --brand-dark: #173f7c; --lime: #c9e24a;
  --line: #dfe7f2; --soft: #eef3fb; --busy: #e6eaf1;
  --err: #b3261e; --err-bg: #fdecea; --ok: #14602a; --ok-bg: #e5f5e9; --warn: #7a5a00; --warn-bg: #fff3c9;
  --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --pill: 999px;
  --sh-1: 0 1px 2px rgba(20, 41, 74, .06), 0 4px 14px rgba(34, 85, 154, .07);
  --sh-2: 0 12px 32px rgba(34, 85, 154, .14);
  --ease: cubic-bezier(.22, .8, .3, 1);
  --t-fast: 140ms; --t-med: 240ms;
  --tap: 48px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); min-height: 100dvh;
  font-family: "Plus Jakarta Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 1000; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); }
.skip:focus { top: 12px; }

.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 28px; height: 28px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 24px; border: 0; border-radius: var(--pill);
  background: var(--brand); color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(34, 85, 154, .28);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.97); }
.btn.lime { background: var(--lime); color: var(--ink); box-shadow: none; }
.btn.lime:hover { background: #d6ec5b; }
.btn.ghost { background: #fff; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: var(--err); box-shadow: none; }
.btn.danger:hover { background: #8f1d17; }
.btn.danger-ghost { background: #fff; color: var(--err); box-shadow: inset 0 0 0 1.5px #f0c4c0; }
.btn.danger-ghost:hover { background: var(--err-bg); }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: .9rem; box-shadow: none; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: #b9c6dc; color: #fff; box-shadow: none; cursor: not-allowed; transform: none; }
.btn.ghost:disabled { background: #fff; color: #9aa5b8; }
.btn.busy { pointer-events: none; opacity: .85; }
.btn.busy::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.iconbtn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%;
  background: transparent; color: var(--brand); transition: background var(--t-fast);
}
.iconbtn:hover { background: var(--soft); }

/* ---------- fields ---------- */
.field { display: block; margin-top: 16px; }
.field:first-child { margin-top: 0; }
.field > span.lbl { display: block; font-size: .875rem; font-weight: 700; margin-bottom: 6px; }
.field .opt { font-weight: 500; color: var(--mut); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 12px 16px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--soft); font-size: 1rem; /* 16px stops iOS zoom-on-focus */
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(74, 134, 216, .25); }
.input::placeholder, .textarea::placeholder { color: #7d8ba3; }
.field.bad .input, .field.bad .textarea, .field.bad .select { border-color: var(--err); background: #fff; }
.help { font-size: .8125rem; color: var(--mut); margin-top: 6px; }
.fielderr { display: none; align-items: center; gap: 6px; color: var(--err); font-size: .875rem; font-weight: 600; margin-top: 6px; }
.field.bad .fielderr { display: flex; }
.pwwrap { position: relative; }
.pwwrap .input { padding-right: 56px; }
.pwwrap .iconbtn { position: absolute; right: 2px; top: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border: 1.5px solid var(--line); background: #fff; color: var(--brand); border-radius: var(--pill);
  font-weight: 700; font-size: .9rem; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip:hover { background: var(--soft); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { opacity: .75; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--pill); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.mute { background: var(--busy); color: var(--ink); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: #e3eefc; color: var(--brand-dark); }

/* ---------- cards ---------- */
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 20px; }
@media (min-width: 640px) { .card { padding: 28px; } }

/* ---------- dialogs (sheet on phones, panel/modal on desktop) ---------- */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(10, 25, 55, .5); backdrop-filter: blur(2px); }
.modal {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; border-radius: var(--r-lg); box-shadow: var(--sh-2); overflow: auto;
}
.modal[open] { animation: pop var(--t-med) var(--ease); }
.modal form, .modal .mbody { padding: 24px; }
.modal h2 { font-size: 1.25rem; letter-spacing: -.01em; }
.modal p { color: var(--mut); margin-top: 8px; }
.modal .mactions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 2000; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 460px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--ink); color: #fff; font-weight: 600; font-size: .92rem; box-shadow: var(--sh-2); animation: pop var(--t-med) var(--ease);
}
.toast.err { background: var(--err); }
.toast button { background: none; border: 0; color: var(--lime); font-weight: 800; min-height: 44px; padding: 0 6px; }

.footer-note { text-align: center; color: var(--mut); font-size: .8125rem; }
.spinner-block { display: grid; place-items: center; padding: 40px; color: var(--mut); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
