/* ---------------------------------------------------------------
   Sapere Signing — shared shell
   Palette and typeface are the Sapere brand guideline:
   plum #4C2C35, orange #FF7700, the neutral ramp below, Manrope.
   --------------------------------------------------------------- */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/manrope-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/manrope-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/manrope-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/manrope-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/manrope-latin-800-normal.woff2') format('woff2');
}

:root {
  /* brand */
  --plum: #4C2C35;
  --plum-700: #3E232B;
  --plum-050: #F3EDEF;
  --orange: #FF7700;
  --orange-050: #FFF2E6;

  --accent: var(--plum);
  --accent-ink: #ffffff;
  --accent-soft: var(--plum-050);

  /* neutral ramp, from the brand guideline */
  --n-050: #EDEFF7;
  --n-200: #D3D6E0;
  --n-300: #BCBFCC;
  --n-400: #9DA2B3;
  --n-600: #6E7180;
  --n-800: #40424D;
  --n-900: #1E1E24;

  --ink: var(--n-900);
  --ink-2: var(--n-800);
  --ink-3: var(--n-600);
  --line: var(--n-200);
  --line-2: var(--n-050);
  --bg: #F6F7FB;
  --panel: #ffffff;

  --ok: #0F6B50;
  --ok-soft: #E6F3EE;
  --warn: #8A4B00;
  --warn-soft: var(--orange-050);
  --bad: #9B2226;
  --bad-soft: #FBECEC;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(30, 30, 36, .04);
  --shadow: 0 1px 2px rgba(30, 30, 36, .04), 0 10px 28px -14px rgba(30, 30, 36, .18);
  --shadow-lg: 0 24px 60px -20px rgba(30, 30, 36, .3);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.018em; }
h1 { font-size: 23px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
a { color: var(--plum); text-underline-offset: 2px; }
a:hover { color: var(--orange); }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.break { word-break: break-all; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* ---------- brand lockup ---------- */

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand img { display: block; height: 23px; width: auto; }
.brand .divider { width: 1px; height: 19px; background: var(--line); }
.brand .product {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ---------- app shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  height: 60px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.page { max-width: 1140px; margin: 0 auto; padding: 28px 22px 72px; }
.page.wide { max-width: 1440px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel > .panel-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.panel > .panel-body { padding: 20px; }
.panel > .panel-body.tight { padding: 0; }

/* ---------- controls ---------- */

button, .btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 15px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, opacity .12s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--n-050); border-color: var(--n-300); }
button:active, .btn:active { transform: translateY(.5px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.btn-primary {
  background: var(--plum);
  border-color: var(--plum);
  color: #fff;
  box-shadow: 0 1px 2px rgba(76, 44, 53, .25);
}
.btn-primary:hover { background: var(--plum-700); border-color: var(--plum-700); }
.btn-danger { color: var(--bad); border-color: #E8CFCF; background: #fff; }
.btn-danger:hover { background: var(--bad-soft); border-color: #DFBDBD; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--n-050); border-color: transparent; color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--n-300); }
input:focus, select:focus, textarea:focus {
  border-color: var(--plum);
  box-shadow: 0 0 0 3px rgba(76, 44, 53, .1);
  outline: none;
}
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--n-400); }
input[readonly] { background: var(--n-050); }

.field { margin-bottom: 16px; }
.field-help { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

/* ---------- status chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--n-050);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--plum); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 700;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
  background: #FBFCFE;
}
td { padding: 14px 20px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background .1s; }
tbody tr.clickable:hover { background: #FAFBFD; }

/* ---------- notices ---------- */

.notice {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: #FBFCFE;
  color: var(--ink-2);
}
.notice.ok { background: var(--ok-soft); border-color: #C7E3D8; color: #0B5540; }
.notice.warn { background: var(--warn-soft); border-color: #FFD9B8; color: #7A4200; }
.notice.bad { background: var(--bad-soft); border-color: #EBC9C9; color: #841C20; }

/* ---------- toast ---------- */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}
.toast {
  background: var(--n-900);
  color: #fff;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s cubic-bezier(.2, .8, .3, 1);
}
.toast.bad { background: #7F1D20; }
.toast.ok { background: #0B5540; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 36, .38);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
  animation: fade-in .12s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in .16s cubic-bezier(.2, .8, .3, 1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal .modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal .modal-body { padding: 22px; }
.modal .modal-foot {
  padding: 15px 22px;
  border-top: 1px solid var(--line-2);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  background: #FBFCFE;
}

/* ---------- pdf canvas ---------- */

.pdf-stack { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.pdf-page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}
.pdf-page canvas { display: block; }
.pdf-page .page-no {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: rgba(255, 255, 255, .9);
  padding: 2px 7px;
  border-radius: 5px;
  pointer-events: none;
}

@media (max-width: 760px) {
  .page { padding: 18px 13px 60px; }
  .topbar { padding: 0 13px; gap: 12px; height: 56px; }
  .brand .product { display: none; }
  .brand .divider { display: none; }
}
