/* Battery Manager — app styles. Tokens from colors_and_type.css */
@import url('colors_and_type.css');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font-ui); color: var(--fg1); background: var(--bg-sunken); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }
.ic svg { width: 100%; height: 100%; }

/* faint pixel grid backdrop */
.pixel-grid {
  background-image: linear-gradient(var(--n100) 1px, transparent 1px), linear-gradient(90deg, var(--n100) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ====================================================================
   App shell
   ==================================================================== */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: var(--bw-bold) solid var(--bb-ink); }
.topbar-in { height: 64px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand img { height: 34px; image-rendering: pixelated; }
.brand .word { font-family: var(--font-display); font-size: 18px; color: var(--bb-blue); -webkit-text-stroke: 1.4px var(--bb-ink); paint-order: stroke fill; line-height: 1; }
.brand .sub { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); margin-top: 3px; }
.topbar-team { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border: 2px solid var(--bb-ink); border-radius: var(--r-pill); background: var(--bb-ink); color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.topbar-team .dot { width: 9px; height: 9px; border-radius: 999px; background: var(--team-frc); box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ====================================================================
   Buttons
   ==================================================================== */
.btn {
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; line-height: 1;
  border: var(--bw-bold) solid var(--bb-ink); padding: 11px 16px; border-radius: var(--r-sm);
  cursor: pointer; box-shadow: var(--shadow-hard-sm); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; color: var(--bb-ink); background: #fff;
  transition: transform var(--dur-fast) var(--ease-pop), box-shadow var(--dur-fast) var(--ease-pop), background var(--dur-fast), color var(--dur-fast);
}
.btn:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-hard); }
.btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--bb-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-hard-sm); }
.btn-primary { background: var(--bb-blue); color: #fff; }
.btn-primary:hover { background: var(--bb-blue-bright); }
.btn-dark { background: var(--bb-ink); color: #fff; }
.btn-red { background: var(--team-red); color: #fff; }
.btn-green { background: var(--team-green); color: #fff; }
.btn-warning { background: var(--warning); color: var(--bb-ink); }
.btn-lg { font-size: 16px; padding: 14px 22px; }
.btn-sm { font-size: 12.5px; padding: 8px 12px; border-width: 2px; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--bb-blue-dark); padding: 9px 11px; }
.btn-ghost:hover { transform: none; box-shadow: none; background: var(--bb-blue-tint); }
.btn-ghost:active { transform: none; box-shadow: none; }

/* ====================================================================
   Status pills, chips, values
   ==================================================================== */
.spill { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12px; padding: 3px 9px 3px 7px; border-radius: var(--r-pill); border: 2px solid; white-space: nowrap; line-height: 1.4; }
.spill-lg { font-size: 13.5px; padding: 6px 13px 6px 10px; }
.hchip { display: inline-flex; align-items: baseline; gap: 6px; color: #fff; font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: var(--r-sm); border: 2px solid var(--bb-ink); }
.hchip b { font-size: 13px; }
.resval { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.resval i { font-style: normal; font-weight: 600; font-size: .72em; opacity: .8; margin-left: 1px; }
.resval.big { font-size: 46px; letter-spacing: -0.02em; }
.resval.big i { font-size: .34em; }

/* ---- resistance meter ---- */
.rmeter { width: 100%; }
.rmeter-track { position: relative; height: 12px; border: 2px solid var(--bb-ink); border-radius: var(--r-pill); overflow: hidden; background: var(--n100); }
.rmeter-seg { position: absolute; top: 0; bottom: 0; }
.rmeter-tick { position: absolute; top: -5px; bottom: -5px; width: 0; transform: translateX(-50%); z-index: 2; }
.rmeter-tick span { position: absolute; inset: 0; left: -4px; width: 8px; background: #fff; border: 2px solid var(--bb-ink); border-radius: 2px; box-shadow: var(--shadow-hard-sm); }
.rmeter-scale { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--fg3); }

.spark { display: block; }
.spark-empty { font-size: 13px; color: var(--fg3); }

/* ---- QR ---- */
.qr { line-height: 0; border-radius: var(--r-sm); }
.qr svg { display: block; }

/* ====================================================================
   Stat tiles
   ==================================================================== */
.statrow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.stat { --stat-accent: var(--bb-blue); text-align: left; background: #fff; border: 2px solid var(--border); border-radius: var(--r-md); padding: 13px 14px; display: flex; flex-direction: column; gap: 1px; position: relative; box-shadow: var(--shadow-soft-sm); }
.stat-btn { cursor: pointer; transition: transform var(--dur-fast) var(--ease-pop), box-shadow var(--dur-fast), border-color var(--dur-fast); }
.stat-btn:hover { transform: translateY(-2px); border-color: var(--stat-accent); box-shadow: var(--shadow-soft); }
.stat-btn.active { border-color: var(--stat-accent); box-shadow: inset 0 0 0 1px var(--stat-accent), var(--shadow-soft-sm); }
.stat-btn.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 999px; background: var(--stat-accent); }
.stat-ic { position: absolute; top: 12px; right: 12px; color: var(--stat-accent); }
.stat-val { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--fg2); }
.stat-sub { font-size: 11px; color: var(--fg3); margin-top: 1px; }

/* ====================================================================
   Page heading + toolbar
   ==================================================================== */
.page { padding: 26px 0 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.page-head .eyebrow { font-weight: 700; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--bb-blue-dark); }
.page-head h1 { font-size: 32px; margin: 5px 0 0; letter-spacing: -0.02em; }
.page-head p.lede { margin: 6px 0 0; color: var(--fg2); font-size: 15px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--n200); border-radius: var(--r-sm); padding: 0 12px; height: 40px; min-width: 220px; flex: 1 1 240px; max-width: 340px; }
.search input { border: none; outline: none; font-family: var(--font-ui); font-size: 14px; width: 100%; background: transparent; color: var(--fg1); }
.search .ic { color: var(--fg3); }
.filterbar { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.fchip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: var(--r-pill); border: 2px solid var(--n200); background: #fff; color: var(--fg2); cursor: pointer; transition: all var(--dur-fast); white-space: nowrap; }
.fchip:hover { border-color: var(--bb-ink); }
.fchip .cnt { font-variant-numeric: tabular-nums; opacity: .65; font-weight: 700; }
.fchip.on { border-color: var(--bb-ink); color: #fff; background: var(--bb-ink); }
.fchip.on .cnt { opacity: .8; }
.fchip .swatch { width: 9px; height: 9px; border-radius: 2px; }

/* ====================================================================
   Data table
   ==================================================================== */
.tablewrap { background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard); overflow: hidden; }
.tscroll { overflow-x: auto; }
table.fleet { width: 100%; border-collapse: collapse; min-width: 920px; }
.fleet thead th { background: var(--n50); border-bottom: 2px solid var(--bb-ink); text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fg2); padding: 11px 12px; white-space: nowrap; position: sticky; top: 0; }
.fleet th.sortable { cursor: pointer; user-select: none; }
.fleet th.sortable:hover { color: var(--bb-blue-dark); }
.fleet th .tharrow { display: inline-flex; vertical-align: middle; margin-left: 3px; opacity: .35; }
.fleet th.sorted .tharrow { opacity: 1; color: var(--bb-blue-dark); }
.fleet th.num, .fleet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.fleet tbody td { padding: 11px 12px; border-bottom: 1px solid var(--n100); font-size: 14px; vertical-align: middle; }
.fleet tbody tr { cursor: pointer; transition: background var(--dur-fast); }
.fleet tbody tr:hover { background: var(--bb-blue-tint); }
.fleet tbody tr:last-child td { border-bottom: none; }
.fleet tbody tr.flagged { background: #FEF4F3; }
.fleet tbody tr.flagged:hover { background: #FCE9E7; }
.tag { font-weight: 700; font-family: var(--font-mono); font-size: 13.5px; color: var(--bb-ink); display: inline-flex; align-items: center; gap: 7px; }
.tag .idnum { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 24px; padding: 0 6px; border-radius: var(--r-sm); background: var(--bb-ink); color: #fff; font-size: 12.5px; }
.cellmodel { font-weight: 600; color: var(--fg1); }
.cellmodel small { display: block; font-weight: 500; color: var(--fg3); font-size: 12px; }
.flagbtn { background: none; border: none; cursor: pointer; color: var(--n300); padding: 4px; border-radius: var(--r-sm); display: inline-flex; }
.flagbtn:hover { color: var(--team-red); background: #FBE7E6; }
.flagbtn.on { color: var(--team-red); }
.warnpill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #B12C28; }

.emptyrow { text-align: center; padding: 48px 0; color: var(--fg3); }

/* ====================================================================
   Card grid layout (tweak)
   ==================================================================== */
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.bcard { background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard-sm); cursor: pointer; overflow: hidden; transition: transform var(--dur) var(--ease-pop), box-shadow var(--dur) var(--ease-pop); position: relative; }
.bcard:hover { transform: translate(-3px,-3px); box-shadow: var(--shadow-hard-lg); }
.bcard .bcard-top { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 0; }
.bcard .bcard-body { padding: 10px 14px 14px; }
.bcard .bcard-r { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 10px; }
.bcard .bcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--fg3); }
.bcard-strip { height: 6px; }

/* ====================================================================
   Rack layout (tweak)
   ==================================================================== */
.rack { background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard); padding: 18px; }
.rack-shelf { padding: 10px 0; border-bottom: 2px dashed var(--n200); }
.rack-shelf:last-child { border-bottom: none; }
.rack-shelf h4 { margin: 0 0 12px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); display: flex; align-items: center; gap: 8px; }
.rack-shelf h4 .ln { flex: 1; height: 2px; background: var(--n100); }
.rack-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cell { width: 92px; cursor: pointer; }
.cellbat { height: 64px; border: 3px solid var(--bb-ink); border-radius: var(--r-sm); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: var(--shadow-hard-sm); transition: transform var(--dur-fast) var(--ease-pop), box-shadow var(--dur-fast); color: #fff; }
.cell:hover .cellbat { transform: translate(-2px,-2px); box-shadow: var(--shadow-hard); }
.cellbat::before { content: ''; position: absolute; top: -7px; left: 50%; transform: translateX(-50%); width: 26px; height: 5px; background: var(--bb-ink); border-radius: 2px 2px 0 0; }
.cellbat .ct { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }
.cellbat .cr { font-size: 10px; font-weight: 700; opacity: .92; white-space: nowrap; }
.cell .clab { text-align: center; font-size: 10px; color: var(--fg3); margin-top: 8px; line-height: 1.3; }

/* ====================================================================
   Battery detail page
   ==================================================================== */
.detail { display: grid; grid-template-columns: 1.55fr 1fr; gap: 22px; align-items: start; }
.backlink { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--bb-blue-dark); cursor: pointer; font-size: 14px; margin-bottom: 14px; background: none; border: none; padding: 0; }
.backlink:hover { text-decoration: underline; }

.panel { background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard); }
.panel.soft { border: 2px solid var(--border); box-shadow: var(--shadow-soft-sm); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 2px solid var(--n100); }
.panel-head h3 { margin: 0; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.panel-head .ic { color: var(--bb-blue-dark); }

/* hero header of detail */
.bhero { display: flex; gap: 18px; align-items: flex-start; padding: 20px; border-bottom: 2px solid var(--n100); }
.bhero-id { flex: 0 0 auto; width: 76px; height: 76px; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); background: var(--bb-ink); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow-hard-sm); }
.bhero-id .lab { font-size: 9px; letter-spacing: .12em; opacity: .7; font-weight: 700; }
.bhero-id .n { font-family: var(--font-mono); font-size: 30px; font-weight: 700; line-height: 1; }
.bhero-main { flex: 1; min-width: 0; }
.bhero-main h1 { font-size: 26px; margin: 2px 0 4px; letter-spacing: -0.01em; }
.bhero-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--fg3); font-size: 13px; margin-top: 8px; }
.bhero-meta b { color: var(--fg2); font-weight: 600; }

/* resistance feature block */
.resfeature { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 20px; }
.resfeature .rf-dial { text-align: center; }
.resfeature .rf-grade { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r-sm); border: 2px solid var(--bb-ink); color: #fff; font-weight: 700; font-size: 16px; }
.rf-right { min-width: 0; }
.rf-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); }
.rf-sub { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }

.specgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.spec { padding: 12px 18px; border-top: 1px solid var(--n100); }
.spec:nth-child(odd) { border-right: 1px solid var(--n100); }
.spec .k { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg3); text-transform: uppercase; letter-spacing: .04em; }
.spec .v { font-weight: 700; font-size: 16px; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* QR side card */
.qrcard { text-align: center; }
.qrcard .qr { display: inline-block; padding: 12px; background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard-sm); }
.qrcard .qr-tag { font-family: var(--font-mono); font-size: 12px; color: var(--fg3); margin-top: 12px; word-break: break-all; }
.qrcard .qr-hint { font-size: 13px; color: var(--fg2); margin: 6px 0 14px; }

/* ---- history timeline ---- */
.hlog { padding: 6px 0; }
.hentry { display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding: 0 18px; }
.hentry .rail { display: flex; flex-direction: column; align-items: center; }
.hentry .rail .node { width: 13px; height: 13px; border-radius: 999px; border: 2.5px solid var(--bb-ink); background: #fff; margin-top: 16px; flex: 0 0 auto; }
.hentry .rail .line { flex: 1; width: 2px; background: var(--n100); margin: 4px 0; }
.hentry:last-child .rail .line { display: none; }
.hentry .hbody { padding: 12px 0 16px; min-width: 0; }
.hentry .hbody .htop { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.hentry .hbody .hgame { font-weight: 700; font-size: 15px; }
.hentry .hbody .hdate { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg3); margin-left: auto; }
.hentry .hbody .hstats { display: flex; gap: 16px; margin: 8px 0 0; flex-wrap: wrap; }
.hentry .hbody .hstat { font-size: 13px; color: var(--fg2); white-space: nowrap; }
.hentry .hbody .hstat b { color: var(--fg1); font-variant-numeric: tabular-nums; }
.hentry .hbody .hnote { font-size: 13.5px; color: var(--fg2); margin: 8px 0 0; background: var(--n50); border-left: 3px solid var(--n200); padding: 7px 11px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.hentry .hbody .hby { font-size: 12px; color: var(--fg3); margin-top: 7px; display: inline-flex; align-items: center; gap: 5px; }
.hentry.fresh .rail .node { background: var(--bb-blue); border-color: var(--bb-blue-dark); animation: pop .4s var(--ease-pop); }
.hentry .hdelete { margin-left: auto; background: none; border: none; padding: 2px 4px; cursor: pointer; color: var(--fg3); opacity: 0; transition: opacity .15s, color .15s; line-height: 1; border-radius: var(--r-sm); }
.hentry:hover .hdelete { opacity: 1; }
.hentry .hdelete:hover { color: var(--team-red); }
@keyframes pop { 0% { transform: scale(.3); } 100% { transform: scale(1); } }

/* ====================================================================
   Form / log drawer
   ==================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 12.5px; color: var(--fg2); }
.field label .req { color: var(--team-red); }
.field input, .field textarea, .field select { font-family: var(--font-ui); font-size: 14.5px; padding: 11px 12px; border: 2px solid var(--n200); border-radius: var(--r-sm); background: #fff; color: var(--fg1); width: 100%; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--bb-blue); box-shadow: 0 0 0 3px var(--bb-blue-tint); }
.field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.res-inputs { display: flex; align-items: center; gap: 8px; }
.res-half { position: relative; flex: 1; }
.res-half input { padding-right: 36px; width: 100%; }
.res-unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 700; color: var(--fg3); pointer-events: none; }
.res-or { font-size: 12px; font-weight: 600; color: var(--fg3); white-space: nowrap; flex-shrink: 0; }
.statuspick { display: flex; flex-wrap: wrap; gap: 7px; }
.statuspick .opt { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12.5px; padding: 7px 11px; border-radius: var(--r-pill); border: 2px solid var(--n200); cursor: pointer; transition: all var(--dur-fast); color: var(--fg2); background: #fff; }
.statuspick .opt:hover { border-color: var(--bb-ink); }
.statuspick .opt.on { border-color: var(--bb-ink); color: #fff; }

/* ---- modal / drawer ---- */
.scrim { position: fixed; inset: 0; background: rgba(11,11,12,.45); z-index: 90; display: flex; justify-content: flex-end; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { width: min(460px, 100%); height: 100%; background: var(--bg-sunken); border-left: var(--bw-bold) solid var(--bb-ink); overflow-y: auto; animation: slidein .26s var(--ease-out); display: flex; flex-direction: column; }
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } }
.drawer-head { position: sticky; top: 0; background: #fff; border-bottom: var(--bw-bold) solid var(--bb-ink); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; z-index: 2; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-head .sub { font-size: 12.5px; color: var(--fg3); margin-top: 2px; }
.iconbtn { background: #fff; border: 2px solid var(--bb-ink); border-radius: var(--r-sm); width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-hard-sm); transition: transform var(--dur-fast) var(--ease-pop), box-shadow var(--dur-fast); }
.iconbtn:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-hard); }
.drawer-body { padding: 20px; flex: 1; }
.drawer-foot { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--n100); padding: 14px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.prefill { background: var(--bb-blue-tint); border: 2px solid var(--bb-blue); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; color: var(--bb-blue-deep); display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; }

/* ---- charge queue panel ---- */
.queue { display: flex; flex-direction: column; gap: 9px; }
.qitem { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 2px solid var(--n100); border-radius: var(--r-sm); background: #fff; }
.qitem .qpos { font-family: var(--font-mono); font-weight: 700; color: var(--fg3); width: 20px; }
.qitem .qtag { font-family: var(--font-mono); font-weight: 700; }
.qitem .qmodel { font-size: 12.5px; color: var(--fg3); }
.qitem .qright { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.queue-empty { text-align: center; color: var(--fg3); font-size: 13.5px; padding: 18px 0; }

/* ====================================================================
   Next battery up
   ==================================================================== */
.nextcard { display: flex; background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard-lg); overflow: hidden; }
.nextcard-rail { flex: 0 0 8px; background: var(--team-green); }
.nextcard-body { flex: 1; min-width: 0; padding: 20px 22px; }
.nextcard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grabline { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--team-green); }
.nextcard-main { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.nextcard-id { flex: 0 0 auto; width: 92px; height: 92px; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); background: var(--team-green); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow-hard-sm); }
.nextcard-id .lab { font-size: 9px; letter-spacing: .12em; opacity: .85; font-weight: 700; }
.nextcard-id .n { font-family: var(--font-mono); font-size: 40px; font-weight: 700; line-height: 1; }
.nextcard-info { min-width: 0; }
.nextcard-info h2 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }
.nextcard-v { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.nextcard-v .nv-num { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.nextcard-v .nv-num i { font-style: normal; font-size: .42em; font-weight: 600; color: var(--fg3); margin-left: 2px; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.reason { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg2); }
.reason b { color: var(--fg1); font-weight: 700; }
.nextcard-actions { display: flex; gap: 11px; flex-wrap: wrap; align-items: center; margin-top: 20px; padding-top: 18px; border-top: 2px solid var(--n100); }
.nextcard.empty { box-shadow: var(--shadow-hard); }
.nextcard .empty-ic { width: 64px; height: 64px; margin: 0 auto; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; color: var(--warning); background: #FCEFD3; box-shadow: var(--shadow-hard-sm); }

.backups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.backup { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow-soft-sm); transition: transform var(--dur-fast) var(--ease-pop), box-shadow var(--dur-fast), border-color var(--dur-fast); }
.backup:hover { transform: translateY(-2px); border-color: var(--bb-ink); box-shadow: var(--shadow-soft); }
.backup .bk-rank { font-family: var(--font-mono); font-weight: 700; color: var(--fg3); font-size: 13px; }
.backup .bk-info { flex: 1; min-width: 0; }
.backup .bk-stats { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.backup .bk-v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }

/* top-bar Next button accent */
.btn-next { background: var(--team-green); color: #fff; }
.btn-next:hover { background: #34BB52; }

@media (max-width: 760px) {
  .nextcard-main { grid-template-columns: auto 1fr; }
  .nextcard-v { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; border-top: 2px solid var(--n100); padding-top: 14px; margin-top: 4px; }
  .backups { grid-template-columns: 1fr; }
}

/* ====================================================================
   Toast
   ==================================================================== */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 120; background: var(--bb-ink); color: #fff; font-weight: 700; font-size: 14px; padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-hard); display: flex; align-items: center; gap: 9px; animation: toastin .3s var(--ease-pop); }
.toast .ic { color: var(--bb-blue-bright); }
@keyframes toastin { from { transform: translate(-50%, 18px); opacity: 0; } }

/* ====================================================================
   Responsive
   ==================================================================== */
@media (max-width: 1000px) {
  .detail { grid-template-columns: 1fr; }
  .statrow { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .topbar-team .lbl-long { display: none; }
  .brand .sub { display: none; }
  .statrow { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-val { font-size: 22px; }
  .page-head h1 { font-size: 26px; }
  .resfeature { grid-template-columns: 1fr; text-align: center; }
  .resfeature .rf-sub { justify-content: center; }
  .search { max-width: none; }
  .bhero { flex-direction: row; }
}
@media (max-width: 460px) {
  .specgrid { grid-template-columns: 1fr; }
  .spec:nth-child(odd) { border-right: none; }
  .field-row { grid-template-columns: 1fr; }
  .page-head-actions { justify-content: flex-start; }
  .page-head-actions .btn { padding: 9px 12px; font-size: 13px; gap: 5px; }
}

/* ====================================================================
   Competition planner
   ==================================================================== */

/* Event key chip in page heading */
.comp-event-key-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 700; letter-spacing: .03em;
  padding: 4px 10px 4px 8px; border-radius: var(--r-pill);
  background: var(--bb-blue-tint); color: var(--bb-blue-dark);
  border: 2px solid var(--bb-blue); font-style: normal;
}
.comp-event-edit {
  background: none; border: none; cursor: pointer;
  color: var(--bb-blue-dark); padding: 0 0 0 2px;
  display: inline-flex; align-items: center; opacity: .6;
  transition: opacity .15s;
}
.comp-event-edit:hover { opacity: 1; }

/* Info / warning cards */
.comp-info-card {
  display: flex; gap: 16px; align-items: flex-start;
  background: #fff; border: 2px solid var(--border);
  border-radius: var(--r-md); padding: 20px 22px;
  box-shadow: var(--shadow-soft-sm); margin-bottom: 20px;
}
.comp-info-card.warn { border-color: var(--warning); background: #FBEFD3; }
.comp-info-card > .ic { flex: 0 0 auto; color: var(--bb-blue-dark); margin-top: 2px; }
.comp-info-card.warn > .ic { color: #8A5E0C; }
.comp-info-card h3 { margin: 0 0 5px; font-size: 16px; }
.comp-info-card p { margin: 0; font-size: 14px; color: var(--fg2); line-height: 1.55; }
.comp-info-card code { font-family: var(--font-mono); font-size: .85em; background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; }

/* Section headers */
.comp-section { background: #fff; border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md); box-shadow: var(--shadow-hard-sm); overflow: hidden; }
.comp-section-head { display: flex; align-items: center; gap: 8px; padding: 13px 18px; border-bottom: 2px solid var(--n100); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--fg2); background: var(--n50); }

/* Match list */
.comp-matches-wrap { padding: 0; }
.comp-matches-legend { display: grid; grid-template-columns: 100px 140px 1fr; gap: 12px; padding: 8px 18px; background: var(--n50); border-bottom: 1px solid var(--n100); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fg3); }

.comp-match-group { border-bottom: 2px solid var(--n100); }
.comp-match-group:last-child { border-bottom: none; }
.comp-group-label { padding: 10px 18px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--bb-blue-dark); }

.comp-match-row {
  display: grid; grid-template-columns: 100px 140px 1fr;
  gap: 12px; align-items: center;
  padding: 11px 18px; border-bottom: 1px solid var(--n100);
  transition: background var(--dur-fast);
  position: relative;
}
.comp-match-row:last-child { border-bottom: none; }
.comp-match-row:hover { background: var(--bb-blue-tint); }
.comp-match-row.past { opacity: .45; }
.comp-match-row.next-up { background: #F0FBF2; }
.comp-match-row.conflict { background: #FEF4F3; }
.comp-match-row.conflict:hover { background: #FCE9E7; }

.comp-conflict-flag {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: #B12C28;
  padding: 0 0 4px 2px;
}
.comp-conflict-flag > .ic { color: #B12C28; }

/* Match level / number */
.comp-match-level { display: flex; flex-direction: column; gap: 3px; }
.comp-next-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--team-green); }
.comp-level-badge { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }

/* Match time */
.comp-match-time {}
.comp-charge-hint { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--fg3); margin-top: 2px; }
.comp-charge-hint.overdue { color: var(--warning); }
.comp-charge-hint > .ic { color: var(--warning); }

/* Battery chip (assigned battery) */
.comp-batt-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 8px 5px 6px; border-radius: var(--r-sm);
  border: 2px solid var(--n200); background: var(--n50);
  font-size: 12.5px; white-space: nowrap; max-width: 100%;
  overflow: hidden;
}
.comp-batt-chip.conflict { border-color: var(--team-red); background: #FBE7E6; }
.comp-batt-chip.missing { border-color: var(--warning); background: #FBEFD3; color: #8A5E0C; }
.comp-chip-clear {
  background: none; border: none; cursor: pointer;
  color: var(--fg3); padding: 0; display: inline-flex;
  align-items: center; margin-left: 2px; opacity: .6; transition: opacity .15s;
}
.comp-chip-clear:hover { opacity: 1; color: var(--team-red); }

/* Assign button */
.comp-assign-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-ui); font-weight: 700; font-size: 12.5px;
  color: var(--bb-blue-dark); background: var(--bb-blue-tint);
  border: 2px dashed var(--bb-blue); border-radius: var(--r-sm);
  padding: 5px 10px; cursor: pointer; transition: all var(--dur-fast);
  white-space: nowrap;
}
.comp-assign-btn:hover { background: var(--bb-blue); color: #fff; border-style: solid; }

/* Battery picker dropdown */
.comp-picker {
  background: #fff; border: var(--bw-bold) solid var(--bb-ink);
  border-radius: var(--r-md); box-shadow: var(--shadow-hard-lg);
  min-width: 280px; max-width: 340px; overflow: hidden;
  position: relative; z-index: 30;
}
.comp-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 2px solid var(--n100);
  background: var(--n50);
}
.comp-picker-list { max-height: 220px; overflow-y: auto; }
.comp-picker-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; background: none;
  border: none; border-bottom: 1px solid var(--n100);
  cursor: pointer; font-family: var(--font-ui);
  text-align: left; transition: background var(--dur-fast);
}
.comp-picker-item:last-child { border-bottom: none; }
.comp-picker-item:hover { background: var(--bb-blue-tint); }
.comp-picker-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }

/* Setup banner */
.comp-setup-banner {
  text-align: center; padding: 48px 24px;
  background: #fff; border: var(--bw-bold) solid var(--bb-ink);
  border-radius: var(--r-md); box-shadow: var(--shadow-hard);
}
.comp-setup-icon {
  width: 60px; height: 60px; margin: 0 auto 16px;
  border: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-md);
  background: var(--bb-blue-tint); color: var(--bb-blue-dark);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-hard-sm);
}
.comp-setup-banner h2 { margin: 0 0 8px; }
.comp-setup-form { max-width: 360px; margin: 0 auto; text-align: left; }

/* Charging timeline */
.comp-timeline {
  overflow-x: auto; padding: 16px;
  background: var(--n50);
}
.comp-tl-header { display: flex; margin-bottom: 4px; }
.comp-tl-label-col { flex: 0 0 110px; font-size: 10px; color: var(--fg3); }
.comp-tl-axis { flex: 1; position: relative; height: 16px; }
.comp-tl-tick {
  position: absolute; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 9.5px; color: var(--fg3);
  white-space: nowrap;
}
.comp-tl-row {
  display: flex; align-items: center; gap: 0;
  margin-bottom: 6px; min-width: 560px;
}
.comp-tl-row.conflict .comp-tl-label-col { color: var(--team-red); }
.comp-tl-label-col {
  flex: 0 0 110px; display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding-right: 8px; white-space: nowrap; overflow: hidden;
}
.comp-tl-track {
  flex: 1; height: 24px; position: relative;
  background: var(--n100); border-radius: 4px; overflow: visible;
}
.comp-tl-seg {
  position: absolute; height: 100%; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 700; overflow: hidden;
  white-space: nowrap; min-width: 4px;
}
.comp-tl-seg.charge { background: rgba(192, 132, 16, 0.25); border: 1px solid rgba(192, 132, 16, 0.5); color: #8A5E0C; }
.comp-tl-seg.charge.conflict { background: rgba(248, 113, 113, 0.2); border-color: rgba(248, 113, 113, 0.5); color: #B12C28; }
.comp-tl-seg.match { background: var(--bb-blue); color: #fff; border: 1px solid var(--bb-blue-dark); z-index: 1; padding: 0 3px; }
.comp-tl-seg.match.conflict { background: var(--team-red); border-color: #8A1E1A; }
.comp-tl-seg.cooldown { background: rgba(100, 116, 139, 0.18); border: 1px dashed rgba(100, 116, 139, 0.4); border-radius: 4px; }
.comp-tl-seg span { overflow: hidden; text-overflow: ellipsis; }

/* Timeline legend */
.comp-tl-legend { display: flex; gap: 16px; padding: 10px 16px 0; flex-wrap: wrap; }
.comp-tl-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg2); }
.comp-tl-swatch { display: inline-block; width: 24px; height: 12px; border-radius: 3px; }
.comp-tl-swatch.charge { background: rgba(192, 132, 16, 0.25); border: 1px solid rgba(192, 132, 16, 0.5); }
.comp-tl-swatch.match { background: var(--bb-blue); border: 1px solid var(--bb-blue-dark); }
.comp-tl-swatch.cooldown { background: rgba(100, 116, 139, 0.18); border: 1px dashed rgba(100, 116, 139, 0.4); }

/* Tabs */
.comp-tabs {
  display: flex; gap: 0; margin-bottom: 0;
  border-bottom: var(--bw-bold) solid var(--bb-ink);
}
.comp-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 18px; font-family: var(--font-ui); font-weight: 700;
  font-size: 13.5px; color: var(--fg2); background: var(--n50);
  border: var(--bw-bold) solid var(--bb-ink); border-bottom: none;
  border-left: none; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative; bottom: -2px;
}
.comp-tab:first-child { border-left: var(--bw-bold) solid var(--bb-ink); border-radius: var(--r-sm) 0 0 0; }
.comp-tab:last-child  { border-radius: 0 var(--r-sm) 0 0; }
.comp-tab:hover:not(.active) { background: #fff; color: var(--fg1); }
.comp-tab.active {
  background: #fff; color: var(--bb-blue-dark);
  border-bottom: 2px solid #fff; z-index: 1;
}
.comp-tab .ic { color: inherit; }

/* Empty tab state */
.comp-tab-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 56px 24px; text-align: center; color: var(--fg3);
}
.comp-tab-empty p { margin: 0; font-size: 14px; max-width: 36ch; }

/* Action table */
.comp-action-table-wrap { overflow-x: auto; }
.comp-action-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.comp-action-table thead th {
  background: var(--n50); border-bottom: 2px solid var(--bb-ink);
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--fg2);
  padding: 10px 14px; white-space: nowrap;
}
.comp-action-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--n100); vertical-align: middle; }
.comp-action-table tbody tr:last-child td { border-bottom: none; }
.comp-action-table tbody tr.act-past { opacity: .38; }
.comp-action-table tbody tr.act-soon { background: #FFFBEA; }
.comp-action-table tbody tr.act-conflict { background: #FEF4F3; }
.comp-action-table tbody tr:hover:not(.act-past) { background: var(--bb-blue-tint); }

.act-time { font-family: var(--font-mono); font-weight: 700; font-size: 13px; white-space: nowrap; color: var(--fg2); }
.act-time-soon { color: var(--warning); }
.act-match { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--bb-blue-dark); }

.act-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.act-label.action-charge  { color: #8A5E0C; }
.act-label.action-remove  { color: var(--fg2); }
.act-label.action-robot   { color: var(--bb-blue-dark); }
.act-label.action-cool    { color: var(--fg3); }

.act-conflict-tag {
  display: inline-flex; align-items: center; gap: 3px;
  margin-left: 8px; font-size: 11px; font-weight: 700; color: #B12C28;
}

@media (max-width: 720px) {
  .comp-matches-legend { display: none; }
  .comp-match-row { grid-template-columns: 80px 1fr; }
  .comp-match-time { grid-column: 2; }
  .comp-match-alloc { grid-column: 1 / -1; }
  .comp-conflict-flag { grid-column: 1 / -1; }
}

/* ---- Login ------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-sunken); padding: 24px; }
.login-card { background: #fff; border: 2.5px solid var(--bb-ink); border-radius: var(--r); box-shadow: var(--shadow-hard); width: 100%; max-width: 380px; padding: 36px 32px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand img { width: 48px; height: 48px; object-fit: contain; }
.login-team { font-weight: 800; font-size: 18px; line-height: 1.1; }
.login-app { font-size: 13px; font-weight: 600; color: var(--fg3); }
.login-heading { font-size: 20px; font-weight: 800; margin: 0 0 20px; }
.login-form .field { margin-bottom: 16px; }
.login-err { font-size: 13px; font-weight: 600; color: var(--team-red); margin: -4px 0 12px; }
.login-btn { width: 100%; padding: 13px; background: var(--bb-ink); color: #fff; border: none; border-radius: var(--r-sm); font-family: var(--font-ui); font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 4px; transition: opacity .15s; }
.login-btn:hover { opacity: .85; }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--fg3); padding: 4px; border-radius: var(--r-sm); display: inline-flex; align-items: center; transition: color .15s; }
.logout-btn:hover { color: var(--team-red); }
.topbar-nav-btn { background: none; border: none; cursor: pointer; color: var(--fg3); padding: 6px; border-radius: var(--r-sm); display: inline-flex; align-items: center; transition: color .15s, background .15s; }
.topbar-nav-btn:hover { color: var(--bb-blue); background: var(--bb-blue-tint); }
.topbar-nav-btn.active { color: var(--bb-blue); }
