:root {
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #f0fdfa;
  --accent: #d97706;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-hosp {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.login-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
}

.login-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-input {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  text-align: center;
}

.login-input:focus {
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  border-radius: 10px;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #ffffff;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand-titles h1 {
  font-size: 20px;
  font-weight: 700;
}

.brand-titles p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Stats Bar */
.stats-bar {
  max-width: 1360px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  margin: 4px 0;
}

.stat-desc {
  font-size: 12px;
  color: #64748b;
}

/* Main Workspace */
.main-container {
  max-width: 1360px;
  margin: 20px auto 48px;
  padding: 0 24px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: #e2e8f0;
  padding: 6px;
  border-radius: 12px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.nav-tab {
  flex: 1;
  min-width: 170px;
  padding: 11px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 19px;
  font-weight: 700;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.search-box input {
  width: 260px;
  padding: 9px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
}

.form-select {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #0284c7;
  color: #fff;
}

.btn-secondary:hover {
  background: #0369a1;
}

.btn-accent {
  background: #f59e0b;
  color: #0f172a;
}

.btn-accent:hover {
  background: #d97706;
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: #f1f5f9;
}

.btn-danger-ghost {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-danger-ghost:hover {
  background: #fee2e2;
}

/* Tables */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.text-right {
  text-align: right !important;
}

.empty-cell {
  text-align: center !important;
  color: var(--text-muted);
  padding: 36px 16px !important;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.badge-muted {
  background: #f1f5f9;
  color: #64748b;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.tp-progress-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.tp-chip.done {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
  cursor: pointer;
}

.tp-chip.done:hover {
  background: #dcfce7;
}

.tp-chip.retake {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
  cursor: pointer;
}

.tp-chip.pending {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}

/* Forms Grid */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 18px;
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.form-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.form-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.form-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
}

.form-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-lg {
  max-width: 860px;
}

.modal-xl {
  max-width: 1080px;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Forms inside Modal */
.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.req {
  color: var(--danger);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.checkbox-label {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
}

/* Visual Form Editor */
.editor-meta-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.timepoint-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.tp-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

. editor-sections-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.editor-sections-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.editor-section-box {
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  margin-bottom: 18px;
  background: #fff;
  overflow: hidden;
}

.editor-section-top {
  background: #f1f5f9;
  padding: 12px 16px;
  border-bottom: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-questions-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-question-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  background: #fcfcfd;
}

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

.editor-opt-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 5px 8px;
  border-radius: 6px;
}

.editor-opt-chip input {
  padding: 4px 6px !important;
  font-size: 12px !important;
}

/* QR Code Poster */
.qr-poster {
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
  border: 2px solid #0f766e;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
}

.qr-poster-hosp {
  font-size: 14px;
  font-weight: 700;
  color: #0f766e;
}

.qr-poster-title {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 16px;
  color: #0f172a;
}

.qr-svg-box {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.qr-steps-hint {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.qr-url-box {
  margin-top: 12px;
  font-family: monospace;
  font-size: 13px;
  color: #475569;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 6px;
  word-break: break-all;
}

/* Simulator Modal */
.simulator-dialog {
  max-width: 440px;
  height: 86vh;
}

.simulator-frame-wrap {
  flex: 1;
  background: #0f172a;
  padding: 10px;
  display: flex;
}

.simulator-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  background: #fff;
}

/* Submission Score Summary Box */
.sub-score-banner {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.sub-answers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.sub-answers-table th,
.sub-answers-table td {
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
}

.sub-answers-table th {
  background: #f8fafc;
}
