:root {
  --bg: #232027;
  --card: #2f2b34;
  --card-2: #3a3540;
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .2);
  --text: #f6f1ea;
  --muted: #b7aeb9;
  --save: #f46000;
  --save-deep: #c94a00;
  --shave: #ffd09a;
  --shave-deep: #e9a45e;
  --gold: #ffd23f;
  --danger: #ff7b6b;
  --ok: #7fdc8f;
}

* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 600 16px/1.4 'Nunito', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 900; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.err { color: var(--danger); font-weight: 800; margin: 0; }
.err:empty { display: none; }

/* ---------- buttons and fields ---------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 9px 16px;
  font-weight: 900;
  font-size: 16px;
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.ghost { background: transparent; }
.btn.primary { background: linear-gradient(180deg, #ff8a35, var(--save)); color: #fff; box-shadow: none; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { appearance: none; border: 0; background: none; padding: 4px 0; color: var(--shave); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.f { display: flex; flex-direction: column; gap: 6px; }
.f > span:first-child { font-size: 14px; font-weight: 800; color: var(--muted); }
.f.inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.f.inline input { width: 120px; }
input, select {
  width: 100%;
  min-height: 44px;
  background: #1c1a20;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 700;
}
input:focus, select:focus { outline: none; border-color: var(--shave); box-shadow: 0 0 0 3px rgba(255, 208, 154, .2); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; color: var(--text); font-weight: 700; }
.check input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--save); flex: none; }

/* ---------- login and setup ---------- */

.center-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: var(--card); border-radius: 18px; box-shadow: inset 0 0 0 1px var(--line); padding: 20px; }
.narrow { width: min(420px, 100%); display: grid; gap: 14px; }
.narrow h1 { font-size: 26px; line-height: 1.15; }
.narrow p { margin: 0; }
.faces { display: flex; justify-content: center; gap: 6px; }
.faces img { width: 84px; height: auto; }
.se-setup summary { cursor: pointer; font-weight: 800; color: var(--shave); margin-bottom: 8px; }
.se-setup[open] { display: grid; gap: 10px; }

/* ---------- header and score ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(35, 32, 39, .95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: auto; }
.brand h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { color: var(--muted); font-size: 14px; }
.tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.score { display: flex; align-items: center; max-width: 1180px; margin: 16px auto 0; padding: 0 18px; }
.sh { width: 64px; height: auto; position: relative; z-index: 2; flex: none; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.sh.save { margin-right: -22px; }
.sh.shave { margin-left: -22px; }
.sbar { position: relative; flex: 1; height: 50px; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #ffe2bd, var(--shave)); box-shadow: 0 0 0 3px rgba(58, 21, 0, .8); }
.sfill { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; background: linear-gradient(180deg, #ff7a1f, var(--save) 50%, var(--save-deep)); transition: width .7s cubic-bezier(.3, 1.4, .5, 1); box-shadow: 3px 0 0 #fff; }
.snum { position: absolute; top: 50%; transform: translateY(-50%); font-size: 24px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(58, 21, 0, .8); font-variant-numeric: tabular-nums; }
.snum.save { left: 30px; }
.snum.shave { right: 30px; text-shadow: 0 2px 0 rgba(150, 60, 0, .9); }
.se-line { max-width: 1180px; margin: 8px auto 0; padding: 0 18px; color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.se-line .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.se-line.bad { color: var(--danger); }
.se-line.bad .dot { background: var(--danger); }
.se-line.off .dot { background: var(--muted); }

/* ---------- columns and tabs ---------- */

.tabs { display: none; }
.cols {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 18px 90px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 4px 0 10px; flex-wrap: wrap; }
.col-head h2 { font-size: 22px; }
.count { color: var(--muted); font-weight: 800; font-size: 18px; }
.empty { color: var(--muted); margin: 0; padding: 18px; border-radius: 14px; border: 1.5px dashed var(--line-2); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

/* queue cards */
.qi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 12px 12px 16px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: opacity .25s ease, transform .25s ease;
}
.qi.leaving { opacity: 0; transform: translateX(30px); }
.qi.fresh { animation: fresh 1.4s ease-out; }
@keyframes fresh { from { box-shadow: inset 0 0 0 2px var(--gold); } to { box-shadow: inset 0 0 0 1px var(--line); } }
.qi .what { font-weight: 900; font-size: 17px; }
.qi .pts { color: var(--shave); font-weight: 900; white-space: nowrap; }
.qi .from { color: var(--muted); font-size: 15px; }
.qi .from b { color: var(--text); }
.qi .msg { margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: #26232b; font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.qi .msg mark { border-radius: 4px; padding: 0 3px; font-weight: 900; }
.qi .msg mark.save { background: var(--save); color: #fff; }
.qi .msg mark.shave { background: var(--shave); color: #5a2600; }
.qi .acts { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.qi .two-btn { display: flex; gap: 6px; }
.btn.team { min-width: 104px; padding: 6px 12px 6px 6px; justify-content: flex-start; border-radius: 12px; font-size: 17px; }
.btn.team img { width: 34px; height: auto; flex: none; }
.btn.team.save { background: linear-gradient(180deg, #ff8a35, var(--save)); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2); text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn.team.shave { background: linear-gradient(180deg, #fff1de, var(--shave)); color: #5a2600; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }
.qi .ignore { align-self: center; font-size: 14px; color: var(--muted); }

/* recent rows */
.ri {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.ri img { width: 34px; height: auto; }
.ri .ig { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 900; }
.ri .what { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri .what .p { font-weight: 900; }
.ri .what .p.save { color: #ff9a4a; }
.ri .what .p.shave { color: var(--shave); }
.ri .what .p.neg { color: var(--danger); }
.ri .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri .acts { display: flex; gap: 10px; }
.ri .acts .link { font-size: 14px; }

/* add by hand */
.add { margin-bottom: 18px; padding: 0; }
.add summary { padding: 14px 18px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.add summary::-webkit-details-marker { display: none; }
.add summary::after { content: '+'; font-size: 24px; font-weight: 900; color: var(--muted); }
.add[open] summary::after { content: '\2212'; }
.add summary h2 { font-size: 18px; }
#form-add { padding: 0 18px 18px; display: grid; gap: 12px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: #1c1a20; box-shadow: inset 0 0 0 1px var(--line); justify-self: start; }
.seg button { appearance: none; border: 0; background: none; padding: 8px 14px; min-height: 38px; border-radius: 9px; font-weight: 900; color: var(--muted); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--shave); color: #4a2000; }
.add-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.calc { margin: 0; color: var(--muted); min-height: 22px; }
.calc b { color: var(--text); font-weight: 900; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick .btn.team { justify-content: center; }
body.removing .pick .btn.team { background: transparent !important; color: var(--text) !important; box-shadow: inset 0 0 0 2px var(--danger); text-shadow: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  transform: translate(-50%, 150%);
  display: flex;
  gap: 16px;
  align-items: center;
  max-width: calc(100vw - 24px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #47404e;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  font-weight: 800;
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #6a2a24; }

/* ---------- dialogs ---------- */

.dlg { width: min(680px, calc(100vw - 20px)); max-height: calc(100vh - 30px); border: 0; padding: 0; border-radius: 18px; background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.dlg::backdrop { background: rgba(10, 8, 12, .7); }
.dlg-in { padding: 20px; display: grid; gap: 14px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dlg h2 { font-size: 24px; }
.dlg h3 { font-size: 18px; margin-top: 6px; }
.dlg p { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 14px 0 0; display: grid; gap: 12px; }
legend { font-weight: 900; font-size: 18px; padding-right: 10px; color: var(--shave); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.opts { display: grid; gap: 8px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; padding: 11px 12px; border-radius: 10px; background: #1c1a20; box-shadow: inset 0 0 0 1px var(--line); font: 600 14px/1.3 ui-monospace, Consolas, monospace; overflow-x: auto; white-space: nowrap; user-select: all; }

/* ---------- phones ---------- */

@media (max-width: 820px) {
  .tabs { display: flex; gap: 6px; max-width: 1180px; margin: 14px auto 0; padding: 0 12px; }
  .tabs button { flex: 1; appearance: none; border: 0; min-height: 44px; border-radius: 12px; background: var(--card); color: var(--muted); font-weight: 900; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
  .tabs button[aria-selected="true"] { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--shave); }
  .badge { display: inline-block; min-width: 24px; padding: 0 7px; margin-left: 4px; border-radius: 99px; background: var(--save); color: #fff; font-size: 14px; }
  .cols { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 90px; }
  body[data-tab="queue"] #col-side, body[data-tab="side"] #col-queue { display: none; }
  .top { padding: 8px 12px; }
  .tools { width: 100%; margin-left: 0; }
  .tools .btn { flex: 1; padding: 6px; font-size: 15px; }
  .score { padding: 0 12px; margin-top: 12px; }
  .se-line { padding: 0 12px; }
  .rates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .qi { grid-template-columns: minmax(0, 1fr); }
  .qi .acts { flex-direction: row; align-items: center; }
  .qi .two-btn { flex: 1; }
  .qi .two-btn .btn { flex: 1; }
  .two { grid-template-columns: 1fr; }
  .sh { width: 52px; }
  .snum { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
