:root {
  --primary: #0c58da;
  --primary-hover: #0a4ec2;
  --primary-light: #edf4fe;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --card-radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.form-box {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 32px 26px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.brand-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-header .header-logo {
  height: 38px;
  width: auto;
  display: block;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.btn-header-qr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-header-qr:hover {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(12, 88, 218, 0.12);
}

.lang-dropdown-box {
  display: inline-flex;
  align-items: center;
  position: relative;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 0 28px 0 11px;
  height: 38px;
  gap: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.lang-dropdown-box:hover,
.lang-dropdown-box:focus-within {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(12, 88, 218, 0.12);
}

.lang-icon {
  color: #64748b;
  flex-shrink: 0;
  pointer-events: none;
}

.lang-text {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.5px;
  line-height: 1;
  pointer-events: none;
}

.dropdown-chevron {
  position: absolute;
  right: 9px;
  pointer-events: none;
  color: #64748b;
  flex-shrink: 0;
}

.dropdown-overlay-select {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 88, 218, 0.12);
}

.phone-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.country-select-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  height: 48px;
  min-width: 124px;
  padding: 0 30px 0 12px;
  transition: all 0.2s ease;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

.country-select-box:hover,
.country-select-box:focus-within {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 88, 218, 0.12);
}

.country-display-text {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
  pointer-events: none;
}

.country-select-box .dropdown-chevron {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: #64748b;
}

.phone-digits-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.phone-digits-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 88, 218, 0.12);
}

.btn-submit {
  width: 100%;
  height: 52px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  box-shadow: 0 10px 25px -6px rgba(12, 88, 218, 0.45);
  transition: all 0.2s ease;
}

.btn-submit:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -6px rgba(12, 88, 218, 0.5);
}

.btn-submit:active {
  transform: translateY(0);
}

.loading-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
}

.spinner-ring {
  width: 56px;
  height: 56px;
  border: 3.5px solid rgba(12, 88, 218, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
  margin-bottom: 20px;
}

.loading-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.loading-bar-wrap {
  width: 180px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 14px;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.preview-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.socar-card {
  width: 100%;
  max-width: 380px;
  background-color: #0c58da;
  border-radius: var(--card-radius);
  padding: 24px 24px 20px 24px;
  color: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(12, 88, 218, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
}

.card-top-logo {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0;
}

.card-top-logo svg {
  height: 38px;
  width: auto;
  max-width: 100%;
  display: block;
}

.card-line {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 6px 0;
  width: 100%;
}

.card-name {
  font-size: 19px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.2px;
  line-height: 1.2;
  margin-bottom: 6px;
  word-break: break-word;
}

.card-info-table {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  font-size: 12px;
}

.info-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
}

.info-label {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 400;
  font-size: 12px;
}

.info-val {
  color: #ffffff;
  font-weight: 500;
  font-size: 12px;
  word-break: break-all;
}

.modal-qr-card {
  max-width: 300px;
  text-align: center;
}

.modal-qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
}

.mobile-popup-qr-box {
  width: 216px;
  height: 216px;
  background: #ffffff;
  border-radius: 20px;
  padding: 12px;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.mobile-popup-qr-box svg,
.mobile-popup-qr-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: 10px;
}

.mobile-popup-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
  text-align: center;
  padding: 0 6px;
}

.card-position-table {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  font-size: 12px;
  line-height: 1.35;
  align-items: start;
}

.pos-label {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 400;
  font-size: 12px;
}

.pos-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pos-title {
  font-weight: 600;
  color: #ffffff;
  font-size: 12.5px;
}

.pos-group {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11.5px;
}

.card-qr-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  height: auto;
  background: #ffffff;
  border-radius: 16px;
  padding: 8px;
  margin: 6px auto 3px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.card-qr-container svg, 
.card-qr-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: 8px;
}

.card-footer-text {
  margin-top: 5px;
  font-size: 9.5px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.68);
  text-align: left;
}

.actions-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.btn-action {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  font-size: 15.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-jpeg {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 8px 20px -4px rgba(15, 23, 42, 0.35);
}

.btn-jpeg:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

.btn-pwa {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 8px 20px -4px rgba(12, 88, 218, 0.4);
}

.btn-pwa:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-back {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn-back:hover {
  background: #f1f5f9;
  color: var(--text);
}

.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 400px;
  border-radius: 24px;
  padding: 24px 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.btn-close-modal {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #64748b;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.pwa-guide-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
}

.pwa-step-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 14px;
  width: 100%;
  box-sizing: border-box;
}

.pwa-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-step-info {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
  width: 100%;
}

.pwa-step-info strong {
  color: var(--primary);
  font-weight: 600;
}

.pwa-offline-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  color: #065f46;
  font-size: 12.5px;
  font-weight: 500;
  width: 100%;
  box-sizing: border-box;
}

.btn-card-share {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-card-share:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.06);
}

.btn-card-share:active {
  transform: scale(0.95);
}

html.is-app-mode {
  background: #000000 !important;
  background-color: #000000 !important;
  height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body.is-app-mode {
  background: #000000 !important;
  background-color: #000000 !important;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

body.is-app-mode .container {
  max-width: 380px;
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body.is-app-mode.has-card #step-form,
body.is-app-mode.has-card #step-loading,
body.is-app-mode.has-card .actions-box {
  display: none !important;
}

body.is-app-mode.has-card #step-preview {
  display: flex !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  align-items: center !important;
  justify-content: center !important;
}

body.is-app-mode .socar-card {
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9) !important;
  padding: 18px 20px 14px 20px;
  max-width: 380px;
}

body.is-app-mode .btn-card-share {
  display: flex !important;
}

@media all and (display-mode: standalone) {
  html {
    background: #000000 !important;
    background-color: #000000 !important;
    height: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
  }
  body {
    background: #000000 !important;
    background-color: #000000 !important;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }
  body .container {
    max-width: 380px;
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  body.has-card #step-form,
  body.has-card #step-loading,
  body.has-card .actions-box {
    display: none !important;
  }
  body.has-card #step-preview {
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .socar-card {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9) !important;
    padding: 18px 20px 14px 20px;
    max-width: 380px;
  }
  .btn-card-share {
    display: flex !important;
  }
}

