:root {
  --bg: #f5f7fb;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --panel: #ffffff;
  --warning: #b7791f;
  --success: #0f8a55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef5ff 0%, var(--bg) 42%);
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px 18px 42px;
}

.nav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.nav a {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary);
  background: #fff;
  text-decoration: none;
  font-weight: 700;
}

.view {
  min-height: calc(100vh - 70px);
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

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

.portal-view {
  display: grid;
  align-content: start;
}

.portal-header {
  margin-bottom: 28px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.role-card {
  display: grid;
  gap: 12px;
  min-height: 210px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

.role-card:hover {
  border-color: var(--primary);
}

.role-card strong {
  font-size: 24px;
}

.role-card span:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.role-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
}

.steps li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.steps li.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.panel,
.result,
.signup-card,
.state,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

.panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
}

.channel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.channel {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.channel.selected {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary,
.secondary {
  min-height: 46px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  border: 0;
  color: #fff;
  background: var(--primary);
}

.primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  color: var(--primary);
  background: #fff;
  text-decoration: none;
}

.result {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 20px;
  text-align: center;
}

.result img {
  width: 220px;
  height: 220px;
}

.footer-tip,
.muted,
.agreement {
  color: var(--muted);
}

.footer-tip {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13px;
}

.empty,
.state,
.signup-card {
  padding: 28px;
  text-align: center;
}

.empty-mark,
.state-icon {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 14px;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 800;
}

.empty-mark {
  color: var(--warning);
  background: #fff7e6;
}

.signup-card {
  max-width: 520px;
  margin: 42px auto 0;
}

.signup-card .primary {
  width: 100%;
  margin-top: 22px;
}

.agreement {
  margin: 28px 0 0;
  font-size: 13px;
}

.state {
  max-width: 520px;
  margin: 42px auto 0;
}

.state-icon.success {
  color: #fff;
  background: var(--success);
}

.state-icon.warn {
  color: #fff;
  background: var(--warning);
}

.state-icon.ended {
  color: #fff;
  background: #667085;
}

dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(17, 24, 39, 0.92);
}

.admin-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-login {
  display: grid;
  gap: 18px;
  max-width: 460px;
}

.employee-login {
  max-width: 520px;
  margin-bottom: 18px;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.staff-patients {
  margin-top: 18px;
}

.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-row h2 {
  margin-bottom: 6px;
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.tab {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.admin-form .actions {
  display: flex;
  gap: 12px;
  grid-column: 1 / -1;
}

.admin-form .actions button {
  flex: 1;
}

.admin-list {
  margin-top: 18px;
  padding: 20px;
}

.campaign-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.campaign-row:first-child {
  border-top: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.data-table th {
  color: #475467;
  background: #f8fafc;
  font-weight: 800;
  white-space: nowrap;
}

.data-table td {
  overflow-wrap: anywhere;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.feedback-code {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-top: 18px;
}

.feedback-code img {
  width: 220px;
  height: 220px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.qr-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-card img,
.qr-placeholder {
  width: 160px;
  height: 160px;
  justify-self: center;
}

.qr-card img {
  object-fit: contain;
}

.qr-card p {
  margin-bottom: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.qr-placeholder {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--warning);
  background: #fff7e6;
  font-size: 42px;
  font-weight: 800;
}

.error-text {
  color: #b42318;
  font-weight: 700;
}

.feedback-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px)) 1fr;
  gap: 12px;
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.stat-card strong {
  color: var(--primary);
  font-size: 28px;
}

.stat-card span,
.type-stats {
  color: var(--muted);
  font-size: 14px;
}

.type-stats p {
  margin: 0 0 6px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.badge.ended {
  background: #667085;
}

.badge.pending {
  color: #1f2937;
  background: #e5e7eb;
}

@media (max-width: 640px) {
  .shell {
    padding-top: 18px;
  }

  h1 {
    font-size: 23px;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .section-row {
    align-items: stretch;
    flex-direction: column;
  }

  .feedback-stats {
    grid-template-columns: 1fr;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }
}
