:root {
  --teal: #006d77;
  --teal-dark: #00545b;
  --teal-darker: #003b40;
  --teal-soft: #e6f2f3;
  --gold: #b98a2f;
  --ink: #1b2b2d;
  --muted: #5f7375;
  --line: #d9e5e6;
  --bg: #f4f8f8;
  --white: #ffffff;
  --danger: #b3372e;
  --ok: #1d7a46;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 59, 64, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--white);
  border-bottom: 3px solid var(--teal);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 14px; }
.topbar .brand img { height: 44px; }
.topbar .brand .app-name {
  border-right: 2px solid var(--line);
  padding-right: 14px;
  margin-right: 2px;
}
.topbar .brand .app-name b { color: var(--teal-dark); font-size: 17px; display: block; line-height: 1.2; white-space: nowrap; }
.topbar .brand .app-name span { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar .brand img { height: 36px; }
  .topbar .brand .app-name b { font-size: 14px; white-space: normal; max-width: 180px; }
  .topbar .brand .app-name span { display: none; }
  .topbar nav a { padding: 7px 10px; font-size: 13.5px; }
}
.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a {
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 15px;
}
.topbar nav a:hover { background: var(--teal-soft); }
.topbar nav a.active { background: var(--teal); color: #fff; }

.container { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; }

h1.page-title { color: var(--teal-darker); font-size: 26px; margin-bottom: 4px; }
p.page-sub { color: var(--muted); margin-bottom: 24px; font-size: 15px; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

.stat { text-align: center; padding: 18px 10px; }
.stat .num { font-size: 34px; font-weight: 700; color: var(--teal); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-weight: 500; margin-bottom: 5px; color: var(--teal-darker); font-size: 14px; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--teal-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--teal-soft); color: var(--teal-dark); }
.btn.secondary:hover { background: #d5e9ea; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #92291f; }
.btn.ghost { background: transparent; color: var(--teal-dark); border: 1.5px solid var(--line); }
.btn.sm { padding: 6px 13px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { padding: 14px 30px; font-size: 17px; }

/* ---------- tables ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); font-size: 14.5px; }
table.list th { color: var(--muted); font-weight: 600; font-size: 13px; background: var(--teal-soft); }
table.list tr:hover td { background: #fafdfd; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.badge.active { background: #e2f4e9; color: var(--ok); }
.badge.ended { background: #eceff0; color: var(--muted); }
.badge.lang { background: var(--teal-soft); color: var(--teal-dark); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--teal-darker) 0%, var(--teal) 70%, #0b8894 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 42px 38px;
  width: 100%;
  max-width: 430px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.login-card img { max-width: 300px; width: 100%; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; color: var(--teal-darker); margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card input { text-align: center; letter-spacing: 6px; font-size: 20px; }

/* ---------- live session ---------- */
.live-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.live-head .meta { color: var(--muted); font-size: 14px; }
.live-head .meta b { color: var(--teal-darker); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 860px) { .panels { grid-template-columns: 1fr; } }

.panel {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel .head {
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.panel.judge .head { background: var(--teal-dark); }
.panel.party .head { background: var(--gold); }
.panel .head .who { font-weight: 700; font-size: 17px; }
.panel .head .lang { font-size: 13px; opacity: .9; }
.panel .body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 12px; }

.mic-btn {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  transition: background .15s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.panel.judge .mic-btn { background: var(--teal); }
.panel.judge .mic-btn:hover { background: var(--teal-dark); }
.panel.party .mic-btn { background: var(--gold); }
.panel.party .mic-btn:hover { background: #9a721f; }
.mic-btn.listening { background: var(--danger) !important; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(179,55,46,.45);} 50% { box-shadow: 0 0 0 12px rgba(179,55,46,0);} }

.interim {
  min-height: 52px;
  background: var(--teal-soft);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--teal-darker);
  font-size: 15px;
}
.interim.empty { color: var(--muted); font-style: italic; }

.manual-row { display: flex; gap: 8px; }
.manual-row input { flex: 1; }

/* transcript — newest statement shown on top; printed record stays chronological */
.transcript { display: flex; flex-direction: column-reverse; gap: 12px; }
@media print { .transcript { flex-direction: column; } }
.utt {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.utt .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.utt .top .who { font-weight: 700; }
.utt.judge { border-right: 4px solid var(--teal); }
.utt.judge .top .who { color: var(--teal-dark); }
.utt.party { border-right: 4px solid var(--gold); }
.utt.party .top .who { color: var(--gold); }
.utt .src { font-size: 15.5px; margin-bottom: 8px; }
.utt .dst {
  font-size: 15.5px;
  background: var(--teal-soft);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--teal-darker);
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
}
.utt .dst .play { flex-shrink: 0; background: none; border: none; cursor: pointer; font-size: 17px; color: var(--teal-dark); }
[dir="rtl"] .ltr-text { direction: ltr; text-align: left; }

.status-line { text-align: center; color: var(--muted); font-size: 13.5px; margin: 8px 0 16px; min-height: 20px; }
.status-line.err { color: var(--danger); font-weight: 600; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.empty-note { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 15px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 40, 44, .5);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h2 { color: var(--teal-darker); font-size: 20px; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 8px; }

/* print */
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
  .utt { break-inside: avoid; box-shadow: none; }
  .container { padding: 0; max-width: 100%; }
}
.print-head { display: none; }
@media print {
  .print-head { display: block; text-align: center; margin-bottom: 22px; border-bottom: 2px solid var(--teal); padding-bottom: 14px; }
  .print-head img { height: 52px; }
}
