:root{
  --available:#2fa84f;
  --requested:#e8a317;
  --booked:#d63b3b;
  --reserved:#f4f4f4;
  --ink:#1a1a1a;
  --line:#111111;
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:'Segoe UI',Arial,sans-serif;
  background:#f7f7f5;
  color:var(--ink);
}

/* ---- page chrome ---- */
.topbar{
  background:#fff;border-bottom:1px solid #e2e2de;
  padding:0 24px;display:flex;align-items:center;gap:24px;
  position:sticky;top:0;z-index:20;
}
.topbar .brand{font-weight:800;font-size:15px;padding:14px 0;margin-right:4px;}
.topbar nav{display:flex;gap:4px;flex-wrap:wrap;}
.topbar nav a{
  padding:14px 12px;font-size:13px;color:#555;text-decoration:none;
  border-bottom:3px solid transparent;
}
.topbar nav a:hover{color:#111;}
.topbar nav a.active{color:#111;font-weight:700;border-bottom-color:var(--available);}
.topbar .brand{text-decoration:none;color:inherit;}
.topbar-right{margin-left:auto;display:flex;align-items:center;gap:14px;font-size:13px;}
.topbar-right form{margin:0;}
.whoami{color:#444;}
.whoami .role{
  display:inline-block;margin-left:4px;padding:2px 8px;border-radius:20px;
  background:#eee;color:#666;font-size:11px;font-weight:700;
  text-transform:uppercase;letter-spacing:.4px;
}
.link-btn{
  background:none;border:none;padding:0;font:inherit;color:#2fa84f;
  font-weight:700;cursor:pointer;text-decoration:none;
}
.link-btn:hover{text-decoration:underline;}
.page{padding:24px;}

/* ---- auth screens ---- */
.auth-card{
  max-width:380px;margin:48px auto;background:#fff;border:1px solid #e2e2de;
  border-radius:10px;padding:28px 30px;
}
.auth-card h1{margin:0 0 4px;font-size:20px;}
.auth-card .sub{margin-bottom:20px;}
.auth-card .field{margin-bottom:16px;}
.auth-card .field input{width:100%;min-width:0;}
.auth-card .checkbox{
  display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:8px;
}
.btn-block{width:100%;padding:11px;text-align:center;margin-top:4px;}
.choice-note{font-size:12px;color:#777;margin:6px 0 18px;text-align:center;}
.auth-alt{font-size:13px;color:#666;margin:18px 0 0;text-align:center;}
.resend-form{margin-top:12px;text-align:center;}
.code-input{
  font-size:22px;letter-spacing:8px;text-align:center;font-family:'Segoe UI',monospace;
}
.demo-code{
  background:#fff8e5;border:1px solid #f0dca4;border-radius:6px;
  padding:10px 12px;font-size:12px;color:#6b5310;margin-bottom:18px;
}
.demo-code code{
  font-size:16px;font-weight:800;letter-spacing:2px;color:#3a2c00;
}
.demo-code .demo-note{display:block;margin-top:6px;color:#8a7430;}

h1{font-size:20px;margin:0 0 4px;}
.sub{color:#666;font-size:13px;margin-bottom:16px;}

.flash{
  max-width:1150px;margin:0 auto 16px;padding:10px 14px;border-radius:6px;
  font-size:13px;background:#e8f6ec;border:1px solid #b9e2c5;color:#1d5c31;
}
.flash.error{background:#fdeaea;border-color:#f3c2c2;color:#8f2020;}

/* ---- layout toolbar ---- */
.layout-bar{
  max-width:1150px;margin:0 auto 16px;
  display:flex;align-items:center;justify-content:space-between;
  gap:18px;flex-wrap:wrap;
}
.layout-bar .legend{margin-bottom:0;}
.layout-tools{display:flex;align-items:center;gap:14px;font-size:13px;flex:none;}
.layout-tools .switch{display:flex;align-items:center;gap:6px;cursor:pointer;}

/* ---- legend ---- */
.legend{
  display:flex;gap:18px;align-items:center;margin-bottom:20px;
  flex-wrap:wrap;font-size:13px;
}
.legend span{display:flex;align-items:center;gap:6px;}
.legend .hint{color:#777;}
.swatch{width:14px;height:14px;border:1px solid #111;border-radius:3px;}

/* ---- hall grid ---- */
/* Scaled by hall-view.js to fit the viewport; the transform needs a clipped, sized box. */
.hall-fit{overflow:hidden;}
.hall-fit > .hall{transform-origin:top center;}

.hall{
  max-width:1150px;
  margin:0 auto;
  display:grid;
  grid-template-columns:100px 1fr 100px;
  gap:24px;
  align-items:start;
}

.col-side{
  display:flex;
  flex-direction:column;
  border:2px solid var(--line);
}
.stall{
  border-bottom:1px solid var(--line);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-size:12px;
  line-height:1.3;
  padding:8px 2px;
  cursor:pointer;
  user-select:none;
  transition:filter .12s ease, transform .12s ease;
}
.stall:last-child{border-bottom:none;}
.stall:hover{filter:brightness(1.08);transform:scale(1.02);z-index:2;}
.stall b{font-size:14px;}

.stall.available{background:var(--available);color:#fff;}
.stall.requested{background:var(--requested);color:#fff;}
.stall.booked{background:var(--booked);color:#fff;}
.stall.reserved{background:var(--reserved);color:#333;}
.stall.is-busy{opacity:.55;pointer-events:none;}
.stall.just-changed{animation:pulse .6s ease;}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 rgba(0,0,0,.55);}
  100%{box-shadow:0 0 0 12px rgba(0,0,0,0);}
}

.col-side .stall{height:64px;}

.exit-label{
  color:#d63b3b;font-weight:800;font-size:14px;
  text-align:center;margin-bottom:6px;letter-spacing:.5px;
}

.middle{display:flex;flex-direction:column;align-items:center;gap:18px;}

.stage{
  width:100%;
  max-width:520px;
  border:3px solid var(--line);
  text-align:center;
  padding:26px 10px;
  background:#fff;
}
.stage .dim{font-size:15px;margin-bottom:6px;}
.stage .name{font-size:19px;font-weight:800;letter-spacing:1px;}

.block{
  width:100%;
  max-width:520px;
  border:2px solid var(--line);
  display:grid;
  grid-template-columns:repeat(4,1fr);
  grid-auto-rows:64px;
}
.block .stall{
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
  height:auto;
}
.block .stall:nth-child(4n){border-right:none;}
.block .stall:nth-last-child(-n+4){border-bottom:none;}

.entry-wrap{text-align:center;margin-top:6px;}
.entry{color:#d63b3b;font-weight:800;font-size:15px;letter-spacing:.5px;}
.hall-title{font-weight:800;font-size:15px;margin-top:2px;}
.venue{font-size:12px;color:#555;margin-top:2px;}

/* ---- customer picker ---- */
.picker{
  max-width:1150px;margin:0 auto 20px;background:#fff;border:1px solid #e2e2de;
  border-radius:8px;padding:14px 16px;display:flex;align-items:center;
  gap:12px;flex-wrap:wrap;font-size:13px;
}
.picker label{font-weight:700;}
.picker select,.picker input{
  padding:8px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px;
  font-family:inherit;
}
.picker .hint{color:#777;}

/* ---- modal ---- */
.overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.45);
  display:none;align-items:center;justify-content:center;z-index:50;
}
.overlay.show{display:flex;}
.modal{
  background:#fff;border-radius:10px;padding:22px 24px;
  /* Wide enough that a name, number and its two buttons sit on one line. */
  width:min(440px, calc(100vw - 32px));
  max-height:calc(100vh - 48px);overflow-y:auto;
  box-shadow:0 12px 40px rgba(0,0,0,.25);
}
.modal h2{margin:0 0 4px;font-size:18px;}
.modal .status-pill{
  display:inline-block;padding:3px 10px;border-radius:20px;
  font-size:12px;font-weight:700;color:#fff;margin:8px 0 14px;
}
.modal p{margin:4px 0;font-size:13px;color:#444;}
.modal label{display:block;font-size:12px;font-weight:700;margin:14px 0 4px;}
.modal select,.modal input[type=text]{
  width:100%;padding:9px 10px;border:1px solid #ccc;border-radius:6px;
  font-size:13px;font-family:inherit;
}
/* a block of the modal, ruled off from the one before it */
.modal .m-section{border-top:1px solid #eee;margin-top:14px;padding-top:2px;}
.modal .m-section:first-child{border-top:none;margin-top:4px;}
/* the section already spaces itself; don't stack the label's margin on top */
.modal .m-section > label:first-child{margin-top:10px;}
.modal .m-fold > label{margin-top:10px;}
.modal .m-fold > .req-list{margin-top:8px;}

/* …and one that stays folded until asked for */
.modal details.m-fold > summary{
  cursor:pointer;list-style:none;padding:10px 0 2px;
  font-size:12px;font-weight:700;color:#666;
  display:flex;align-items:center;gap:6px;
}
.modal details.m-fold > summary::-webkit-details-marker{display:none;}
.modal details.m-fold > summary::before{content:'▸';font-size:9px;color:#999;}
.modal details.m-fold[open] > summary::before{content:'▾';}
.modal details.m-fold > summary:hover{color:#111;}

/* competing requests on one stall — approve or reject each on its own */
.modal .req-list{
  max-height:244px;overflow-y:auto;border:1px solid #e4e4e0;border-radius:6px;
}
.modal .req-list .req{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:8px 10px;font-size:13px;
  border-left:3px solid transparent;border-bottom:1px solid #f0f0ee;
}
.modal .req-list .req:last-child{border-bottom:none;}
/* The left edge carries the status, so each row stays one line tall. */
.modal .req.is-pending{border-left-color:var(--requested);}
.modal .req.is-approved{border-left-color:var(--available);background:#f5faf6;}
.modal .req.is-rejected{border-left-color:#c9c9c9;}
.modal .req.is-rejected .opt-name{color:#8a8a8a;}
.modal .req-text{min-width:0;}
.modal .req-actions{display:flex;gap:6px;flex:none;}
.modal .req-actions button{
  width:auto;margin-top:0;padding:5px 11px;font-size:11px;
}

/* type-to-search customer picker — a <select> is hopeless past a few dozen names */
.modal .picker-results{
  max-height:196px;overflow-y:auto;border:1px solid #e4e4e0;border-radius:6px;
  margin-top:6px;
}
.modal .picker-option{
  padding:8px 10px;font-size:13px;cursor:pointer;border-bottom:1px solid #f0f0ee;
}
.modal .picker-option:last-child{border-bottom:none;}
.modal .picker-option:hover,.modal .picker-option.is-active{background:#eaf5ee;}
.modal .picker-note{padding:9px 10px;font-size:11px;color:#777;}

/* one name over its mobile/timestamp — shared by the picker and the request list */
.opt-name{
  display:block;font-weight:700;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.opt-meta{display:block;font-size:11px;color:#777;margin-top:1px;}
.modal .error{color:#b32e2e;font-size:12px;margin-top:8px;}
.modal button{
  margin-top:10px;width:100%;padding:10px;border:none;border-radius:6px;
  font-size:14px;font-weight:700;cursor:pointer;font-family:inherit;
}
.modal button:disabled{background:#ccc;color:#666;cursor:not-allowed;}
.btn-primary{background:var(--available);color:#fff;}
.btn-danger{background:var(--booked);color:#fff;}
.btn-secondary{background:#444;color:#fff;}
.btn-close{background:#eee;color:#333;}

/* ---- tables / forms (customers + my-stall) ---- */
.panel{
  max-width:900px;margin:0 auto 20px;background:#fff;border:1px solid #e2e2de;
  border-radius:8px;padding:18px 20px;
}
.panel h2{margin:0 0 12px;font-size:16px;}
.form-row{display:flex;gap:12px;flex-wrap:wrap;align-items:flex-end;}
.field{display:flex;flex-direction:column;gap:4px;}
.field label{font-size:12px;font-weight:700;}
.field input{
  padding:9px 10px;border:1px solid #ccc;border-radius:6px;font-size:13px;
  font-family:inherit;min-width:220px;
}
.field .err{color:#b32e2e;font-size:12px;}
.btn{
  padding:10px 18px;border:none;border-radius:6px;font-size:13px;font-weight:700;
  cursor:pointer;background:var(--available);color:#fff;font-family:inherit;
  text-decoration:none;display:inline-block;
}
table{width:100%;border-collapse:collapse;font-size:13px;}
th,td{text-align:left;padding:9px 8px;border-bottom:1px solid #eee;}
th{font-size:11px;text-transform:uppercase;letter-spacing:.4px;color:#777;}

/* sortable column headers */
th .sort-link{
  display:inline-flex;align-items:center;gap:5px;
  color:inherit;text-decoration:none;font:inherit;letter-spacing:inherit;
  text-transform:inherit;white-space:nowrap;
}
th .sort-link:hover{color:#111;}
th .sort-link.is-sorted{color:#111;font-weight:800;}
th .sort-arrow{font-size:9px;opacity:.3;}
th .sort-link:hover .sort-arrow{opacity:.6;}
th .sort-link.is-sorted .sort-arrow{opacity:1;color:var(--available);}
.empty{color:#777;font-size:13px;padding:12px 0;}
.tag{
  display:inline-block;padding:2px 9px;border-radius:20px;font-size:11px;
  font-weight:700;color:#fff;
}
.tag.pending{background:var(--requested);}

/* a pending request that opens the stall modal */
button.stall-chip{
  border:none;font-family:inherit;cursor:pointer;
  padding:3px 10px;line-height:1.4;
}
button.stall-chip + button.stall-chip{margin-left:4px;}
button.stall-chip:hover{filter:brightness(1.1);}
button.stall-chip:focus-visible{outline:2px solid var(--ink);outline-offset:1px;}
.tag.approved,.tag.confirmed{background:var(--available);}
.tag.rejected,.tag.cancelled{background:#999;}

/* ---- print / save as PDF ---- */
/* hall-view.js scales the plan to one sheet on beforeprint; this strips the chrome. */
@page{size:A4 portrait;margin:10mm;}

@media print{
  body{background:#fff;}
  .page{padding:0;}
  .topbar,.layout-tools,.sub,.flash,.overlay,.panel{display:none !important;}

  h1{font-size:16px;margin-bottom:10px;}
  .layout-bar{margin-bottom:10px;}
  .legend{font-size:10px;gap:12px;margin-bottom:0;}

  /* The plan is the point — keep every stall colour instead of printing it white. */
  .hall-fit,.hall,.stall,.stage,.block,.col-side,.swatch,.entry,.exit-label{
    -webkit-print-color-adjust:exact;print-color-adjust:exact;
  }
  .hall-fit{overflow:visible;}
  .stall:hover{filter:none;transform:none;}

  /* One sheet, no orphaned rows. */
  .hall,.block,.col-side,.stage{break-inside:avoid;page-break-inside:avoid;}
}
