:root {
  --navy-900: #0a1929;
  --navy-800: #112a44;
  --navy-700: #1a3a5c;
  --navy-50: #f4f8fc;
  --navy-100: #e6eef7;
  --cyan-500: #15c5e8;
  --cyan-600: #0fb0d1;
  --cyan-100: #d4f3fa;
  --blue-600: #1f6fb8;
  --text: #0f1f33;
  --muted: #64748b;
  --border: #d8e3ee;
  --danger: #d93636;
  --success: #18a957;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(15, 31, 51, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 31, 51, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 31, 51, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Heebo", "Rubik", "Assistant", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--navy-50);
  color: var(--text);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======= LAYOUT — FORM ======= */
.hero {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 55%, #1a4e7a 100%);
  color: #fff;
  padding: 48px 24px 96px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 30%, rgba(21, 197, 232, 0.18), transparent 55%),
              radial-gradient(circle at 20% 80%, rgba(21, 197, 232, 0.12), transparent 50%);
  pointer-events: none;
}

.hero-inner { position: relative; max-width: 760px; margin: 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-logo { width: 56px; height: 56px; }

.brand-text {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-text .accent { color: var(--cyan-500); }

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.5px;
}

.hero p {
  font-size: 17px;
  opacity: 0.88;
  margin: 0;
  line-height: 1.6;
}

.container {
  max-width: 880px;
  margin: -64px auto 64px;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

@media (max-width: 640px) {
  .hero { padding: 32px 16px 80px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 15px; }
  .container { padding: 0 12px; margin-top: -56px; }
  .card { padding: 24px 20px; }
}

/* ======= FORM ELEMENTS ======= */
.section { margin-bottom: 36px; }
.section:last-child { margin-bottom: 0; }

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--cyan-500), var(--blue-600));
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}

.section-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 22px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 640px) {
  .grid, .grid-3 { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label,
.field-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-800);
}

.field .req { color: var(--danger); margin-inline-start: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--cyan-500);
  box-shadow: 0 0 0 3px rgba(21, 197, 232, 0.18);
}

.textarea { resize: vertical; min-height: 110px; }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
  display: none;
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--danger);
}

.field.has-error .error-text { display: block; }

/* Yes / No segmented choice */
.choice-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--navy-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: border-color .15s, background .15s;
}

.choice-row.is-yes {
  background: #fff8ee;
  border-color: #f5c982;
}

.choice-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.choice-q { font-size: 15px; font-weight: 500; line-height: 1.45; flex: 1; }

.choice-yn { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 3px; }

.choice-yn button {
  border: 0;
  background: transparent;
  padding: 6px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.choice-yn button.active[data-val="yes"] { background: var(--warn); color: #fff; }
.choice-yn button.active[data-val="no"] { background: var(--success); color: #fff; }

.choice-detail {
  display: none;
  margin-top: 4px;
}
.choice-row.is-yes .choice-detail { display: block; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (max-width: 640px) { .checkbox-grid { grid-template-columns: 1fr; } }

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--navy-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  font-size: 14.5px;
  user-select: none;
}

.check-item:hover { border-color: var(--cyan-500); }

.check-item input { accent-color: var(--cyan-600); width: 18px; height: 18px; cursor: pointer; }
.check-item.is-checked { background: var(--cyan-100); border-color: var(--cyan-500); font-weight: 600; }

/* Signature pad */
.signature-wrap {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  position: relative;
}
.signature-wrap canvas {
  width: 100%;
  height: 180px;
  display: block;
  touch-action: none;
  border-radius: var(--radius-sm);
  cursor: crosshair;
}
.signature-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.signature-wrap.has-signature .signature-hint { display: none; }

.signature-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.linkbtn {
  background: transparent;
  border: 0;
  color: var(--blue-600);
  cursor: pointer;
  font: inherit;
  padding: 4px 8px;
}
.linkbtn:hover { text-decoration: underline; }

/* Submit button */
.submit-wrap { margin-top: 32px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--cyan-500), var(--blue-600));
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  box-shadow: var(--shadow-md);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--navy-800);
  box-shadow: none;
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--navy-50); }

.btn-danger { background: var(--danger); }

.note {
  margin-top: 22px;
  padding: 12px 16px;
  background: var(--navy-50);
  border-right: 4px solid var(--cyan-500);
  border-radius: var(--radius-sm);
  color: var(--navy-800);
  font-size: 13.5px;
  line-height: 1.5;
}

/* Success screen */
.success-screen {
  text-align: center;
  padding: 32px 8px;
}
.success-icon {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success), #0e8d48);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.success-icon svg { width: 48px; height: 48px; }
.success-screen h2 { margin: 0 0 8px; color: var(--navy-900); font-size: 26px; }
.success-screen p { color: var(--muted); font-size: 16px; margin: 0; }

/* ======= LOGIN PAGE ======= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand { display: flex; justify-content: center; margin-bottom: 24px; }
.login-card .brand-text { color: var(--navy-900); }
.login-card h1 { font-size: 22px; margin: 0 0 6px; text-align: center; color: var(--navy-900); }
.login-card p { color: var(--muted); margin: 0 0 24px; text-align: center; font-size: 14px; }
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fde8e8; color: #9b1c1c; border: 1px solid #f5c2c2; }

/* ======= DASHBOARD ======= */
.dash-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.dash-sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #fff;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dash-sidebar .brand-text { font-size: 20px; }
.dash-sidebar .brand-logo { width: 44px; height: 44px; }

.sidebar-stats {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 16px;
}
.stat-label { font-size: 12px; color: rgba(255,255,255,0.6); letter-spacing: 0.4px; text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 2px; }

.sidebar-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-actions .btn-ghost {
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.18);
  background: transparent;
}
.sidebar-actions .btn-ghost:hover { background: rgba(255,255,255,0.08); }

.dash-main { padding: 32px; min-width: 0; }

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.dash-header h1 { margin: 0; font-size: 26px; color: var(--navy-900); }

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.search-box input {
  width: 100%;
  padding: 10px 38px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  font-size: 14.5px;
}
.search-box svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--navy-50);
  border: 1.5px solid var(--border);
  color: var(--navy-800);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.copy-link-btn:hover { background: var(--navy-100); }

.dash-table-wrap {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dash-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.dash-table th, .dash-table td { padding: 14px 16px; text-align: right; border-bottom: 1px solid var(--border); }
.dash-table th { background: var(--navy-50); color: var(--navy-800); font-weight: 700; font-size: 13px; letter-spacing: 0.2px; text-transform: uppercase; }
.dash-table tbody tr { cursor: pointer; transition: background .12s; }
.dash-table tbody tr:hover { background: var(--navy-50); }
.dash-table tbody tr:last-child td { border-bottom: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-warn { background: #fff1d6; color: #92500a; }
.tag-ok { background: #dcf5e6; color: #0f7038; }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}

/* Detail drawer / modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 41, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  z-index: 100;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  background: #fff;
  width: min(720px, 100%);
  height: 100%;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-in .25s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.modal-head h2 { margin: 0; font-size: 20px; color: var(--navy-900); }
.modal-head .close {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.modal-head .close:hover { background: var(--navy-50); color: var(--navy-900); }

.modal-body { padding: 24px 28px 40px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
  margin-bottom: 24px;
}
@media (max-width: 600px) { .kv-grid { grid-template-columns: 1fr; } }

.kv-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.kv-value { font-size: 15px; color: var(--navy-900); font-weight: 500; margin-top: 2px; word-break: break-word; }

.modal-section { margin-top: 28px; }
.modal-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cyan-500);
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.answer-row:last-child { border-bottom: 0; }
.answer-q { font-size: 14.5px; color: var(--navy-800); }
.answer-detail { font-size: 13px; color: var(--muted); margin-top: 4px; }

.signature-display {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #fff;
}
.signature-display img { display: block; max-width: 100%; height: auto; }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-sidebar { flex-direction: row; align-items: center; padding: 16px 20px; gap: 16px; flex-wrap: wrap; }
  .sidebar-stats { padding: 8px 14px; }
  .sidebar-actions { margin-top: 0; flex-direction: row; }
  .dash-main { padding: 20px 16px; }
}

@media print {
  .modal-head .close, .modal-actions { display: none; }
  .modal-backdrop { position: static; background: #fff; }
  .modal-panel { box-shadow: none; height: auto; width: 100%; }
}
