* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Cairo', 'Tahoma', sans-serif;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  color: #222;
  direction: rtl;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ===== COMMON ===== */
.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }
.btn {
  display: inline-block; padding: 12px 24px; border: none; cursor: pointer;
  border-radius: 10px; font-family: inherit; font-size: 16px; font-weight: 700;
  transition: transform .1s, box-shadow .2s; background: #3498db; color: #fff;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.btn:active { transform: translateY(0); }
.btn-danger { background: #e74c3c; }
.btn-success { background: #27ae60; }
.btn-warn { background: #f39c12; }
.btn-ghost { background: rgba(255,255,255,.15); color: #fff; }
.btn-block { display: block; width: 100%; }
.card {
  background: #fff; border-radius: 14px; padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); margin-bottom: 20px;
}
input[type=text], input[type=password], input[type=number] {
  width: 100%; padding: 12px 14px; border: 2px solid #e4e4e4;
  border-radius: 10px; font-family: inherit; font-size: 16px; outline: none;
}
input:focus { border-color: #3498db; }
label { display: block; margin-bottom: 6px; font-weight: 700; color: #333; }
.form-row { margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 700; }
.alert-error { background: #fdecea; color: #c0392b; }
.alert-ok { background: #e9f7ef; color: #1e8449; }

/* ===== LOGIN ===== */
.login-box {
  max-width: 440px; margin: 10vh auto; background: #fff;
  border-radius: 18px; padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; text-align: center; }
.login-box p { text-align: center; color: #777; margin-bottom: 24px; }

/* ===== PUBLIC RESULTS ===== */
.public-head {
  text-align: center; padding: 30px 20px 20px; color: #fff;
}
.public-head h1 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.public-head .sub { opacity: .85; font-size: 16px; }
.lists-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  margin-bottom: 24px;
}
.list-card {
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}
.list-head {
  padding: 20px; display: flex; align-items: center; gap: 16px;
  color: #fff;
}
.list-head .logo-wrap {
  position: relative; flex-shrink: 0;
}
.list-head .logo {
  width: 120px; height: 120px; object-fit: contain; display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.35));
}
.list-head .num-badge {
  position: absolute; top: 6px; right: 6px;
  width: 34px; height: 34px; border-radius: 50%;
  background: #1a1a2e; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; font-family: 'Cairo', sans-serif;
  box-shadow: 0 3px 8px rgba(0,0,0,.5);
  border: 2px solid #fff;
  line-height: 1;
}
.list-head .info { flex: 1; }
.list-head .info .name { font-size: 18px; font-weight: 800; margin-bottom: 4px; line-height: 1.2; }
.list-head .info .stat { font-size: 14px; opacity: .95; }
.list-head .total {
  text-align: center; padding: 8px 12px; background: rgba(0,0,0,.15);
  border-radius: 10px; min-width: 100px;
}
.list-head .total .n { font-size: 28px; font-weight: 800; line-height: 1; }
.list-head .total .l { font-size: 12px; opacity: .95; }
.list-pct {
  padding: 10px 20px; background: #f7f7f7; font-size: 14px;
  display: flex; justify-content: space-between; border-bottom: 1px solid #eee;
}
.list-pct b { color: #2c3e50; font-size: 16px; }
.cand-list { list-style: none; padding: 8px 0; }
.cand-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid #f0f0f0; position: relative;
  transition: background .2s;
}
.cand-row:last-child { border-bottom: none; }
.cand-rank {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #eee; color: #555; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.cand-row.top .cand-rank { background: #f1c40f; color: #fff; }
.cand-row.top1 { background: linear-gradient(90deg, rgba(241,196,15,.18), transparent); }
.cand-row.top1 .cand-rank { background: #f39c12; color: #fff; font-size: 14px; }
.cand-row.top1 .cand-name { font-weight: 800; font-size: 16px; }
.cand-name { flex: 1; font-size: 14px; color: #2c3e50; }
.cand-votes {
  font-weight: 800; color: #2c3e50; min-width: 60px; text-align: left;
  font-size: 16px;
}
.cand-bar {
  position: absolute; bottom: 0; right: 0; height: 3px;
  background: currentColor; opacity: .5; transition: width .5s;
}

.global-stats {
  background: rgba(255,255,255,.1); backdrop-filter: blur(10px);
  border-radius: 14px; padding: 20px; color: #fff; margin-bottom: 20px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  text-align: center;
}
.global-stats .s-n { font-size: 30px; font-weight: 800; }
.global-stats .s-l { font-size: 14px; opacity: .8; }

.live-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: #e74c3c; animation: pulse 1.2s infinite; margin-left: 6px;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ===== ADMIN ===== */
.admin-nav {
  background: #1a1a2e; color: #fff; padding: 14px 20px;
  display: flex; gap: 20px; align-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.2); flex-wrap: wrap;
}
.admin-nav .brand { font-weight: 800; font-size: 18px; }
.admin-nav a { padding: 8px 14px; border-radius: 8px; transition: background .2s; }
.admin-nav a.active, .admin-nav a:hover { background: rgba(255,255,255,.15); }
.admin-nav .spacer { flex: 1; }
.data-table { width: 100%; background: #fff; border-collapse: collapse; border-radius: 12px; overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid #f0f0f0; }
.data-table th { background: #f7f8fc; font-weight: 700; }
.data-table tr:hover { background: #fafbfc; }

/* ===== CENTER OPERATOR ===== */
.op-shell { display: flex; flex-direction: column; min-height: 100vh; }
.op-head {
  background: #1a1a2e; color: #fff; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.op-head .brand { font-weight: 800; }
.op-head .spacer { flex: 1; }
.op-head .center-name { background: rgba(255,255,255,.1); padding: 6px 12px; border-radius: 8px; }
.undo-btn-top {
  background: #e74c3c; color: #fff; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; font-family: inherit;
  font-weight: 700; font-size: 14px;
}
.undo-btn-top:hover:not(:disabled) { background: #c0392b; }
.undo-btn-top:disabled { background: rgba(231,76,60,.4); cursor: not-allowed; }
.op-totals { display: flex; gap: 10px; flex-wrap: wrap; }
.op-totals .t { background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.op-totals .t b { font-size: 18px; margin-right: 6px; }

.op-lists {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  padding: 10px; padding-bottom: 140px;
}
.op-list {
  background: #fff; border-radius: 12px; padding: 10px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.op-list-head {
  padding: 10px; color: #fff; border-radius: 10px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.op-list-head .logo { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.op-list-head .name { font-weight: 800; font-size: 16px; flex: 1; }
.op-list-head .total { font-weight: 800; font-size: 20px; }
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.op-btn {
  background: #f7f8fc; border: 2px solid #eef; border-radius: 8px;
  padding: 10px 8px; cursor: pointer; text-align: right;
  display: flex; align-items: center; gap: 8px;
  transition: all .1s; font-family: inherit; user-select: none;
  min-height: 52px;
}
.op-btn:hover { background: #edf2ff; border-color: #3498db; }
.op-btn:active { transform: scale(.97); }
.op-btn.flash { background: #2ecc71 !important; border-color: #27ae60 !important; color: #fff; }
.op-btn .num {
  width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #2c3e50; color: #fff; font-weight: 800; font-size: 14px;
}
.op-btn .cname { flex: 1; font-size: 13px; font-weight: 700; line-height: 1.2; color: #2c3e50; }
.op-btn .cfirst { display: none; }
.op-btn .cvotes {
  background: #fff; border-radius: 6px; padding: 2px 8px;
  font-weight: 800; color: #2c3e50; font-size: 14px; min-width: 32px; text-align: center;
}
.op-btn.flash .cname, .op-btn.flash .cvotes { color: #fff; }
.op-btn.flash .num { background: rgba(0,0,0,.3); }
.op-btn.flash .cvotes { background: rgba(255,255,255,.25); color: #fff; }

/* ===== TWO-SCREEN FLOW ===== */
.screen-lists {
  flex: 1; padding: 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
  background: linear-gradient(135deg, #0f2027, #203a43);
  color: #fff;
  min-height: 0;
}
.sl-hint {
  text-align: center; font-size: 18px; font-weight: 700;
  color: rgba(255,255,255,.85); padding: 10px;
}
.list-chooser {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.lch {
  background: #fff; border: 3px solid var(--c); border-radius: 16px;
  padding: 24px 16px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: transform .1s, box-shadow .2s;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.lch:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(0,0,0,.3); }
.lch:active { transform: translateY(-1px); }
.lch img { width: 110px; height: 110px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,.2)); }
.lch-name { font-size: 20px; font-weight: 800; color: #2c3e50; text-align: center; }
.lch-count {
  background: var(--c); color: #fff; padding: 8px 20px; border-radius: 10px;
  font-size: 16px; font-weight: 700;
}
.lch-count b { font-size: 24px; margin-left: 4px; }

.action-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-width: 600px; margin: 0 auto; width: 100%;
}
.action-btn {
  padding: 16px; border-radius: 12px; border: none; cursor: pointer;
  font-family: inherit; font-size: 18px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: transform .1s;
}
.action-btn:active { transform: scale(.97); }
.action-btn.flash { background: #27ae60 !important; color: #fff !important; }
.action-btn.invalid { background: #e74c3c; color: #fff; }
.action-btn.blank { background: #95a5a6; color: #fff; }
.action-btn .lbl { font-size: 18px; }
.action-btn .cnt {
  background: rgba(255,255,255,.25); padding: 4px 14px; border-radius: 8px;
  font-size: 22px; font-weight: 800;
}
.action-row-secondary {
  display: flex; gap: 12px; max-width: 600px; margin: 0 auto; width: 100%;
}
.action-btn-alt {
  flex: 1; padding: 12px; border-radius: 10px; border: none; cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 700;
  text-align: center;
}
.action-btn-alt:active { transform: scale(.97); }

/* Screen 2: candidate selector */
.screen-cands {
  flex: 1; display: flex; flex-direction: column;
  background: #f7f8fc; min-height: 0;
}
.sc-head {
  padding: 14px 20px; color: #fff;
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2); flex-shrink: 0;
}
.sc-head .back-btn {
  background: rgba(255,255,255,.25); color: #fff; border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; font-family: inherit; font-weight: 700;
  font-size: 14px;
}
.sc-title { flex: 1; font-size: 20px; font-weight: 800; display: flex; align-items: center; }
.sc-count {
  background: rgba(0,0,0,.25); padding: 6px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 700;
}
.sc-count b { font-size: 20px; margin: 0 4px; }

.cand-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px;
  align-content: start;
}
.cand-btn {
  background: #fff; border: 2px solid #e4e4e4; border-radius: 10px;
  padding: 10px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 10px;
  transition: all .1s; position: relative;
}
.cand-btn:hover { border-color: var(--c); background: #f7f9fd; }
.cand-btn.selected {
  border-color: var(--c); border-width: 3px;
  background: #fffbea;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.1);
}
.cand-btn .num {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: #2c3e50; color: #fff; font-weight: 800; font-size: 15px;
  flex-shrink: 0; transition: transform .15s;
}
.cand-btn.selected .num { background: var(--c); transform: scale(1.1); }
.cand-btn.selected .cname, .cand-btn.selected .cfirst { font-weight: 800; }
.cand-btn .cname { flex: 1; font-size: 14px; font-weight: 700; color: #2c3e50; line-height: 1.2; }
.cand-btn .cfirst { display: none; }
.cand-btn .check { font-size: 22px; color: #ccc; flex-shrink: 0; }
.cand-btn.selected .check { color: var(--c); }

.new-ballot-btn {
  background: linear-gradient(135deg, #27ae60, #219150);
  color: #fff; border: none; cursor: pointer;
  padding: 16px; font-size: 20px; font-weight: 800; font-family: inherit;
  box-shadow: 0 -6px 20px rgba(0,0,0,.2);
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  line-height: 1.1;
}
.new-ballot-btn small { font-size: 13px; font-weight: 600; opacity: .85; }
.new-ballot-btn:hover { background: linear-gradient(135deg, #219150, #1e8449); }
.new-ballot-btn:active { transform: scale(.99); }
.new-ballot-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===== MOBILE: Screen 1 + 2 adjustments ===== */
@media (max-width: 900px) {
  .screen-lists { padding: 8px; gap: 8px; }
  .sl-hint { font-size: 13px; padding: 2px; }
  .list-chooser { grid-template-columns: 1fr; gap: 10px; }
  .lch { padding: 14px; flex-direction: row; text-align: right; gap: 14px; align-items: center; }
  .lch img { width: 70px; height: 70px; flex-shrink: 0; }
  .lch-name { font-size: 18px; line-height: 1.1; flex: 1; text-align: right; font-weight: 800; }
  .lch-count { font-size: 14px; padding: 6px 14px; flex-shrink: 0; }
  .lch-count b { font-size: 20px; }
  .action-btn { padding: 10px; font-size: 14px; }
  .action-btn .lbl { font-size: 14px; }
  .action-btn .cnt { font-size: 16px; padding: 2px 10px; }
  .action-btn-alt { padding: 8px; font-size: 14px; }
  .sc-head { padding: 8px 12px; gap: 8px; }
  .sc-title { font-size: 14px; }
  .sc-title img { width: 24px !important; height: 24px !important; }
  .sc-count { font-size: 12px; padding: 4px 10px; }
  .sc-count b { font-size: 14px; }
  .cand-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(8, auto);
    grid-auto-flow: column;
    gap: 5px; padding: 6px;
  }
  .cand-btn { padding: 7px 8px; gap: 6px; }
  .cand-btn .cname { display: none; }
  .cand-btn .cfirst { display: inline; flex: 1; font-size: 13px; font-weight: 700; color: #2c3e50; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .cand-btn .num { width: 26px; height: 26px; font-size: 12px; }
  .cand-btn .check { font-size: 18px; }
  .new-ballot-btn { padding: 14px; font-size: 17px; }
  .new-ballot-btn small { font-size: 11px; }
}
@media (max-width: 480px) {
  .cand-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(8, auto);
    grid-auto-flow: column;
    gap: 4px; padding: 4px;
  }
  .cand-btn .num { width: 22px; height: 22px; font-size: 11px; }
  .cand-btn .cfirst { font-size: 12px; }
  .cand-btn .check { font-size: 16px; }
}

/* ===== OLD Clickable list header (legacy; unused in new flow) ===== */
.op-list-head.list-btn {
  border: none; cursor: pointer; font-family: inherit;
  width: 100%; text-align: right;
  position: relative; transition: transform .1s, box-shadow .2s;
}
.op-list-head.list-btn:hover { box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.op-list-head.list-btn:active { transform: scale(.98); }
.op-list-head.list-btn.flash {
  animation: listFlash .4s;
}
@keyframes listFlash {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3) saturate(1.5); box-shadow: 0 0 0 4px rgba(46,204,113,.6); }
  100% { filter: brightness(1); }
}
.op-list-head.list-btn::before {
  content: '👆 اضغط هنا لاحتساب صوت ورقة';
  position: absolute; top: 2px; left: 8px;
  font-size: 10px; opacity: .75; font-weight: 400;
}

/* Ballot tracker (inside footer) */
.op-footer .ballot-tracker {
  background: #f39c12; color: #fff;
  padding: 8px 16px; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; font-size: 14px;
}
.op-footer .ballot-tracker.over-limit { background: #c0392b; animation: flashWarn .7s infinite alternate; }
@keyframes flashWarn { to { background: #e74c3c; } }
.ballot-tracker .bt-label { font-weight: 700; opacity: .9; }
.ballot-tracker .bt-list { font-weight: 800; font-size: 16px; background: rgba(0,0,0,.15); padding: 2px 10px; border-radius: 6px; }
.ballot-tracker .bt-divider { opacity: .4; }
.ballot-tracker .bt-count { font-size: 15px; }
.ballot-tracker .bt-count b { font-size: 20px; font-weight: 800; margin: 0 4px; }

.op-footer {
  position: fixed; bottom: 0; right: 0; left: 0; background: #1a1a2e;
  color: #fff; border-top: 3px solid #f39c12;
  display: flex; flex-direction: column;
  box-shadow: 0 -6px 20px rgba(0,0,0,.3);
  z-index: 100;
}
.op-footer-row {
  padding: 10px; display: flex; gap: 10px; align-items: center;
}
.op-special { display: flex; gap: 8px; flex-shrink: 0; }
.special-btn {
  border: none; cursor: pointer; border-radius: 10px;
  padding: 10px 14px; font-family: inherit; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 80px; transition: transform .1s;
}
.special-btn:active { transform: scale(.95); }
.special-btn.flash { background: #2ecc71 !important; color: #fff !important; }
.special-btn .lbl { font-size: 14px; }
.special-btn .cnt { font-size: 18px; font-weight: 800; }
.special-btn.invalid { background: #e74c3c; color: #fff; }
.special-btn.blank { background: #95a5a6; color: #fff; }
.undo-btn {
  background: #e74c3c; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-weight: 800; border: none; cursor: pointer; flex-shrink: 0; font-size: 15px;
}
.undo-btn:disabled { opacity: .4; cursor: not-allowed; }
.history {
  flex: 1; overflow-x: auto; white-space: nowrap; display: flex; gap: 6px;
  padding: 2px;
}
.history-item {
  background: rgba(255,255,255,.1); border-radius: 8px; padding: 6px 10px;
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px;
  flex-shrink: 0;
}
.history-item .x {
  background: rgba(231,76,60,.8); color: #fff; border: none; border-radius: 50%;
  width: 22px; height: 22px; cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.history-item .x:hover { background: #e74c3c; }
.history-item.gone { opacity: .4; text-decoration: line-through; }

@media (max-width: 1024px) {
  .lists-grid { grid-template-columns: 1fr; }
  .global-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== MOBILE VIEW — compact single-screen layout ===== */
@media (max-width: 900px) {
  body { overflow: auto; }
  .op-shell { min-height: 100vh; min-height: 100dvh; overflow: visible; display: flex; flex-direction: column; }
  .op-head {
    padding: 4px 8px; gap: 4px; flex-shrink: 0;
    flex-wrap: wrap;
  }
  .op-head .brand { font-size: 12px; }
  .op-head .center-name {
    font-size: 11px; padding: 2px 6px;
    max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .op-head .spacer { display: none; }
  .op-head .op-totals { order: 10; width: 100%; gap: 3px; flex-wrap: nowrap; overflow-x: auto; }
  .op-totals .t {
    font-size: 10px; padding: 2px 6px; flex-shrink: 0;
  }
  .op-totals .t b { font-size: 12px; margin-right: 3px; }
  #editToggle { padding: 4px 8px !important; font-size: 11px !important; }
  .op-head a[href*="logout"] { padding: 4px 8px !important; font-size: 11px !important; }
  .undo-btn-top { padding: 4px 8px !important; font-size: 11px !important; }

  /* 3 columns, one per list — 15 buttons stacked per list */
  .op-lists {
    flex: 1; overflow: hidden;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 3px; padding: 3px; padding-bottom: 0;
    min-height: 0;
  }
  .op-list { padding: 3px; display: flex; flex-direction: column; min-height: 0; }
  .op-list-head {
    padding: 4px; gap: 4px; margin-bottom: 3px;
    border-radius: 6px;
  }
  .op-list-head .logo { width: 22px; height: 22px; filter: none; }
  .op-list-head .name {
    font-size: 10px; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .op-list-head .total { font-size: 14px; }
  .op-list-head.list-btn::before { display: none; }
  .ballot-tracker { padding: 6px 10px; font-size: 12px; flex-wrap: wrap; gap: 6px; }
  .ballot-tracker .bt-list { font-size: 13px; }
  .ballot-tracker .bt-count { font-size: 12px; }
  .ballot-tracker .bt-count b { font-size: 16px; }

  /* single column of 15 buttons per list */
  .op-grid {
    grid-template-columns: 1fr; gap: 2px;
    flex: 1; min-height: 0;
  }
  .op-btn {
    padding: 3px 5px; min-height: 0; gap: 4px;
    flex-direction: row; text-align: right;
    border-radius: 5px; border-width: 1px;
  }
  .op-btn .num {
    width: 20px; height: 20px; font-size: 11px;
    border-radius: 4px; flex-shrink: 0;
  }
  .op-btn .cname { display: none; }
  .op-btn .cfirst {
    display: inline; flex: 1; min-width: 0;
    font-size: 11px; font-weight: 700; line-height: 1.1; color: #2c3e50;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .op-btn .cvotes {
    font-size: 13px; padding: 0 4px; min-width: 24px;
    flex-shrink: 0;
  }

  .op-footer {
    flex-shrink: 0; position: static;
  }
  .op-footer-row {
    padding: 6px; gap: 6px; flex-wrap: nowrap; justify-content: space-between;
  }
  .op-footer .history { display: none; }
  .op-footer #clearHistory { display: none; }
  .op-special { flex: 1; justify-content: flex-start; gap: 6px; }
  .special-btn {
    flex: 1; padding: 10px 8px; min-width: 0;
    flex-direction: row; gap: 6px; justify-content: center;
    font-size: 13px; font-weight: 800;
  }
  .special-btn .lbl { font-size: 13px; }
  .special-btn .cnt { font-size: 16px; padding: 2px 6px; background: rgba(255,255,255,.25); border-radius: 6px; }
  .undo-btn { padding: 10px 14px; font-size: 13px; flex-shrink: 0; }
}

/* Very narrow: tighter but keep first name + number + count */
@media (max-width: 480px) {
  .op-list-head .name { display: none; }
  .op-btn { padding: 2px 4px; }
  .op-btn .num { width: 18px; height: 18px; font-size: 10px; }
  .op-btn .cfirst { font-size: 10px; }
  .op-btn .cvotes { font-size: 12px; min-width: 22px; }
}

/* ===== EDIT SCREEN (full overlay) ===== */
.edit-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #1a1a2e, #2c5364);
  display: flex; flex-direction: column;
}
.edit-screen-head {
  background: #0f1625; color: #fff;
  padding: 14px 20px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3); flex-shrink: 0;
  flex-wrap: wrap;
}
.edit-screen-head h2 { flex: 1; font-size: 18px; font-weight: 800; }
.edit-screen-body {
  flex: 1; overflow-y: auto; padding: 16px; color: #222;
}
.edit-summary {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.edit-summary .es-card {
  padding: 12px; border-radius: 10px; color: #fff; text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.edit-summary .es-card .es-t { font-size: 13px; opacity: .9; margin-bottom: 4px; }
.edit-summary .es-card .es-n { font-size: 26px; font-weight: 800; }
.edit-specials {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 16px;
}
.special-edit-card {
  background: #fff; border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  border-right: 5px solid transparent;
  min-width: 0;
}
.special-edit-card.invalid { border-right-color: #e74c3c; }
.special-edit-card.blank { border-right-color: #95a5a6; }
.special-edit-card .label {
  flex: 1; font-weight: 800; font-size: 14px; color: #2c3e50;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.special-edit-card.invalid .label { color: #c0392b; }
.special-edit-card.blank .label { color: #556677; }
.special-edit-card .el-input {
  width: 72px; padding: 6px 8px; font-size: 16px; font-weight: 800;
  text-align: center; border: 2px solid #ddd; border-radius: 6px;
  font-family: 'Cairo', sans-serif; outline: none;
  flex-shrink: 0;
}
.special-edit-card .el-input:focus { border-color: #3498db; }
.special-edit-card .el-input.changed { border-color: #f39c12; background: #fff9e6; }
.edit-list {
  background: #fff; border-radius: 12px; overflow: hidden;
  margin-bottom: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.edit-list-head {
  color: #fff; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; font-weight: 800;
  flex-wrap: wrap;
}
.edit-list-head img { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.edit-list-head .lname { flex: 1; font-size: 17px; }
.edit-list-head .head-edit {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.25); padding: 6px 10px; border-radius: 8px;
}
.edit-list-head .head-edit label { font-size: 13px; font-weight: 700; color: #fff; margin: 0; }
.edit-list-head .el-input-inline {
  width: 90px; padding: 6px 10px; font-size: 18px; font-weight: 800;
  text-align: center; border: 2px solid rgba(255,255,255,.5); border-radius: 6px;
  font-family: 'Cairo', sans-serif; background: rgba(255,255,255,.95); color: #2c3e50;
  outline: none;
}
.edit-list-head .el-input-inline:focus { border-color: #fff; }
.edit-list-head .el-input-inline.changed { border-color: #f39c12; background: #fff9e6; }
.edit-rows-label { padding: 8px 14px; color: #999; font-size: 13px; background: #f7f8fc; border-bottom: 1px solid #eee; font-weight: 700; }
.edit-list-rows { padding: 6px; }
.edit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid #f0f0f0;
}
.edit-row:last-child { border-bottom: none; }
.edit-row .el-num {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: #1a1a2e; color: #fff; font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.edit-row .el-name {
  flex: 1; font-size: 14px; color: #2c3e50; font-weight: 700;
}
.edit-specials .edit-row { border: 2px dashed #ddd; border-radius: 10px; padding: 10px; }
.edit-specials .edit-row .el-name { font-size: 15px; }
.edit-row .el-input {
  width: 100px; padding: 8px 10px; font-size: 18px; font-weight: 800;
  text-align: center; border: 2px solid #ddd; border-radius: 8px;
  font-family: 'Cairo', sans-serif; outline: none;
}
.edit-row .el-input:focus { border-color: #3498db; }
.edit-row .el-input.changed { border-color: #f39c12; background: #fff9e6; }
body.editing { overflow: hidden; }
