/* =========================================================================
   Die Anker Pub management. Ported from the Bulshoekfarm portal sheet
   (css/manage.css in that build), same class names, same look: dense, square
   cornered, high contrast. Additions for the bar are marked POS.
   ========================================================================= */

.mg { background: var(--page); color: var(--ink); font-family: var(--body); font-size: 15px; min-height: 100vh; }

/* --------------------------------------------------------------- top bar */
.mg-top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 1.1rem; background: var(--forest); color: var(--cream);
  border-bottom: 3px solid var(--gold);
}
.mg-brand { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; min-width: 0; }
.mg-mark { width: 30px; height: 30px; flex: none; display: block; }
.mg-brand span { font-family: var(--display); font-size: 1.1rem; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.mg-brand small { display: block; font-family: var(--body); font-size: .68rem; font-weight: 500; color: var(--sage-soft); letter-spacing: .08em; text-transform: uppercase; }
.mg-who { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: .85rem; }
.mg-who span { color: var(--sage-soft); }
.mg-who form { margin: 0; }
.mg-who button { background: none; border: 0; padding: 0; color: var(--cream); font-size: .85rem; border-bottom: 1px solid rgba(247,242,230,.35); }
.mg-who button:hover { border-color: var(--gold); }
.mg-menu { display: none; }

/* ----------------------------------------------------------------- shell */
.mg-shell {
  display: grid; grid-template-columns: 220px 1fr; align-items: start;
  background: linear-gradient(to right, var(--band) 0 220px, transparent 220px);
}
.mg-side { position: sticky; top: 54px; padding: 1.1rem .7rem 3rem; min-height: calc(100vh - 54px); }
.mg-group { margin: 1.15rem .55rem .3rem; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--moss); font-weight: 600; }
.mg-group:first-child { margin-top: 0; }
.mg-side ul { list-style: none; margin: 0; padding: 0; }
.mg-side a {
  display: flex; align-items: center; gap: .6rem;
  padding: .48rem .55rem; color: var(--ink); text-decoration: none; font-size: .9rem;
  border-left: 3px solid transparent;
}
.mg-side a:hover { background: rgba(255,255,255,.55); }
.mg-side a.is-on { background: #fff; border-left-color: var(--gold); font-weight: 600; }
.mg-side svg { width: 17px; height: 17px; color: var(--moss); }

/* min-width:0 is load-bearing: as a grid item .mg-main otherwise refuses to
   shrink below its widest table and a phone clips the right of every card. */
.mg-main { padding: 1.4rem 1.6rem 4rem; max-width: 1200px; min-width: 0; }

/* ------------------------------------------------------------- page head */
.mg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; margin-bottom: 1.2rem; }
.mg-head h1 { font-size: 1.65rem; margin: 0 0 .15rem; }
.mg-head p { margin: 0; color: var(--moss); font-size: .92rem; max-width: 66ch; }
.mg-head .mg-btn { flex: none; }

/* --------------------------------------------------------------- surfaces */
.mg-card { background: #fff; border: 1px solid var(--line); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.mg-card > h2 { font-size: 1.15rem; margin: 0 0 .25rem; }
.mg-card > .hint { margin: 0 0 1rem; color: var(--moss); font-size: .87rem; }
.mg-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.mg-two { display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); align-items: start; }
/* Grid children default to min-width:auto and refuse to shrink below their
   widest content (the 48-column slip preview pushed a phone to 420px). */
.mg-two > *, .mg-grid > * { min-width: 0; }

/* POS: headline figures */
.mg-stats { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.1rem; }
.mg-stat { background: #fff; border: 1px solid var(--line); padding: .85rem 1rem; min-width: 0; }
.mg-stat b { display: block; font-family: var(--display); font-size: 1.65rem; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mg-stat span { display: block; margin-top: .3rem; font-size: .8rem; color: var(--moss); }
.mg-stat.is-main { border-top: 3px solid var(--gold); }
.mg-stat.is-alert { border-left: 3px solid var(--clay); }
.mg-sub { font-family: var(--display); font-size: 1.15rem; margin: 1.4rem 0 .55rem; }
.mg-sub small { font-family: var(--body); font-size: .82rem; color: var(--moss); font-weight: 400; margin-left: .4rem; }

/* ---------------------------------------------------------------- tables */
.mg-table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; }
.mg-table th, .mg-table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.mg-table th { background: #f6f2e6; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--moss); font-weight: 600; white-space: nowrap; }
.mg-table tbody tr:hover { background: #fbf9f2; }
.mg-table td.num, .mg-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mg-table tfoot td { font-weight: 700; background: #faf7ee; border-top: 2px solid var(--line); }
.mg-table a { color: inherit; text-decoration: none; border-bottom: 1px solid rgba(61,82,50,.35); }
.mg-table a:hover { border-color: var(--gold); }
.mg-table .is-off td { color: #8a8f80; }
.mg-table tr.is-low td:first-child { box-shadow: inset 3px 0 0 var(--clay); }
.mg-table td.is-short { color: var(--clay); font-weight: 600; }
.mg-table td.is-over { color: var(--ok); font-weight: 600; }
.mg-table--click tbody tr { cursor: pointer; }
.mg-wrap { overflow-x: auto; border: 1px solid var(--line); margin-bottom: 1.1rem; background: #fff; }
.mg-wrap > .mg-table { margin: 0; }
.mg-muted { color: #8a8f80; }
.mg-nowrap { white-space: nowrap; }

.mg-empty { padding: 2rem 1.2rem; text-align: center; color: var(--moss); background: #fff; border: 1px dashed #ccc3ac; margin-bottom: 1.1rem; }
.mg-empty b { display: block; font-family: var(--display); font-size: 1.1rem; color: var(--ink); margin-bottom: .3rem; }

/* ----------------------------------------------------------------- forms */
.mg-field { margin-bottom: .95rem; min-width: 0; }
.mg-field > label, .mg-field > .mg-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: .28rem; }
.mg-field .hint { display: block; font-size: .78rem; color: var(--moss); margin-top: .25rem; }
.mg input[type=text], .mg input[type=email], .mg input[type=number], .mg input[type=date],
.mg input[type=password], .mg select, .mg textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--field); background: #fff; border-radius: 0;
  font-family: var(--body); font-size: .95rem; color: var(--ink);
}
.mg textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.mg input:focus, .mg select:focus, .mg textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.mg input.num { text-align: right; font-variant-numeric: tabular-nums; }
.mg-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.mg-check { display: flex; align-items: flex-start; gap: .5rem; font-size: .92rem; margin-bottom: .6rem; }
.mg-check input { margin-top: .2rem; width: 17px; height: 17px; accent-color: var(--forest); }
.mg-field.is-err > label { color: var(--clay); }
.mg-field.is-err input, .mg-field.is-err select { border-color: var(--clay); background: #fffaf7; }

.mg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; cursor: pointer;
  padding: .55rem 1rem; border: 1px solid var(--moss); background: #fff; color: var(--ink);
  font-family: var(--body); font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  min-height: 40px;
}
.mg-btn:hover { background: #f3efe3; }
.mg-btn--gold { background: var(--gold); border-color: var(--gold-deep); color: var(--ink); }
.mg-btn--gold:hover { background: #e4b752; }
.mg-btn--forest { background: var(--forest); border-color: var(--forest); color: var(--cream); }
.mg-btn--forest:hover { background: var(--moss); }
.mg-btn--quiet { border-color: var(--field); font-weight: 500; }
.mg-btn--danger { border-color: var(--clay); color: var(--clay); }
.mg-btn--danger:hover { background: var(--clay); color: #fff; }
.mg-btn svg { width: 16px; height: 16px; }
.mg-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); align-items: center; }
.mg-actions .mg-spacer { flex: 1; }
.mg-save { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .6rem; padding: .8rem 0; background: linear-gradient(to top, var(--page) 72%, rgba(242,239,230,0)); }

/* ---------------------------------------------------------------- pieces */
.mg-flash { padding: .7rem .9rem; margin: 0 0 1.1rem; border-left: 3px solid var(--moss); background: #fff; font-size: .92rem; }
.mg-flash--ok { border-left-color: var(--ok); }
.mg-flash--err { border-left-color: var(--clay); background: #fffaf7; }
.mg-note { padding: .75rem 1rem; margin: 0 0 1.1rem; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--moss); font-size: .92rem; }
.mg-note--warn { border-left-color: var(--clay); background: #fffaf7; }
.mg-note--gold { border-left-color: var(--gold); background: #fffcf2; }
.mg-note b { display: block; margin-bottom: .2rem; }
.mg-note p { margin: .2rem 0 0; }

.mg-tag { display: inline-block; padding: .1rem .42rem; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; background: #ece6d6; color: var(--moss); font-weight: 600; white-space: nowrap; }
.mg-tag--gold { background: var(--gold); color: var(--ink); }
.mg-tag--alert { background: var(--clay); color: #fff; }
.mg-tag--ok { background: #d8e6cf; color: #2f5423; }

.mg-back { margin: -.3rem 0 .8rem; font-size: .87rem; }
.mg-back a { display: inline-flex; align-items: center; gap: .3rem; color: var(--moss); text-decoration: none; }
.mg-back a:hover { color: var(--ink); }
.mg-back svg { width: 15px; height: 15px; }

.mg-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.mg-tabs a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .42rem .8rem;
  background: #fff; border: 1px solid var(--line); color: var(--moss); text-decoration: none; font-size: .87rem;
}
.mg-tabs a:hover { background: #fbf9f2; color: var(--ink); }
.mg-tabs a.is-on { background: var(--forest); border-color: var(--forest); color: var(--cream); font-weight: 600; }
.mg-tabs span { font-variant-numeric: tabular-nums; opacity: .75; font-size: .8rem; }

.mg-dl { display: grid; grid-template-columns: 9rem 1fr; gap: .45rem 1rem; margin: 0; font-size: .93rem; }
.mg-dl dt { color: var(--moss); font-size: .84rem; padding-top: .1rem; }
.mg-dl dd { margin: 0; }

/* POS: report period picker */
.mg-period { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.mg-range { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; font-size: .85rem; color: var(--moss); }
.mg-range label { display: flex; align-items: center; gap: .4rem; }
.mg .mg-range input[type=date] { width: auto; padding: .38rem .5rem; font-size: .88rem; }

/* POS: category colours */
.mg-swatch { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: .45rem; border: 1px solid rgba(0,0,0,.15); }
.mg-swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.mg-swatches label { position: relative; cursor: pointer; }
.mg-swatches input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mg-swatches span {
  display: flex; align-items: flex-end; width: 74px; height: 52px; padding: .3rem .35rem;
  color: #fff; font-size: .7rem; font-weight: 600; border: 3px solid transparent; outline: 1px solid var(--line);
}
.mg-swatches input:checked + span { border-color: var(--ink); outline-color: var(--ink); }
.mg-swatches input:focus-visible + span { outline: 3px solid var(--gold); }

/* POS: till button preview, how the till draws an item */
.mg-till { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); margin: 0 0 1rem; }
.mg-tile {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 66px;
  padding: .5rem .6rem; color: #fff; text-decoration: none; font-weight: 700; font-size: .88rem; line-height: 1.2;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.mg-tile small { display: block; font-weight: 500; font-size: .74rem; opacity: .92; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.mg-tile.is-off { opacity: .4; }
.mg-tile:hover { filter: brightness(1.08); }

/* POS: item editor portion rows */
.mg-portions { width: 100%; border-collapse: collapse; }
.mg-portions th { padding: .2rem .35rem .35rem; text-align: left; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--moss); font-weight: 600; white-space: nowrap; }
.mg-portions td { padding: .2rem .35rem; vertical-align: middle; }
.mg-portions td.mid { text-align: center; }
.mg-portions .uses { display: flex; align-items: center; gap: .35rem; }
.mg-portions .uses input { min-width: 4.5rem; }
.mg-portions .uses small { color: var(--moss); font-size: .78rem; min-width: 2.6rem; }
.mg-portions tr.is-new input, .mg-portions tr.is-new select { background: #f9f6ec; border-style: dashed; }

/* POS: stock take entry */
.mg-count input { max-width: 7rem; margin-left: auto; display: block; }

/* ----------------------------------------------------------------- login */
.mg-login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--forest); }
.mg-login-card { width: min(390px, 100%); background: var(--paper); border-top: 4px solid var(--gold); padding: 1.9rem 1.7rem; }
.mg-login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.mg-login-brand .mg-mark { width: 40px; height: 40px; }
.mg-login-card h1 { font-size: 1.5rem; margin: 0; }
.mg-login-card h1 small { display: block; font-family: var(--body); font-size: .7rem; font-weight: 600; color: var(--moss); letter-spacing: .08em; text-transform: uppercase; }
.mg-login-card > p { margin: 0 0 1.3rem; color: var(--moss); font-size: .9rem; }

/* POS: token shown once */
.mg-token { display: block; padding: .8rem 1rem; background: var(--forest); color: var(--gold); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; word-break: break-all; user-select: all; }

/* POS: slip preview */
.mg-slip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; line-height: 1.35; background: #fff; border: 1px solid var(--line); padding: 1rem; white-space: pre; overflow-x: auto; max-width: 100%; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .mg-two { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .mg-top { gap: .6rem; padding: .55rem .9rem; }
  .mg-who span { display: none; }
  .mg-menu {
    display: inline-flex; align-items: center; gap: .35rem; margin-left: auto;
    background: none; border: 1px solid rgba(247,242,230,.35); color: var(--cream); padding: .35rem .6rem; font-size: .85rem;
  }
  .mg-menu svg { width: 18px; height: 18px; }
  .mg-who { margin-left: 0; }
  .mg-shell { grid-template-columns: 1fr; background: none; }
  .mg-side { position: static; min-height: 0; padding: .6rem .9rem .9rem; background: var(--band); border-bottom: 1px solid var(--line); }
  .js .mg-side { display: none; }
  .js .mg-side.is-open { display: block; }
  .mg-side ul { display: flex; flex-wrap: wrap; gap: .3rem; }
  .mg-group { margin: .6rem .1rem .25rem; }
  .mg-side a { border-left: 0; border-bottom: 3px solid transparent; padding: .45rem .65rem; background: rgba(255,255,255,.5); }
  .mg-side a.is-on { border-left: 0; border-bottom-color: var(--gold); }
  .mg-main { padding: 1rem 1rem 3rem; }
  .mg-head { flex-direction: column; gap: .7rem; }
  .mg-head h1 { font-size: 1.4rem; }
  .mg-dl { grid-template-columns: 1fr; gap: .1rem; }
  .mg-dl dd { margin-bottom: .5rem; }
  .mg-stat b { font-size: 1.35rem; }
  .mg-card { padding: .95rem .9rem; }
}
@media (max-width: 420px) {
  .mg-stats { grid-template-columns: 1fr 1fr; }
  .mg-brand span { font-size: 1rem; }
}

/* ------------------------------------------------------------------ print */
@media print {
  @page { margin: 12mm; }
  .mg { background: #fff; font-size: 11pt; }
  .mg-top, .mg-side, .mg-noprint, .mg-save, .mg-actions, .mg-back, .mg-flash { display: none !important; }
  .mg-shell { display: block; background: none; }
  .mg-main { padding: 0; max-width: none; }
  .mg-wrap { overflow: visible; border: 0; }
  .mg-table { font-size: 10pt; }
  .mg-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .mg-table tr { break-inside: avoid; }
  .mg-table thead { display: table-header-group; }
}

/* POS: room to write on the printed count sheet */
.mg-sheet td { height: 2.2em; vertical-align: middle; }
@media print { .mg-sheet td { height: 9mm; } }

/* POS: show-on-phone / hide-on-phone, for tables that must fit 390px */
.mg-sm { display: none; }
@media (max-width: 600px) {
  .mg-sm { display: inline; }
  p.mg-sm { display: block; }
  .mg-lg, th.mg-lg, td.mg-lg { display: none; }
  .mg-count th, .mg-count td { padding: .5rem .4rem; }
  .mg-count td:first-child { font-size: .85rem; }
  .mg-count input { max-width: 4.6rem; padding: .4rem .35rem; }
}
@media (max-width: 600px) {
  .mg-table { font-size: .85rem; }
  .mg-table th, .mg-table td { padding: .5rem .45rem; }
  .mg-table th { letter-spacing: .03em; font-size: .68rem; }
  /* Line editors (item portions, delivery lines) become small labelled cards. */
  .mg-portions, .mg-portions tbody { display: block; }
  .mg-portions thead { display: none; }
  .mg-portions tr { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .6rem; padding: .75rem 0; border-bottom: 1px solid var(--line-soft); }
  .mg-portions td { display: block; padding: 0; min-width: 0; }
  .mg-portions td.wide { grid-column: 1 / -1; }
  .mg-portions td.mid { text-align: left; }
  .mg-portions td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: .15rem;
    font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--moss); font-weight: 600;
  }
}
@media (max-width: 600px) {
  /* Tables where every column matters (Voids) become one labelled card per row. */
  .mg-stack, .mg-stack tbody, .mg-stack tfoot { display: block; }
  .mg-stack thead { display: none; }
  .mg-stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .8rem; padding: .7rem .75rem; border-bottom: 1px solid var(--line-soft); }
  .mg-stack td { display: block; padding: 0; border: 0; min-width: 0; text-align: left !important; white-space: normal; }
  .mg-stack td[data-label]::before {
    content: attr(data-label); display: block; font-size: .66rem; letter-spacing: .05em;
    text-transform: uppercase; color: var(--moss); font-weight: 600;
  }
  .mg-stack tfoot tr { grid-template-columns: 1fr; }
  .mg-stack tfoot td[colspan] { display: none; }
}
