/* Misfits Deer Processing — brand styles
   Palette pulled from the logo: navy, brick red, cream. Mobile-first. */

:root {
  --navy: #24344d;
  --navy-dark: #1b2840;
  --navy-soft: #3a4d6b;
  --red: #a93f35;
  --red-dark: #8f332b;
  --cream: #f4f0e6;
  --card: #fffdf7;
  --line: #ded7c4;
  --ink: #22293a;
  --muted: #71798c;
  --ok: #3e7d4f;
  --warn: #b07d2c;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(27, 40, 64, 0.12), 0 4px 14px rgba(27, 40, 64, 0.08);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules like
   .login-wrap { display:flex } — without this the login screen never hides. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .heading {
  font-family: "Oswald", -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  color: var(--navy);
  margin: 0;
}

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 44px;
  padding: 0 18px;
  transition: background 0.15s, transform 0.05s;
}
button:active { transform: scale(0.985); }

.btn-primary { background: var(--navy); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-red { background: var(--red); color: #fff; font-weight: 600; }
.btn-red:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: rgba(36, 52, 77, 0.06); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }

/* ---------- Forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--navy-soft);
  outline-offset: 1px;
  border-color: var(--navy-soft);
}
.field { margin-bottom: 14px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  right: 3px;
  top: 3px;
  bottom: 3px;
  width: 42px;
  min-height: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 1.15rem;
  border-radius: 8px;
}
.pw-toggle:hover { background: rgba(36, 52, 77, 0.07); }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.checkbox-line { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.checkbox-line input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--red); }
.checkbox-line label { margin: 0; font-weight: 500; }

/* ---------- Login screen ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card img { width: 140px; margin-bottom: 8px; }
.login-card h1 { font-size: 1.5rem; margin-bottom: 20px; }
.login-card form { text-align: left; }
.login-card .btn-primary { width: 100%; margin-top: 6px; }
.login-alt { margin-top: 16px; font-size: 0.9rem; color: var(--muted); }
.login-alt a { color: var(--red); font-weight: 600; cursor: pointer; text-decoration: none; }

/* ---------- App shell ---------- */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Oswald", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: #fff;
}
.app-header .brand img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.app-header .spacer { flex: 1; }
.user-chip { font-size: 0.85rem; color: #cfd6e4; }
.app-header .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
.app-header .btn-ghost:hover { background: rgba(255,255,255,0.1); }

.app-nav {
  background: var(--navy-dark);
  display: flex;
  overflow-x: auto;
  position: sticky;
  top: 56px;
  z-index: 49;
}
.app-nav button {
  background: none;
  color: #b9c2d4;
  border-radius: 0;
  padding: 0 18px;
  min-height: 48px;
  font-family: "Oswald", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  position: relative;
}
.app-nav button.active { color: #fff; border-bottom-color: var(--red); }
.nav-badge {
  background: var(--red);
  color: #fff;
  border-radius: 99px;
  font-size: 0.72rem;
  padding: 2px 7px;
  margin-left: 6px;
  font-family: -apple-system, sans-serif;
}

main { padding: 18px 16px 80px; max-width: 1100px; margin: 0 auto; }

/* ---------- Cards / tables ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.15rem; }
.card-head .sub { color: var(--muted); font-size: 0.85rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.pill { display: inline-block; border-radius: 99px; padding: 3px 10px; font-size: 0.78rem; font-weight: 600; }
.pill-ok { background: #e2efe5; color: var(--ok); }
.pill-off { background: #eee9dc; color: var(--muted); }
.pill-red { background: #f3e0dd; color: var(--red-dark); }
.pill-navy { background: #e1e6ef; color: var(--navy); }

.muted { color: var(--muted); }
.empty-note { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- Admin sub-nav ---------- */
.subnav { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; }
.subnav button {
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--navy);
  font-weight: 600;
  border-radius: 99px;
  min-height: 40px;
  white-space: nowrap;
}
.subnav button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Stat tiles (reports) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat-tile .st-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-tile .st-value { font-family: "Oswald", sans-serif; font-size: 1.6rem; color: var(--navy); margin-top: 2px; }
.stat-tile .st-note { font-size: 0.75rem; color: var(--muted); }

/* ---------- Modal ---------- */
dialog {
  border: none;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(27, 40, 64, 0.3);
  padding: 0;
  width: min(94vw, 460px);
  background: var(--card);
}
dialog::backdrop { background: rgba(27, 40, 64, 0.45); }
.modal-head { background: var(--navy); color: #fff; padding: 14px 20px; font-family: "Oswald", sans-serif; font-size: 1.05rem; letter-spacing: 0.03em; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: 99px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--red-dark); }

/* ---------- Phase placeholders ---------- */
.placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.placeholder .big { font-family: "Oswald", sans-serif; font-size: 1.3rem; color: var(--navy); margin-bottom: 6px; }

/* ---------- Status pills ---------- */
.st-incoming { background: #e1e6ef; color: var(--navy); }
.st-dropped_off { background: #f0e6cf; color: #7c5a17; }
.st-hanging { background: #e7ead6; color: #5a6b2f; }
.st-quartering { background: #e7e0ef; color: #56407a; }
.st-processing { background: #f3e0dd; color: var(--red-dark); }
.st-ready { background: #e2efe5; color: var(--ok); }
.st-picked_up { background: #eee9dc; color: var(--muted); }
.st-archived { background: #eee9dc; color: var(--muted); }

/* ---------- Toolbar (orders list) ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }

/* ---------- Order rows / incoming cards ---------- */
.order-row { cursor: pointer; }
.order-row:hover td { background: rgba(36, 52, 77, 0.04); }
.order-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.order-card.overdue { border-left-color: var(--red); }
.order-card .who { flex: 1; min-width: 160px; }
.order-card .who .name { font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.order-card .who .sub { color: var(--muted); font-size: 0.88rem; }
.order-card .meta { text-align: right; min-width: 120px; }
.order-card .actions { display: flex; gap: 8px; }

/* ---------- Intake form ---------- */
.intake-section { margin-bottom: 18px; }
.intake-section .card-head h2 { font-size: 1.05rem; }
.sex-toggle { display: flex; gap: 10px; }
.sex-toggle button {
  flex: 1;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-weight: 700;
}
.sex-toggle button.on { border-color: var(--red); background: var(--red); color: #fff; }
.item-line { display: flex; align-items: center; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--line); }
.item-line:last-child { border-bottom: none; }
.item-line input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; accent-color: var(--red); flex-shrink: 0; }
.item-line .iname { flex: 1; }
.item-line .iprice { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.item-line .wt { width: 90px; min-height: 38px; padding: 4px 8px; }
.item-line .wt-label { color: var(--muted); font-size: 0.8rem; }
.totalbar {
  position: sticky;
  bottom: 0;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 -2px 14px rgba(27,40,64,0.25);
}
.totalbar .tb-item { min-width: 90px; }
.totalbar .tb-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: #b9c2d4; }
.totalbar .tb-value { font-family: "Oswald", sans-serif; font-size: 1.25rem; }
.totalbar .spacer { flex: 1; }
.totalbar input { width: 90px; min-height: 38px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); font-weight: 600; cursor: pointer; margin-bottom: 12px; background: none; border: none; padding: 0; min-height: 0; }

/* ---------- Detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 800px) { .detail-grid { grid-template-columns: 3fr 2fr; } }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 0.95rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

/* ---------- Signature ---------- */
.sig-canvas {
  width: 100%;
  height: 200px;
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  touch-action: none;
  display: block;
}
.sig-terms {
  max-height: 160px;
  overflow-y: auto;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 12px;
}

/* ---------- Kanban board ---------- */
.board-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.board-wrap {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
/* On the Board view, use the full browser width — no horizontal scrolling
   on desktop. Phones keep the swipeable columns. */
body.board-active main { max-width: none; }
@media (min-width: 1100px) {
  .board-col { max-width: none !important; }
  /* With dozens of deer, each column scrolls on its own so all four
     stages stay on screen. */
  #board-main .board-col, #board-donation .board-col { max-height: calc(100vh - 240px); overflow-y: auto; }
  #board-main .board-col-head, #board-donation .board-col-head { position: sticky; top: -8px; margin: -8px -8px 0; padding: 10px 14px; background: #ebe8df; z-index: 1; }
}
.board-col {
  flex: 1;
  min-width: 225px;
  max-width: 340px;
  background: rgba(36, 52, 77, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  scroll-snap-align: start;
}
.board-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Oswald", sans-serif;
  color: var(--navy);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 6px 10px;
}
.board-col-head .count {
  background: var(--navy);
  color: #fff;
  border-radius: 99px;
  padding: 1px 9px;
  font-size: 0.8rem;
}
.kanban-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(27, 40, 64, 0.1);
  padding: 8px 10px;
  margin-bottom: 7px;
  cursor: pointer;
}
.kanban-card .kc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kanban-card .kc-name { font-weight: 700; color: var(--navy); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kanban-card .kc-num { color: var(--muted); font-size: 0.75rem; flex-shrink: 0; }
.kanban-card .kc-sub { color: var(--muted); font-size: 0.76rem; margin-top: 1px; }
.kanban-card .kc-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.kanban-card .kc-pills .pill { font-size: 0.66rem; padding: 1px 7px; }
.kanban-card .kc-actions { display: flex; gap: 5px; margin-top: 7px; }
.kanban-card .kc-actions button { min-height: 32px; flex: 1; font-size: 0.78rem; padding: 0 8px; border-radius: 7px; }
.kanban-card .kc-move { max-width: 36px; font-size: 0.95rem !important; flex: 0 0 36px !important; }
.kc-cutline { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.kc-cutline .cut-progress { flex: 1; margin-top: 0; height: 4px; }
.kc-cutline span { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.kc-tasks { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 3px; display: flex; flex-wrap: wrap; gap: 0 16px; }
.kc-task { display: flex; align-items: center; gap: 6px; min-height: 30px; font-size: 0.8rem; font-weight: 600; color: var(--navy); cursor: pointer; }
.kc-task input { width: 19px; height: 19px; min-height: 0; accent-color: var(--red); flex-shrink: 0; }
.cut-progress { height: 6px; background: var(--line); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.cut-progress div { height: 100%; background: var(--ok); border-radius: 99px; }
.board-euro-head {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 12px;
}
.board-euro-head h2 { font-size: 1.1rem; }
.board-empty { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 18px 6px; }

/* ---------- Cut sheet ---------- */
.cut-line { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.cut-line:last-child { border-bottom: none; }
.cut-line input[type="checkbox"] { width: 26px; height: 26px; min-height: 0; accent-color: var(--ok); flex-shrink: 0; }
.cut-line .cname { flex: 1; font-weight: 600; color: var(--navy); }
.cut-line.done .cname { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.cut-line .cwho { color: var(--muted); font-size: 0.78rem; text-align: right; }

/* ---------- Print ---------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; font-size: 12pt; color: #000; }
  #print-area h1 { font-size: 16pt; margin: 0 0 4pt; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area th, #print-area td { border-bottom: 1px solid #999; padding: 4pt 6pt; text-align: left; }
  #print-area .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #000; padding-bottom: 8pt; margin-bottom: 10pt; }
  #print-area .print-terms { font-size: 8.5pt; color: #333; margin-top: 12pt; }
  #print-area .sigline { margin-top: 24pt; display: flex; gap: 24pt; }
  #print-area .sigline div { flex: 1; border-top: 1px solid #000; padding-top: 4pt; font-size: 9pt; }
}

@media (min-width: 700px) {
  main { padding: 24px; }
}
