/* #TEACH brand: Inter; red #8B0000, navy #002E5D, light #F5F5F5, gray #C5C5C5, blue #12A7E6 */
:root {
  --red: #8b0000;
  --red-dark: #6e0000;
  --navy: #002e5d;
  --navy-dark: #00213f;
  --light: #f5f5f5;
  --gray: #c5c5c5;
  --blue: #12a7e6;
  --ink: #1f2a37;
  --muted: #5b6570;
  --line: #e2e4e7;
  --card: #ffffff;
  --ok: #1d7a45;
  --ok-bg: #e8f5ee;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --err-bg: #fbeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 46, 93, 0.06), 0 2px 8px rgba(0, 46, 93, 0.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--light);
  color: var(--ink);
  font-family: Inter, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 700; }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--red); }
code { font-family: Menlo, Consolas, 'Courier New', monospace; font-size: 0.92em; background: #eef1f4; padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 8px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---- Top bar ---- */
.topbar { background: var(--navy); color: #fff; border-bottom: 4px solid var(--red); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { height: 29px; width: auto; display: block; }
.brand span { font-weight: 300; font-size: 1rem; letter-spacing: 0.02em; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.35); }
.brand:hover { color: #fff; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a, .usermenu > a { color: rgba(255, 255, 255, 0.85); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; font-size: 0.93rem; }
.mainnav a:hover, .usermenu > a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.mainnav a.active, .usermenu > a.active { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 0 -3px 0 var(--blue); }
.usermenu { display: flex; align-items: center; gap: 8px; }
.usermenu form { margin: 0; }
.usermenu .linkbtn { color: rgba(255, 255, 255, 0.85); }
.usermenu .linkbtn:hover { color: #fff; }
.devbanner { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid #f0dca8; font-size: 0.88rem; padding: 8px 0; }

.main { padding-top: 28px; padding-bottom: 48px; min-height: calc(100vh - 160px); }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 0; max-width: 680px; }

/* ---- Footer with partner logo ---- */
.sitefoot { background: #fff; border-top: 1px solid var(--line); padding: 16px 0; font-size: 0.85rem; color: var(--muted); }
.sitefoot-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.partner { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--muted); }
.partner img { display: block; height: 29px; width: auto; }

/* ---- Cards, grids ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 14px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > * { margin: 0; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---- Stock cards ---- */
.stock-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stock { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border-top: 5px solid var(--navy); display: flex; flex-direction: column; gap: 4px; }
.stock-low { border-top-color: #d08b00; }
.stock-out { border-top-color: var(--red); }
.stock-head { display: flex; justify-content: space-between; align-items: center; }
.stock-type { font-weight: 700; color: var(--navy); }
.stock-num { font-size: 2.6rem; font-weight: 800; color: var(--ink); line-height: 1.1; margin-top: 6px; letter-spacing: -0.02em; }
.stock-label { color: var(--muted); font-size: 0.85rem; margin-top: -2px; }
.stock-foot { color: var(--muted); font-size: 0.82rem; margin-bottom: 10px; }
.stock .btn { align-self: flex-start; }
.bar { height: 6px; background: #e9ecef; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.stock-low .bar span { background: #d08b00; }
.stock-out .bar span { background: var(--red); }
.stats { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stats > div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; display: flex; align-items: baseline; gap: 8px; box-shadow: var(--shadow); }
.stats strong { font-size: 1.35rem; color: var(--navy); }
.stats span { color: var(--muted); font-size: 0.88rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 7px; border: 1.5px solid transparent; font: inherit; font-weight: 600; font-size: 0.93rem; text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--gray); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkbtn.danger { color: var(--red); }

/* ---- Forms ---- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--ink); }
.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1.5px solid var(--gray); border-radius: 7px; padding: 9px 12px; width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(18, 167, 230, 0.2); }
input[type='checkbox'], input[type='radio'] { width: auto; accent-color: var(--red); }
input[type='file'] { padding: 8px; background: var(--light); border-style: dashed; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { margin-top: 4px; }
.check-warn { background: var(--warn-bg); border-radius: 7px; padding: 10px 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 700; color: var(--navy); font-size: 1.02rem; margin-bottom: 10px; padding: 0; }
form.inline { display: inline; margin: 0; }
.inline-form { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters label { min-width: 130px; }
.filters .grow { flex: 1; min-width: 200px; }
.filter-actions { display: flex; gap: 12px; align-items: center; padding-bottom: 4px; }
.rolepick { display: inline-flex !important; gap: 6px; align-items: center; }
.rolepick select { width: auto; padding: 5px 8px; font-size: 0.88rem; }
.linkbox { display: flex; gap: 8px; margin: 10px 0 6px; }
.linkbox input { font-family: Menlo, Consolas, monospace; font-size: 0.82rem; }

/* Voucher type picker */
.typegrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.typecard { position: relative; border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 14px 14px; cursor: pointer; background: #fff; gap: 2px; text-align: center; align-items: center; transition: border-color 0.15s, box-shadow 0.15s; }
.typecard input { position: absolute; opacity: 0; pointer-events: none; }
.typecard:hover { border-color: var(--gray); }
.typecard:has(input:checked) { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.12); background: #fffafa; }
.typecard:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.typecard-num { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1; }
.typecard-label { font-weight: 600; font-size: 0.88rem; }
.typecard-stock { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.typecard.disabled { opacity: 0.45; cursor: not-allowed; background: var(--light); }

.segmented { display: inline-flex; border: 1.5px solid var(--gray); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.segmented label { flex-direction: row; align-items: center; gap: 8px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
.segmented label + label { border-left: 1.5px solid var(--gray); }
.segmented label:has(input:checked) { background: var(--navy); color: #fff; }
.segmented input { accent-color: var(--blue); }

/* ---- Tables ---- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }
.card:not(.flush) table th:first-child, .card:not(.flush) table td:first-child { padding-left: 0; }
.card:not(.flush) th { background: none; }
.note { color: var(--warn); }
.rowactions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 16px 0; color: var(--muted); font-size: 0.88rem; }

/* ---- Pills ---- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 0.75rem; font-weight: 700; text-transform: capitalize; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.pill-role { background: rgba(255, 255, 255, 0.15); color: #fff; text-transform: none; }
.pill-available, .pill-active, .pill-sent { background: var(--ok-bg); color: var(--ok); }
.pill-reserved, .pill-invited, .pill-low { background: var(--warn-bg); color: var(--warn); }
.pill-void, .pill-voided, .pill-disabled { background: var(--err-bg); color: var(--red); }
.pill-returned { background: #e8f4fb; color: #0b6e99; }

/* ---- Flash messages ---- */
.flash { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid; font-size: 0.92rem; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-ok { background: var(--ok-bg); border-color: #b9e0c9; color: #155c34; }
.flash-error { background: var(--err-bg); border-color: #efc1c1; color: var(--red); }
.flash-warn { background: var(--warn-bg); border-color: #f0dca8; color: var(--warn); }
.flash form.inline { display: inline-block; margin-left: 8px; }

/* ---- Detail page ---- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.facts dd { margin: 0; }
.facts.roles dt { color: var(--navy); font-weight: 700; }
.bigcode { font-size: 1.2rem; padding: 3px 8px; }
.danger-zone { border-color: #efc1c1; }
.timeline { margin: 0; padding-left: 18px; }
.timeline li { margin-bottom: 6px; }

/* ---- Settings preview ---- */
.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; background: var(--light); }

/* ---- Sign-in pages ---- */
body.bare { background: var(--navy); background-image: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%); }
.bare-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 20px; }
.bare-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 32px 30px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); border-top: 6px solid var(--red); }
.bare-card h1 { font-size: 1.45rem; }
.bare-card .stack { margin-top: 18px; }
.bare-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 22px; }
.bare-brand img { height: 39px; width: auto; }
.bare-brand span { color: var(--muted); font-weight: 300; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.8rem; }
.bare-partner { display: flex; align-items: center; gap: 12px; background: #fff; padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 0.8rem; }
.bare-partner img { height: 24px; width: auto; display: block; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .stock-grid, .typegrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
  .grid-2 > .card { margin-bottom: 0; }
  .grid-2 { margin-bottom: 20px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 8px 10px; padding-bottom: 10px; }
  .brand img { height: 24px; }
  .brand span { font-size: 0.9rem; }
  .main { padding-top: 22px; }
  .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav a { white-space: nowrap; }
  .usermenu { margin-left: auto; }
  .usermenu > a { display: none; }
  h1 { font-size: 1.45rem; }
  .card { padding: 16px; }
  .preview { height: 520px; }
}
