:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --soft: #ecfdf5;
  --green: #059669;
  --green-dark: #047857;
  --ink: #0f172a;
  --danger: #dc2626;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.kyc-shell {
  min-height: 100vh;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 18px 154px;
  background:
    linear-gradient(180deg, rgba(236, 253, 245, 0.9) 0%, rgba(248, 250, 252, 0) 220px),
    var(--bg);
}

.form-head span,
.field label,
.note-card b {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.35;
  text-transform: uppercase;
}

.step-card,
.form-card,
.note-card {
  margin: 14px auto 0;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.step-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr) 26px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 20px;
}

.step {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
}

.step span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.step b {
  max-width: 100%;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step.active {
  color: var(--green-dark);
}

.step.active span {
  background: var(--green);
  color: #fff;
}

.step-card i {
  height: 2px;
  border-radius: 999px;
  background: #dbe5ea;
}

.form-card {
  padding: 16px;
  border-radius: 22px;
}

.form-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-head h2 {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 1.2;
}

.form-head b {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 900;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.required label::after {
  margin-left: 4px;
  color: var(--danger);
  content: "*";
}

.input,
.select-trigger,
.custom-select-trigger {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  padding: 0 13px;
}

.input:focus,
.custom-select-trigger:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.select-trigger,
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.select-trigger span,
.custom-select-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-trigger i,
.custom-select-trigger i {
  flex: 0 0 auto;
  color: #94a3b8;
  font-style: normal;
}

.date-trigger .placeholder {
  color: #94a3b8;
}

.custom-select {
  position: relative;
  z-index: 1;
}

.custom-select.is-open {
  z-index: 30;
}

.custom-select-menu {
  position: absolute;
  right: 0;
  left: 0;
  top: calc(100% + 6px);
  display: none;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.14);
}

.custom-select.is-open .custom-select-menu {
  display: grid;
  gap: 4px;
}

.custom-select-menu button {
  width: 100%;
  min-height: 38px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 750;
  text-align: left;
}

.custom-select-menu button:hover,
.custom-select-menu button.is-active {
  background: var(--soft);
  color: var(--green-dark);
}

.custom-select.is-open .custom-select-trigger i {
  transform: rotate(180deg);
}

.upload-field {
  display: grid;
  gap: 8px;
}

.upload-box {
  display: grid;
  min-height: 94px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.upload-preview {
  display: none;
  width: 94px;
  height: 94px;
  object-fit: cover;
  border-radius: 14px;
}

.upload-field.has-image .upload-box {
  place-items: start;
  padding: 8px;
}

.upload-field.has-image .upload-preview {
  display: block;
}

.upload-field.has-image .upload-placeholder {
  display: none;
}

.loading-state,
.error-state {
  grid-column: 1 / -1;
  padding: 18px 12px;
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.error-state {
  color: var(--danger);
}

.note-card {
  padding: 13px 14px;
  border-radius: 18px;
}

.note-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.submit-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 20;
  display: grid;
  width: 100%;
  max-width: 960px;
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -18px 40px rgba(15, 23, 42, 0.08);
  transform: translateX(-50%);
}

.primary-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 950;
}

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

.primary-button:disabled {
  opacity: 0.6;
}

.sheet[hidden],
.toast[hidden] {
  display: none !important;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.sheet-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  max-height: 78vh;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  padding: 10px 18px calc(16px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: #fff;
  box-shadow: 0 -24px 48px rgba(15, 23, 42, 0.22);
}

.sheet-handle {
  width: 46px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #cbd5e1;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-head strong {
  font-size: 18px;
}

.sheet-head button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  font-size: 20px;
}

.sheet-search {
  width: 100%;
  height: 44px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  padding: 0 13px;
}

.date-panel {
  grid-template-rows: auto auto auto auto;
}

.date-select-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr) minmax(0, 0.72fr);
  gap: 10px;
}

.date-select-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.date-select-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.date-select-grid select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  appearance: none;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
}

.date-select-grid select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.date-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  margin-top: 16px;
}

.date-cancel,
.date-confirm {
  min-height: 48px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
}

.date-cancel {
  background: #e2e8f0;
  color: #334155;
}

.date-confirm {
  background: var(--ink);
  color: #fff;
}

.country-list {
  min-height: 0;
  overflow-y: auto;
}

.country-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.country-option span {
  min-width: 0;
}

.country-option strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-option small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.country-option b {
  color: var(--green-dark);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 60;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

@media (min-width: 768px) {
  .kyc-shell {
    padding-top: 24px;
  }

  .form-card {
    padding: 22px;
  }

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

  .note-card {
    padding: 16px 18px;
  }

  .sheet-panel {
    left: 50%;
    width: min(560px, calc(100vw - 48px));
    border-radius: 28px;
    transform: translateX(-50%);
  }
}

@media (max-width: 379px) {
  .kyc-shell {
    padding-right: 14px;
    padding-left: 14px;
  }
}
