/* Taj Sultan Owners' Committee Vote — Madinet Masr identity.
   Mobile-first, RTL-safe (logical properties only). */

:root {
  --brand: #d4112a;
  --brand-dark: #7d0d18;
  --brand-hover: #b30e23;
  --brand-tint: #fdecee;
  --brand-tint-line: #f5c9cf;
  --bg: #faf6f6;
  --card: #ffffff;
  --ink: #231a1c;
  --muted: #6a5f61;
  --line: #eadfe0;
  --ok: #1f7a4d;
  --ok-bg: #e7f4ec;
  --err: #a50e20;
  --err-bg: #fdecee;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 26, 28, .04), 0 8px 24px rgba(35, 26, 28, .07);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans Arabic", Tahoma, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -.01em;
  margin-block: 0 .6em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin-block: 0 .8em; }
a { color: var(--brand); }

/* ---------- header ---------- */
.site-header {
  background: #fff;
  border-block-end: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.header-inner {
  max-width: 1100px;
  margin-inline: auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
}
.brand-logo { flex: 0 0 auto; width: 40px; height: 40px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { font-size: .8rem; color: var(--muted); line-height: 1.3; }

.lang-toggle, .header-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 6px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.lang-toggle:hover, .header-btn:hover { background: var(--brand-hover); }
.inline-form { margin: 0; }

/* ---------- hero band ---------- */
.hero {
  background: linear-gradient(120deg, var(--brand-dark) 0%, #a40d20 45%, var(--brand) 100%);
  color: #fff;
}
.hero-inner {
  max-width: 760px;
  margin-inline: auto;
  padding: 28px 16px 92px;
}
.hero-slim { height: 104px; }
.eyebrow {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .85);
  margin-block-end: 10px;
}
.hero-title {
  color: #fff;
  font-size: 1.85rem;
  line-height: 1.15;
  margin-block-end: 14px;
}
.hero-greeting { font-weight: 700; font-size: 1.05rem; margin-block-end: 6px; }
.hero-text { color: rgba(255, 255, 255, .92); margin: 0; }

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding: 20px 16px 32px;
  flex: 1 0 auto;
  position: relative;
}
.hero + .container { margin-block-start: -72px; padding-block-start: 0; }
.admin .container { max-width: 1100px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-block-end: 18px;
}
.card > :last-child { margin-block-end: 0; }
.card-accent { border-block-start: 4px solid var(--brand); }
.card-title { font-size: 1.4rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.text-err { color: var(--err); }
.details { margin-block: 14px; }
.details > summary { cursor: pointer; font-weight: 700; color: var(--brand); padding-block: 6px; }

/* ---------- alerts ---------- */
.alert {
  border-radius: 10px;
  padding: 12px 14px;
  margin-block-end: 14px;
  border: 1px solid transparent;
  box-shadow: var(--shadow);
}
.card .alert { box-shadow: none; }
.alert-error { background: var(--err-bg); color: var(--err); border-color: var(--brand-tint-line); }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe0cc; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a4; }

/* ---------- progress ---------- */
progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border: 0;
  border-radius: 999px;
  background: #f1e6e7;
  overflow: hidden;
  display: block;
  margin-block: 10px;
}
progress::-webkit-progress-bar { background: #f1e6e7; border-radius: 999px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--brand-dark), var(--brand)); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.turnout-count { font-size: 1.1rem; font-weight: 700; margin: 0; }

/* ---------- forms ---------- */
.field { margin-block-end: 16px; }
label, .label { display: block; font-weight: 700; margin-block-end: 6px; }
.help { display: block; font-size: .86rem; color: var(--muted); margin-block-start: 4px; font-weight: 400; }

input[type=text], input[type=password], input[type=number], input[type=search],
input[type=email], input[type=tel], textarea, select {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 1px solid #d9caca;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(212, 17, 42, .25);
  outline-offset: 1px;
  border-color: var(--brand);
}

.mono { font-family: var(--mono); }
input.unit-input { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .04em; text-transform: uppercase; }
input.digits-input {
  font-family: var(--mono);
  width: 9em;
  max-width: 100%;
  font-size: 1.6rem;
  letter-spacing: .45em;
  text-align: center;
  padding-inline-start: .6em;
}

.declare {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-line);
  border-radius: 10px;
  padding: 14px;
  margin-block-end: 16px;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
}
.declare input { width: 22px; height: 22px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--brand); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--brand); border-color: var(--brand-tint-line); }
.btn-secondary:hover { background: var(--brand-tint); border-color: var(--brand); }
.btn-gold { /* kept for admin templates: same as primary */ }
.btn-danger { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger:hover { background: #5e0912; border-color: #5e0912; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: .88rem; }
form .btn { width: 100%; }
form.inline-form .btn, td form .btn { width: auto; }

/* ---------- rules ---------- */
.rules { margin: 0; padding-inline-start: 1.3em; }
.rules li { margin-block-end: .5em; }
.rules li::marker { color: var(--brand); font-weight: 700; }

/* ---------- ballot ---------- */
.unit-banner {
  display: inline-block;
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-line);
  border-radius: 999px;
  padding: 4px 14px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-block-end: 12px;
}
.candidates { display: grid; gap: 12px; margin-block-end: 16px; }
.cand {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
  transition: border-color .12s, opacity .12s, background-color .12s;
}
.cand input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 2px solid #cbb9bb;
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-block-start: 2px;
}
.tick::after {
  content: "";
  width: 8px;
  height: 14px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0;
}
.cand input:checked ~ .tick { background: var(--brand); border-color: var(--brand); }
.cand input:checked ~ .tick::after { opacity: 1; }
.cand:has(input:checked), .cand.is-checked { border-color: var(--brand); background: #fffafa; }
.cand input:focus-visible ~ .tick { outline: 3px solid rgba(212, 17, 42, .3); outline-offset: 2px; }
.cand:has(input:disabled), .cand.is-disabled { opacity: .5; cursor: not-allowed; }
.cand-body { min-width: 0; }
.cand-name { font-weight: 700; font-size: 1.08rem; display: block; }
.cand-unit { font-size: .85rem; color: var(--muted); display: block; margin-block-end: 4px; }
.cand-bio { font-size: .93rem; margin: 0; white-space: pre-line; }

/* ---------- unit fields: compound, block, building, unit ---------- */
fieldset { border: 0; padding: 0; margin-inline: 0; min-width: 0; }
legend { padding: 0; }
.unit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.unit-compound { grid-column: 1 / -1; }
.sub-label { font-size: .85rem; font-weight: 600; color: var(--muted); margin-block-end: 4px; }
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 36px;
  font-weight: 600;
}
[dir="rtl"] select { background-position: 13px 50%, 18px 50%; }
input.unit-part {
  font-family: var(--mono);
  font-size: 1.3rem;
  text-align: center;
  letter-spacing: .08em;
}

/* ---------- people (search results, picks) ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.count-pill {
  display: inline-block;
  font-size: .85rem;
  font-weight: 700;
  background: var(--brand-tint);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 2px 10px;
  vertical-align: middle;
  margin-inline-start: 6px;
}
.pick-list, .result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick-list { counter-reset: pick; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.pick-list .person { border-inline-start: 4px solid var(--brand); counter-increment: pick; }
.pick-list .person::before {
  content: counter(pick);
  font-weight: 700;
  color: var(--brand);
  min-width: 1.2em;
}
.person.is-picked { background: #fffafa; border-color: var(--brand-tint-line); }
.person-body { flex: 1 1 auto; min-width: 0; }
.person-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.person-unit { display: block; font-size: .85rem; color: var(--muted); }
.person form, .person .pill { flex: 0 0 auto; }
.btn-disabled, .btn-disabled:hover { background: #e9dfe0; border-color: #e9dfe0; color: #8c8183; cursor: not-allowed; }
.choice-list .person-name { display: block; }

body.has-sticky { padding-block-end: 76px; }
.sticky-bar {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  background: rgba(255, 255, 255, .97);
  border-block-start: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(35, 26, 28, .08);
  z-index: 10;
}
.sticky-inner {
  max-width: 760px;
  margin-inline: auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
}
.counter { flex: 0 0 auto; font-weight: 700; white-space: nowrap; }
.sticky-inner .btn { flex: 1 1 auto; width: auto; }

.choice-list { list-style: none; margin: 0 0 16px; padding: 0; }
.choice-list li {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--brand);
  border-radius: 10px;
  margin-block-end: 8px;
  background: #fff;
}
.stack { display: grid; gap: 10px; }

.done-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; font-size: 2rem; font-weight: 700;
}

/* ---------- footer ---------- */
.site-footer {
  text-align: center;
  padding: 24px 16px 28px;
  color: var(--muted);
  background: #fff;
  border-block-start: 1px solid var(--line);
}
.footer-msg { font-weight: 700; color: var(--brand-dark); font-size: 1rem; margin-block-end: 4px; }
.footer-sign { margin: 0; font-size: .9rem; }

/* ---------- admin ---------- */
.admin-nav { background: #fff; border-block-end: 1px solid var(--line); }
.admin-nav ul {
  list-style: none;
  margin: 0 auto;
  padding: 0 16px;
  max-width: 1100px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.admin-nav a {
  display: block;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--muted);
  border-block-end: 3px solid transparent;
  white-space: nowrap;
  font-weight: 700;
}
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.active { color: var(--brand); border-block-end-color: var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-block-end: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tile-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; }
.tile-value { font-size: 1.7rem; font-weight: 700; display: block; line-height: 1.2; margin-block: 4px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: .85rem; color: var(--muted); }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: #eee;
  color: #444;
  white-space: nowrap;
}
.pill-draft { background: #f1ecec; color: var(--muted); }
.pill-open, .pill-elected, .pill-voted, .pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-closed { background: #ece8f3; color: #4b3d84; }
.pill-locked, .pill-missing { background: var(--brand-tint); color: var(--err); }
.pill-tie { background: var(--warn-bg); color: var(--warn); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: start; padding: 9px 10px; border-block-end: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fbf8f8; }
td.mono, td.nowrap { white-space: nowrap; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }

hr { border: 0; border-block-start: 1px solid var(--line); margin-block: 18px; }
.grid-2 { display: grid; gap: 18px; }
.form-row { display: grid; gap: 12px; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.checklist li { padding-block: 4px; }
.checklist .ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.checklist .todo::before { content: "○ "; color: var(--brand); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions form { margin: 0; }
.search { display: flex; gap: 8px; margin-block-end: 12px; }
.search .btn { width: auto; }
code { font-family: var(--mono); background: #f5eeee; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.login-card { max-width: 420px; margin-inline: auto; margin-block-start: 24px; }

@media (min-width: 760px) {
  h1 { font-size: 1.9rem; }
  .brand-logo { width: 44px; height: 44px; }
  .brand-title { font-size: 1.15rem; }
  .brand-sub { font-size: .85rem; }
  .hero-inner { padding: 48px 16px 110px; }
  .hero-title { font-size: 2.6rem; }
  .hero-text { font-size: 1.08rem; }
  .hero-slim { height: 120px; }
  .hero + .container { margin-block-start: -84px; }
  .card { padding: 28px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr 1fr; }
  form.narrow .btn { width: auto; min-width: 200px; }
}

/* ---------- ballot search hint ---------- */
.search-tip {
  background: var(--brand-tint);
  border: 1px solid var(--brand-tint-line);
  border-inline-start: 4px solid var(--brand);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .92rem;
  color: var(--ink);
  margin-block-end: 12px;
}

/* ---------- candidates ---------- */
.cand-alt { display: block; font-size: .92rem; color: var(--muted); }
.top-gap { margin-block-start: 12px; }

/* ---------- admin: phases + clickable tiles ---------- */
.phases { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: phase; }
.phases li {
  counter-increment: phase;
  padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700;
  background: #f1ecec; color: var(--muted);
}
.phases li::before { content: counter(phase) ". "; }
.phases li.current { background: var(--brand); color: #fff; }
a.tile-link { text-decoration: none; color: inherit; display: block; }
a.tile-link:hover, a.tile-link.is-active { border-color: var(--brand); }
.pill-registration { background: #e8f0fb; color: #1d4f91; }
.pill-review { background: var(--warn-bg); color: var(--warn); }

/* ---------- vote receipt ---------- */
.receipt-box {
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  background: var(--brand-tint);
  padding: 16px;
  margin-block: 16px;
}
.receipt-title { font-weight: 700; margin-block-end: 6px; }
.receipt-code {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--brand-dark);
  margin-block-end: 8px;
  user-select: all;
}
input.receipt-input { font-family: var(--mono); font-size: 1.2rem; letter-spacing: .1em; text-transform: uppercase; }
.card-danger { border-color: var(--brand-tint-line); }
.card-danger h3 { margin-block-start: 6px; }

.help-contact { font-weight: 600; color: var(--ink); }
.help-contact a { font-weight: 700; white-space: nowrap; }
