:root {
  --crimson: #9e1b1e;
  --crimson-dark: #7a1114;
  --bg: #f6f3ec;
  --card: #ffffff;
  --border: #e6dfd3;
  --text: #221712;
  --muted: #6e5b50;
  --green: #1b7a37;
  --green-bg: #e7f6ec;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --gray-bg: #f1ede6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Auth Gate */
.auth-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #7a1114 0%, #b71c1c 48%, #e2a832 100%);
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: #fffdf8;
  border-radius: 20px;
  padding: 32px 26px;
  text-align: center;
  box-shadow: 0 24px 50px rgba(34, 10, 6, 0.3);
}

.auth-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(158, 27, 30, 0.1);
  color: var(--crimson);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.auth-card h1 {
  margin: 14px 0 6px;
  font-size: 1.5rem;
  color: var(--crimson-dark);
}

.auth-card p {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--muted);
}

#passcode-input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 1.3rem;
  letter-spacing: 0.3em;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}

#passcode-input:focus {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(158, 27, 30, 0.14);
}

.auth-error {
  color: #b71c1c;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.btn-primary {
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--crimson), #c62828);
  color: #fff;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-back {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.84rem;
  color: var(--muted);
  text-decoration: none;
}

.auth-back:hover {
  color: var(--crimson);
}

/* Topbar */
.topbar {
  background: linear-gradient(90deg, #7a1114, #a31b1f);
  color: #fff8ea;
  padding: 14px 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(80, 12, 12, 0.2);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-sub {
  font-size: 0.8rem;
  opacity: 0.86;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}

.live-pill.active {
  background: rgba(27, 122, 55, 0.9);
  border-color: rgba(255, 255, 255, 0.4);
}

.live-pill.active .live-dot {
  background: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.35);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-outline {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Conference Switcher */
.conference-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

@media (max-width: 560px) {
  .conference-switcher {
    grid-template-columns: 1fr;
  }
}

.conf-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.conf-tab:hover {
  border-color: rgba(158, 27, 30, 0.4);
}

.conf-tab.active {
  background: linear-gradient(135deg, var(--crimson-dark), var(--crimson));
  border-color: var(--crimson-dark);
  color: #fff9ec;
  box-shadow: 0 8px 20px rgba(158, 27, 30, 0.2);
}

.conf-title {
  font-weight: 700;
  font-size: 0.96rem;
  text-align: left;
}

.conf-count {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.conf-tab.active .conf-count {
  background: rgba(255, 255, 255, 0.2);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 4px 14px rgba(40, 20, 10, 0.04);
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-value {
  margin-top: 6px;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.stat-success .stat-value {
  color: var(--green);
}

.stat-pending .stat-value {
  color: var(--amber);
}

.stat-rate .stat-value {
  color: var(--crimson);
}

.stat-note {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.progress-track {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: #ede6da;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--crimson), #e09f24);
  transition: width 0.35s ease;
}

/* Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1040px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(40, 20, 10, 0.04);
  overflow: hidden;
}

.panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

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

#search-box {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.86rem;
  min-width: 220px;
  outline: none;
}

#search-box:focus {
  border-color: var(--crimson);
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #faf8f4;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--crimson);
  border-color: var(--crimson);
  color: #fff;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.delegate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.delegate-table th {
  text-align: left;
  padding: 11px 14px;
  background: #faf7f1;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.delegate-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0ebe2;
  vertical-align: middle;
}

.delegate-table tr:hover td {
  background: #fdfbf7;
}

.col-stt {
  width: 60px;
  text-align: center !important;
  font-weight: 700;
  color: var(--muted);
}

.name-cell {
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pos-cell {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.tag-both {
  background: rgba(158, 27, 30, 0.1);
  color: var(--crimson);
}

.tag-absent {
  background: var(--gray-bg);
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-checked {
  background: var(--green-bg);
  color: var(--green);
}

.status-pending {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-absent {
  background: var(--gray-bg);
  color: var(--muted);
}

.status-time {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.9;
}

.btn-action {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-checkin-proxy {
  background: var(--crimson);
  color: #fff;
}

.btn-undo {
  background: #fff;
  border-color: #d6ccc0;
  color: var(--muted);
}

.btn-undo:hover:not(:disabled) {
  border-color: #b71c1c;
  color: #b71c1c;
}

/* Recent Live Panel */
.last-sync {
  font-size: 0.75rem;
  color: var(--muted);
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 8px 14px 14px;
  max-height: 620px;
  overflow-y: auto;
}

.recent-item {
  padding: 10px 0;
  border-bottom: 1px dashed #ece5d8;
  animation: fadeSlide 0.3s ease;
}

.recent-item:last-child {
  border-bottom: none;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recent-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.recent-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.recent-time {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
}

.recent-pos {
  margin-top: 2px;
  font-size: 0.77rem;
  color: var(--muted);
  line-height: 1.35;
}

.recent-meta {
  margin-top: 4px;
  font-size: 0.71rem;
  color: #8b776b;
}

.empty-row {
  text-align: center;
  padding: 28px 14px;
  color: var(--muted);
}
