/* ===========================================================
   Gram Panchayat Elections — simplified results site
   Mobile-first. Public site + admin panel.
   =========================================================== */

:root {
  --ink: #171a3a;
  --ink-2: #3f4468;
  --ink-3: #767c9e;
  --paper: #f3f5fb;
  --card: #ffffff;
  --line: #e3e6f2;
  --line-2: #d2d7e9;

  --indigo: #2f3390;
  --indigo-deep: #1c1f62;
  --indigo-soft: #eef0ff;
  --saffron: #f59e0b;
  --saffron-soft: #fff6e5;
  --green: #12803f;
  --green-soft: #e9f8ef;
  --amber: #b45309;
  --red: #cf2f35;
  --red-soft: #fdecec;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 26, 58, .05), 0 10px 26px -14px rgba(23, 26, 58, .22);
  --shadow-lg: 0 2px 6px rgba(23, 26, 58, .06), 0 24px 48px -20px rgba(23, 26, 58, .3);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-te: "Noto Sans Telugu", "Gautami", "Nirmala UI", "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  overflow-x: clip;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
html[lang="te"] body { font-family: var(--font-te); }

button { font: inherit; cursor: pointer; }
a { color: var(--indigo); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }

.container { width: min(760px, 100% - 24px); margin-inline: auto; }
.muted { color: var(--ink-3); }
.small { font-size: .8rem; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 88vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--ink-2); font-size: .9rem; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--indigo); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================
   HEADER
   =========================================================== */
.site-header {
  background:
    radial-gradient(600px 240px at 10% -50%, rgba(245, 158, 11, .25), transparent 65%),
    linear-gradient(135deg, var(--indigo-deep), var(--indigo) 60%, #3c40a8);
  color: #fff;
  padding-top: 14px;
}
.site-header .container { display: grid; gap: 12px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 170px; }
.brand-mark {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22);
  display: grid; place-items: center;
}
.brand-text { min-width: 0; }
.brand-text h1 { font-size: .98rem; font-weight: 800; letter-spacing: .1px; line-height: 1.25; overflow-wrap: anywhere; }
.brand-text h1 span { color: #ffd98a; }
.brand-text p { margin: 2px 0 0; font-size: .74rem; color: #c9cdf3; display: flex; align-items: center; gap: 6px; }
.head-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; margin-left: auto; }
.chip-btn {
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .3);
  color: #fff; font-weight: 700; font-size: .76rem; padding: 7px 12px; border-radius: 999px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.chip-btn:hover { background: rgba(255, 255, 255, .22); }

/* page switch */
.view-tabs { display: flex; gap: 6px; }
.view-tab {
  flex: 1; text-align: center; border: 0; background: transparent; color: #c9cdf3;
  font-weight: 700; font-size: .9rem; padding: 11px 8px 13px; border-bottom: 3px solid transparent;
}
.view-tab.active { color: #fff; border-bottom-color: var(--saffron); }

/* ===========================================================
   HERO / VILLAGE CARD
   =========================================================== */
main { padding: 16px 0 40px; }

.village-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.village-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.village-name { font-size: 1.15rem; font-weight: 800; }
.village-sub { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.updated { text-align: right; font-size: .7rem; color: var(--ink-3); }
.updated b { display: block; font-size: .74rem; color: var(--ink-2); }

.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.tally-cell { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfcff; }
.tally-cell .k { font-size: .64rem; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); }
.tally-cell .v { font-size: 1.25rem; font-weight: 800; margin-top: 1px; }
.tally-cell .v small { font-size: .75rem; color: var(--ink-3); font-weight: 700; }
.tally-cell.accent { background: var(--indigo-soft); border-color: #dfe3ff; }
.tally-cell.accent .k { color: #4b50b0; }
.tally-cell.accent .v { color: var(--indigo-deep); }
.tally-cell.green { background: var(--green-soft); border-color: #c8f0d7; }
.tally-cell.green .k { color: #0d6b36; }
.tally-cell.green .v { color: #0b5e2f; }

/* ===========================================================
   SECTION HEADINGS
   =========================================================== */
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section-title .dot { width: 9px; height: 9px; border-radius: 3px; background: var(--saffron); }
.section-sub { font-size: .76rem; color: var(--ink-3); }

/* ===========================================================
   STATUS PILLS
   =========================================================== */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 800; letter-spacing: .2px;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.status i { width: 7px; height: 7px; border-radius: 50%; font-style: normal; }
.status.pending { background: #f1f2f8; color: #5b6182; border: 1px solid var(--line-2); }
.status.pending i { background: #9aa0bd; }
.status.counting { background: var(--saffron-soft); color: var(--amber); border: 1px solid #fcd68d; }
.status.counting i { background: var(--saffron); animation: blink 1.2s infinite; }
.status.declared { background: var(--green-soft); color: #0d6b36; border: 1px solid #b5ebc7; }
.status.declared i { background: var(--green); }
@keyframes blink { 50% { opacity: .25; } }

/* ===========================================================
   BATTLE CARD (A vs B)
   =========================================================== */
.battle-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.battle-card.declared { border-color: #9fe6ba; box-shadow: 0 0 0 2px rgba(18, 128, 63, .12), var(--shadow); }
.battle-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px dashed var(--line-2); background: #fbfcff;
}
.battle-title { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1 1 170px; }
.ward-tag {
  flex: 0 0 auto; min-width: 40px; padding: 5px 8px; border-radius: 9px;
  background: var(--indigo-soft); border: 1px solid #dfe3ff; color: var(--indigo-deep);
  font-size: .66rem; font-weight: 800; letter-spacing: .4px; text-align: center; text-transform: uppercase;
}
.battle-title h3 { font-size: .95rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-title .sub { font-size: .72rem; color: var(--ink-3); }

.battle-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; }

/* two-candidate duel: photos row, then names row (never collide) */
.duel { padding: 16px 10px 14px; }
.duel-photos {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.duel-photos .side { padding: 0; }
.ph-wrap { position: relative; display: inline-block; }
.duel-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; }
.duel-names .side { padding: 0; }
.duel-names .side + .side { border-left: 1px dashed var(--line-2); }
.nm-wrap { display: grid; justify-items: center; gap: 5px; padding: 0 4px; }
.side { padding: 16px 8px 14px; text-align: center; min-width: 0; }
.side .who { display: grid; justify-items: center; gap: 8px; }
.side .nm-wrap { padding: 0 4px; }

.photo {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #5a5fd4, var(--indigo-deep));
  display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line-2);
}
.photo.has-photo { background-size: cover; background-position: center; background-repeat: no-repeat; }
.photo.has-photo .initial { opacity: 0; }
.photo .initial { color: #fff; font-weight: 800; font-size: 1.9rem; }
.side.winner .photo { box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--green); }

.sym-badge {
  position: absolute; right: -7px; bottom: -7px;
  width: 36px; height: 36px; border-radius: 10px; background: #fff;
  border: 1px solid var(--line-2); display: grid; place-items: center;
  box-shadow: 0 3px 8px -3px rgba(23, 26, 58, .3); overflow: hidden;
}
.sym-badge img { width: 100%; height: 100%; object-fit: cover; }
.sym-badge svg { width: 24px; height: 24px; }

.c-name { font-weight: 800; font-size: .88rem; line-height: 1.25; }
.c-name.te { font-size: .86rem; }
.c-party {
  font-size: .68rem; font-weight: 800; letter-spacing: .2px;
  padding: 3px 10px; border-radius: 999px; background: #f2f4fb;
  border: 1px solid var(--line); color: var(--ink-2);
  max-width: 100%; text-align: center; line-height: 1.3;
}
.c-party.ind { background: #f8f5ec; border-color: #ece2cc; color: #77571c; }
.c-sym-name { font-size: .68rem; color: var(--ink-3); display: flex; align-items: center; gap: 4px; justify-content: center; }

.vs {
  align-self: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 800; font-size: .74rem;
  display: grid; place-items: center; letter-spacing: .5px;
  box-shadow: 0 0 0 5px var(--paper);
}

/* 3+ candidates */
.multi-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; padding: 14px 10px; }
.multi-body .side { padding: 8px 4px; }
.multi-body .photo { width: 68px; height: 68px; }
.multi-body .photo .initial { font-size: 1.5rem; }
.multi-body .sym-badge { width: 30px; height: 30px; }
.multi-body .sym-badge svg { width: 20px; height: 20px; }
.multi-body .c-name { font-size: .8rem; }
.multi-body .c-party { font-size: .62rem; padding: 2px 7px; }

/* winner banner */
.win-banner {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 58px 11px 16px; background: var(--green); color: #fff;
}
.win-banner .sym-badge {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 9px; border: 0;
  bottom: auto; left: auto;
}
.win-banner .sym-badge { color: var(--ink); flex: 0 0 auto; }
.win-banner .sym-badge svg { width: 22px; height: 22px; }
.win-banner .tick {
  width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .2);
  display: grid; place-items: center; flex: 0 0 auto;
}
.win-banner .txt { min-width: 0; }
.win-banner .k { font-size: .62rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; opacity: .85; }
.win-banner .n { font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-banner .p { font-size: .7rem; opacity: .9; }
.win-banner .ph { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; background-color: rgba(255,255,255,.25); display:grid; place-items:center; font-weight: 800; font-size: .68rem; color: #fff; }
.win-banner .ph.has-photo { background-size: cover; background-position: center; color: transparent; }

.counting-note {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--saffron-soft); color: var(--amber);
  font-size: .78rem; font-weight: 700; border-top: 1px solid #fbe3b4;
}
.no-contest { text-align: center; padding: 30px 16px; color: var(--ink-3); font-size: .88rem; }

/* ===========================================================
   OVERVIEW LIST
   =========================================================== */
.ov-list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.ov-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 12px; box-shadow: 0 1px 2px rgba(23, 26, 58, .04);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s ease, transform .1s ease;
}
.ov-row:hover { border-color: #b9bedd; }
.ov-row:active { transform: scale(.995); }
.ov-row .grow { flex: 1 1 auto; min-width: 0; display: block; }
.ov-row .nm { font-weight: 800; font-size: .88rem; display: block; }
.ov-row .nm-sub { color: var(--ink-3); font-weight: 600; font-size: .78rem; }
.ov-row .vs-line { display: block; font-size: .76rem; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }
.ov-row .vs-line b { color: var(--ink-2); font-weight: 700; }

/* inline election symbol thumb + party name */
.mini-sym {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  border: 1px solid var(--line-2); border-radius: 5px; background: #fff;
  color: var(--ink-2); overflow: hidden; vertical-align: middle;
}
.mini-sym svg { display: block; }
.mini-sym.has-img { background-size: cover; background-position: center; }
.cand-inline { display: inline-flex; align-items: center; gap: 4px; }
.cand-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.cand-line + .cand-line { margin-top: 2px; }
.cand-line .mini-sym { align-self: center; }
.vs-prefix {
  font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-3); background: #f2f4fb; border-radius: 4px; padding: 0 4px; opacity: .9;
}
.cand-inline b { font-weight: 700; }
.party-inline { color: var(--ink-3); font-weight: 700; font-size: .94em; }
.cand-inline { flex-wrap: wrap; }
.cand-inline .party-inline { font-size: .9em; }
.vs-sep { color: var(--ink-3); font-size: .68rem; font-weight: 800; text-transform: uppercase; margin: 0 3px; opacity: .75; }
.ov-win .mini-sym { margin-left: 2px; }
.ov-row .row-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.ov-row .chev { color: var(--ink-3); font-size: .9rem; flex: 0 0 auto; align-self: center; }
.ov-row .ward-tag { align-self: flex-start; margin-top: 1px; min-width: 38px; }
.ov-win { display: inline-flex; align-items: flex-start; gap: 6px; font-size: .72rem; font-weight: 700; color: #0d6b36; margin-top: 2px; max-width: 100%; }
.ov-win .txt { min-width: 0; line-height: 1.45; }
.ov-win .txt b { font-weight: 800; }
.ov-win .ph { width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; overflow: hidden; background-color: var(--green-soft); display:grid; place-items:center; font-size:.56rem; font-weight:800; color:#0d6b36; }
.ov-win .ph.has-photo { background-size: cover; background-position: center; color: transparent; }

/* ===========================================================
   MISC
   =========================================================== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: #fbfcff; font-size: .88rem; }
.empty .big { font-size: 1.5rem; margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font-weight: 700; font-size: .84rem;
  text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: #b3b9d6; }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn.primary:hover { background: var(--indigo-deep); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c9cb; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: .76rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.banner { border-radius: 12px; padding: 10px 13px; font-size: .8rem; border: 1px solid #fcd68d; background: var(--saffron-soft); color: #7c4a03; }
.banner.blue { border-color: #c6d8fb; background: #eef4ff; color: #1e40af; }
.banner.red { border-color: #f0c9cb; background: var(--red-soft); color: #a11d21; }
.banner.green { border-color: #b5ebc7; background: var(--green-soft); color: #0d6b36; }

.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0 28px; }
.site-footer .container { display: grid; gap: 10px; }
.foot-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .76rem; color: var(--ink-3); }
.foot-links { display: flex; gap: 12px; align-items: center; }
.foot-links a { color: var(--ink-2); font-weight: 700; text-decoration: none; }
.disclaimer { font-size: .72rem; color: #8a6a2f; background: var(--saffron-soft); border: 1px solid #fbe3b4; border-radius: 10px; padding: 9px 11px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(70px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: .82rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: all .25s ease; z-index: 300; max-width: calc(100% - 24px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* ===========================================================
   ADMIN
   =========================================================== */
.admin-top { background: linear-gradient(135deg, #12143f, var(--indigo-deep)); color: #fff; padding: 12px 0; }
.admin-top .container { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.admin-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-brand .brand-mark { width: 40px; height: 40px; border-radius: 10px; }
.admin-brand h1 { font-size: .92rem; font-weight: 800; white-space: nowrap; }
.admin-brand p { margin: 1px 0 0; font-size: .68rem; color: #b9bde8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.admin-user { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.mode-chip { font-size: .62rem; font-weight: 800; letter-spacing: .4px; padding: 4px 8px; border-radius: 999px; text-transform: uppercase; background: var(--saffron); color: #3b2500; }
.mode-chip.live { background: #34d399; color: #04351f; }

.admin-wrap { padding: 16px 0 70px; }
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  flex: 0 0 auto; border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; font-size: .8rem; font-weight: 700;
}
.admin-tab.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: .74rem; font-weight: 800; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: .9rem; background: #fbfcff; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid #c7cbfa; border-color: #9aa0ee; background: #fff; }
.field .hint { font-size: .68rem; color: var(--ink-3); }
.field-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.admin-section { margin-bottom: 18px; }
.admin-section h2 { font-size: .95rem; font-weight: 800; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.list-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; margin-bottom: 7px;
}
.list-row .grow { flex: 1 1 120px; min-width: 0; }

/* stacked admin row: content full width, status + actions on their own line */
.list-row.stack { flex-wrap: wrap; align-items: flex-start; row-gap: 8px; }
.list-row.stack .grow { flex: 1 1 calc(100% - 56px); }
.list-row.stack .status { order: 3; }
.list-row.stack .row-actions { order: 4; margin-left: auto; }
.list-row.stack .cand-line { font-size: .76rem; }
.list-row .title { font-weight: 800; font-size: .86rem; }
.list-row .sub { font-size: .72rem; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-left: auto; align-items: center; }

/* candidate editor row */
.cand-editor { border: 1px solid var(--line); border-radius: 12px; padding: 11px; margin-bottom: 9px; background: #fcfdff; }
.cand-editor .topline { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 9px; }
.cand-editor .avatar-btn {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%; border: 1.5px dashed var(--line-2);
  background: #fff; display: grid; place-items: center; overflow: hidden; position: relative;
  color: var(--ink-3); font-size: .6rem; font-weight: 700; text-align: center; line-height: 1.15;
}
.cand-editor .avatar-btn.has-photo { background-size: cover; background-position: center; color: transparent; border-style: solid; }
.cand-editor .grow { flex: 1; display: grid; gap: 6px; min-width: 0; }
.cand-editor input { width: 100%; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 10px; font: inherit; font-size: .86rem; background: #fff; }
.cand-editor .mini-grid { display: grid; grid-template-columns: 1fr 84px 34px; gap: 6px; }
.cand-editor .mini-grid .sym-slot, .cand-editor .mini-grid .rm { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: #fff; display: grid; place-items: center; overflow: hidden; }
.cand-editor .mini-grid .sym-slot { width: 34px; }
.cand-editor .mini-grid .sym-slot img { width: 100%; height: 100%; object-fit: cover; }
.cand-editor .mini-grid .sym-slot svg { width: 22px; height: 22px; }
.cand-editor .sym-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cand-editor .sym-row .sym-slot { margin: 0; }
.cand-editor .sym-label { display: grid; gap: 1px; min-width: 0; }
.cand-editor .sym-label .k { font-size: .62rem; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-3); }
.cand-editor .sym-label b { font-size: .78rem; font-weight: 800; color: var(--ink-2); }
/* party name chip is no longer used */
.c-party, .party-inline { display: none; }

/* symbol picker grid */
.sym-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; max-height: 320px; overflow-y: auto; padding: 2px; }
.sym-opt {
  border: 1px solid var(--line-2); border-radius: 10px; background: #fff; height: 54px;
  display: grid; place-items: center; position: relative; color: var(--ink-2); padding: 0;
}
.sym-opt svg { width: 26px; height: 26px; }
.sym-opt .lbl { position: absolute; bottom: 1px; font-size: .44rem; color: var(--ink-3); max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-opt.selected { border-color: var(--indigo); background: var(--indigo-soft); box-shadow: 0 0 0 2px rgba(47, 51, 144, .18); }

dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 16px));
  max-height: calc(100dvh - 24px); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(16, 18, 48, .55); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.dialog-head h3 { font-size: .95rem; font-weight: 800; }
.dialog-body { padding: 14px 16px; overflow-y: auto; max-height: calc(100dvh - 170px); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fbfcff; position: sticky; bottom: 0; flex-wrap: wrap; }
.icon-btn { border: 0; background: #f1f3fa; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--ink-2); font-size: .9rem; flex: 0 0 auto; }
.icon-btn:hover { background: #e6e9f5; }

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 18px; }
.login-card { width: min(400px, 100%); }
.login-card .logo-row { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.login-card .logo-row .brand-mark { background: var(--indigo-soft); border-color: #dfe3ff; }
.login-card h2 { font-size: 1.1rem; font-weight: 800; }

/* instagram studio */
.ig-grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .ig-grid { grid-template-columns: 1fr 280px; align-items: start; } }
.poster-frame { background: #10122d; border-radius: 14px; padding: 10px; display: grid; place-items: center; }
.poster-frame img { width: 100%; max-width: 420px; border-radius: 6px; display: block; }
.ig-actions { display: grid; gap: 8px; }
.caption-box { font-size: .76rem; color: var(--ink-2); background: #f7f8fd; border: 1px solid var(--line); border-radius: 10px; padding: 10px; white-space: pre-wrap; max-height: 160px; overflow-y: auto; }

/* print */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .view-tabs, .head-actions, .banner { display: none !important; }
  .battle-card, .village-card, .ov-row { box-shadow: none !important; break-inside: avoid; }
  .win-banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===========================================================
   WIDER SCREENS
   =========================================================== */
@media (min-width: 700px) {
  .container { width: min(880px, 100% - 32px); }
  .brand-text h1 { font-size: 1.2rem; }
  .photo { width: 104px; height: 104px; }
  .photo .initial { font-size: 2.3rem; }
  .sym-badge { width: 40px; height: 40px; }
  .sym-badge svg { width: 27px; height: 27px; }
  .c-name { font-size: 1rem; }
  .side { padding: 22px 12px 18px; }
  .vs { width: 52px; height: 52px; font-size: .8rem; }
  .tally-cell .v { font-size: 1.45rem; }
  .village-name { font-size: 1.3rem; }
}
