:root {
  --bg: #16161a;
  --surface: #1f1f26;
  --surface-2: #2a2a33;
  --border: #34343f;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --brand: #c0392b;
  --brand-d: #962d22;
  --accent: #2e86de;
  --ok: #27ae60;
  --warn: #e67e22;
  --radius: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }

header.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem 1rem;
  padding-top: calc(.8rem + env(safe-area-inset-top));
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
header.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
header.topbar .badge { background: rgba(255,255,255,.2); padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; }

main { padding: 1rem; max-width: 900px; margin: 0 auto; }

button, .btn {
  font: inherit; font-weight: 600;
  min-height: var(--tap);
  padding: 0 1rem;
  border: none; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-sm { min-height: 38px; padding: 0 .7rem; font-size: .9rem; }
.btn-block { width: 100%; }
button:disabled { opacity: .5; }

input, select, textarea {
  font: inherit; width: 100%;
  min-height: var(--tap);
  padding: .5rem .75rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: .6rem; }
.grid { display: grid; gap: .6rem; }

/* role picker */
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1rem; }
.roles a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 120px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-weight: 600; font-size: 1.1rem;
}
.roles a .ico { font-size: 2rem; margin-bottom: .3rem; }

/* menu / articles as tappable tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.tile {
  text-align: left; align-items: flex-start; flex-direction: column;
  min-height: 76px; padding: .7rem; gap: .2rem;
  background: var(--surface); border: 1px solid var(--border);
}
.tile .name { font-weight: 600; font-size: .95rem; }
.tile .price { color: var(--muted); font-size: .9rem; }
.cat-title { margin: 1.2rem 0 .5rem; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* cart bar */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.35);
}
.cart-list { max-height: 40vh; overflow:auto; }
.cart-line { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.qty-ctrl { display: flex; align-items: center; gap: .4rem; }
.qty-ctrl button { min-width: 40px; min-height: 40px; padding: 0; }

/* order cards (stations + admin) */
.order { border-left: 5px solid var(--accent); }
.order.food { border-left-color: var(--warn); }
.order h3 { display: flex; justify-content: space-between; align-items: baseline; }
.order .meta { font-size: .85rem; color: var(--muted); }
.item-line { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.item-line.done { opacity: .4; text-decoration: line-through; }
.item-line .q { font-weight: 700; min-width: 2.2rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; align-items: start; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { color: var(--muted); font-weight: 600; }

.tag { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); }
.tag.ok { background: rgba(39,174,96,.25); color: #6ee7a8; }
.tag.warn { background: rgba(230,126,34,.25); color: #f0b27a; }
.tag.muted { background: var(--surface-2); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--ok); color: #fff; padding: .7rem 1.2rem; border-radius: 999px;
  z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.4); font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--brand); }

.center-screen { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 360px; }
.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.flash { animation: flash 1s ease; }
@keyframes flash { from { background: rgba(46,134,222,.4); } to { background: var(--surface); } }
