*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="url"],
  select,
  textarea,
  .float-input,
  .form-control,
  .pay-input,
  .pay-phone-input {
    font-size: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .states-ticker { animation: none !important; }
  .scan-line     { animation: none !important; }
  .floating-card { animation: none !important; }
  html { scroll-behavior: auto !important; }
}

@media (max-width: 1024px) {
  .btn,
  button:not([role="switch"]),
  .nav-hamburger,
  .nav-dropdown-item,
  .sidebar-item,
  .income-tab,
  .dash-tab,
  .faq-question,
  .plan-cta,
  .pay-btn-primary,
  .pay-btn-secondary,
  .btn-auth-submit,
  .pay-copy-btn,
  .pay-txid-verify-btn {
    min-height: 44px;
  }

  .nav-hamburger {
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.navbar { position: sticky; }

@media (max-width: 1100px) {
  .nav-links { gap: 2px; }
  .nav-links a { padding: 7px 10px; font-size: 0.82rem; }
}

@media (max-width: 900px) {
  .nav-hamburger { display: flex !important; }
  .nav-links     { display: none !important; }
  .navbar        { padding: 12px 20px; }

  body.nav-mobile-open .nav-links {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 16px 16px;
    z-index: 99;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  body.nav-mobile-open .nav-links a {
    display: block;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
  }

  .nav-actions { gap: 6px; }

  .theme-toggle { width: 60px; height: 28px; }
  .toggle-thumb { width: 20px; height: 20px; }
}

@media (max-width: 480px) {
  .navbar { padding: 10px 14px; }
  .nav-brand span { display: none; }
  .btn-nav-login  { display: none !important; }
  .btn-nav-signup { padding: 8px 14px; font-size: 0.78rem; }

  .theme-toggle { width: 52px; height: 26px; }
  .toggle-thumb { width: 18px; height: 18px; top: 3px; }
  [data-theme="light"] .toggle-thumb { transform: translateX(24px); }
}

@media (max-width: 600px) {
  .toast-container {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }
  .toast,
  .toast-success,
  .toast-error,
  .toast-info,
  .toast-warning {
    min-width: unset !important;
    width: 100%;
    max-width: 100%;
    font-size: 0.82rem;
    padding: 12px 14px;
  }
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    width: 100%;
    padding: 1.5rem 1.25rem;
  }
  .modal-close {
    top: 0.875rem;
    right: 0.875rem;
  }
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-width: 768px) {
  th, td { white-space: nowrap; padding: 0.6rem 0.75rem; }
  .detail-row { flex-wrap: wrap; gap: 0.25rem; }
  .detail-value { word-break: break-all; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.admin-sidebar.open ~ .sidebar-overlay,
body.sidebar-open .sidebar-overlay {
  display: block;
}

@media (max-width: 768px) {
  .admin-main { margin-left: 0 !important; }
  .sidebar-toggle { display: block !important; }

  .admin-content { padding: 1rem 0.875rem 2rem; }
  .admin-topbar  { padding: 0 0.875rem; gap: 0.5rem; }

  .stats-grid   { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem; }
  .charts-row   { grid-template-columns: 1fr !important; }

  .income-period-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
  }

  .maintenance-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .stat-value { font-size: 1.6rem; }
  .admin-page-sub { display: none; }
  .admin-page-title { font-size: 1rem; }
  .maintenance-actions { grid-template-columns: 1fr; }

  .bar-chart { height: 120px; }
  .bar-label { font-size: 0.58rem; }
}

@media (max-width: 768px) {
  .dash-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: 4px;
  }
  .dash-tab { white-space: nowrap; flex-shrink: 0; }

  .dash-welcome {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .dash-welcome-right { margin-left: 0; }

  .lb-top3-grid { grid-template-columns: 1fr !important; }

  .analytics-grid { grid-template-columns: 1fr !important; }

  .form-row { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .dash-stats-6 { grid-template-columns: repeat(2, 1fr) !important; }
  .dash-tab { font-size: 0.78rem; padding: 0.5rem 0.75rem; }
}

@media (max-width: 360px) {
  .dash-stats-6 { grid-template-columns: 1fr !important; }
}

@media (max-width: 1100px) {
  .gen-layout { grid-template-columns: 1fr !important; }
  .gen-result-panel { position: static !important; }
}

@media (max-width: 1100px) {
  .states-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .generator-page { padding-top: 64px; }
}

@media (max-width: 900px) {
  .states-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 600px) {
  .gen-form-card .form-grid { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)) !important; gap: 0.55rem; }
  .gen-form-card { padding: 1rem; }
  .gen-form-card .form-label {
    min-height: 2.35em;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.3;
  }
  .gen-form-card .form-control {
    padding: 0.5rem 0.55rem;
    font-size: 16px !important;
  }
  .gen-form-card .input-wrapper .form-control {
    padding-left: 0.6rem;
    padding-right: 2rem;
  }
  .gen-form-card .input-action { right: 0.5rem; }
  .gen-form-card .form-hint { font-size: 0.64rem; }
  .gen-form-actions { flex-direction: column; }
  .gen-form-actions .btn { width: 100%; }
  .gen-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .gen-header-actions { width: 100%; }
  .gen-header-actions .btn { flex: 1; }
  .scanner-list, .scanners-list { grid-template-columns: 1fr !important; }
  .gen-form-card { padding: 1rem; }
  .barcode-result-card { padding: 1.25rem; }
  .states-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 400px) {
  .states-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .auth-page { padding: 4.5rem 1rem 2rem; }
  .auth-card { padding: 1.75rem 1.25rem; border-radius: 16px; }
  .auth-title { font-size: 1.35rem; }
  .float-input { height: 52px; }
  .btn-auth-submit { height: 50px; font-size: 0.95rem; }
  .otp-container { gap: 0.35rem; }
  .otp-input { width: 42px; height: 50px; font-size: 1.25rem; }
}

@media (max-width: 360px) {
  .auth-card { padding: 1.5rem 1rem; }
  .otp-input { width: 36px; height: 44px; font-size: 1.1rem; }
  .auth-steps { gap: 0.25rem; }
  .step-dot { width: 22px; height: 22px; font-size: 0.6rem; }
  .step-connector-line { max-width: 24px; }
}

@media (max-width: 1024px) {
  .hero-section .container {
    grid-template-columns: 1fr !important;
    text-align: center;
    gap: 2.5rem;
  }
  .hero-badge, .hero-actions, .hero-stats { justify-content: center; }
  .hero-subtitle { margin-left: auto; margin-right: auto; }
  .hero-visual { display: none; }
  .features-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {
  .features-grid { grid-template-columns: 1fr !important; }
  .steps-container { flex-direction: column; align-items: center; }
  .step-connector { width: 2px; height: 40px; }
}

@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .hero-section { padding: 1.5rem 0 1rem; min-height: auto; }
  .hero-title { font-size: clamp(2rem, 8vw, 2.8rem); }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-actions .btn-lg { width: 100%; max-width: 320px; justify-content: center; }
  .hero-stats { gap: 1.25rem; flex-wrap: wrap; justify-content: center; }
  .hero-stat-divider { display: none; }
  .cta-actions { flex-direction: column; align-items: center; }
  .cta-actions .btn { width: 100%; max-width: 320px; justify-content: center; }
  .cta-card { padding: 2.5rem 1.25rem; }
  .faq-question { padding: 1rem 1.25rem; font-size: 0.875rem; }
  .faq-answer p { padding: 0 1.25rem 1.25rem; }
  .footer-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 900px) {
  .pricing-grid { grid-template-columns: 1fr !important; max-width: 460px; margin-left: auto; margin-right: auto; }
  .pricing-card.featured { transform: none !important; order: -1; }
  .pricing-card.featured:hover { transform: translateY(-4px) !important; }
}

@media (max-width: 600px) {
  .pricing-hero { padding: 4.5rem 16px 2rem; }
  .billing-toggle-wrap { gap: 0.75rem; }
  .compare-table th, .compare-table td { padding: 10px 14px; font-size: 0.8rem; }
  .compare-table td:first-child, .compare-table th:first-child { min-width: 120px; }
}

@media (max-width: 480px) {
  .pricing-hero-title { font-size: clamp(1.8rem, 7vw, 2.5rem); }
  .pricing-grid { max-width: 100%; }
  .pricing-card { padding: 1.75rem; }
}

@media (max-width: 600px) {
  .payment-page-wrap { padding: 4.5rem 0.875rem 2rem; }
  .payment-container {
    border-radius: 18px;
    padding: 1.5rem 1.25rem;
  }
  .pay-meta-row { flex-direction: column; }
  .pay-meta-item { min-width: unset; width: 100%; }
  .pay-txid-input-row { flex-direction: column; }
  .pay-txid-verify-btn { width: 100%; }
}

@media (max-width: 400px) {
  .payment-container { border-radius: 16px; padding: 1.25rem 1rem; }
  .pay-header { flex-wrap: wrap; }
  .pay-qr-box { width: 148px; height: 148px; }
  .pay-qr-box img { width: 124px; height: 124px; }
}

@media (max-width: 480px) {
  .auth-steps { gap: 0.25rem; flex-wrap: wrap; justify-content: center; }
  .step-connector-line { max-width: 30px; }
}

@media (max-width: 640px) {
  .footer { padding: 40px 16px 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr !important; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; text-align: center; gap: 0.35rem; }
}

@media (max-width: 400px) {
  .footer-grid { grid-template-columns: 1fr !important; }
}

.income-period-tabs,
.dash-tabs,
.table-wrapper {
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-height: 500px) {
  .toast-container { bottom: 8px; }
  .gen-result-panel { position: static !important; }
}

.navbar,
.admin-sidebar,
.modal,
.toast,
.toast-success,
.toast-error,
.toast-info,
.toast-warning,
.nav-dropdown {
  will-change: auto;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

@media (update: slow) {
  .badge,
  .nav-plan-badge,
  .scan-line,
  .states-ticker,
  .floating-card {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-width: 1600px) {
  .container { max-width: 1480px; }
  .section { padding: 70px 32px; }
  .gen-layout { grid-template-columns: 1fr 500px; }
}

@media (min-width: 2000px) {
  .container { max-width: 1760px; }
  body { font-size: 17px; }
}

p, li, td, th, label, .detail-value, .activity-text {
  overflow-wrap: break-word;
  word-break: break-word;
}

* { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) { outline: none; }

@media (min-width: 769px) and (max-width: 1100px) {
  .gen-form-card .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)) !important;
  }
}


/* Generator forms: widen phone fields and let state-specific fields span cleanly. */
@media (max-width: 600px) {
  .gen-form-card .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 0.7rem;
  }

  .gen-form-card .form-group:has(#fDD),
  .gen-form-card .form-group:has(#fICN),
  .gen-form-card #coreFields > .form-group-full,
  .gen-form-card #stateExtraFields > .form-group-full {
    grid-column: 1 / -1 !important;
  }

  .generator-view .gen-form-card .form-label {
    min-height: 0;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
  }
}

/* State index layout: two balanced columns on desktop, one readable column on phones. */
.states-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
@media (max-width: 680px) {
  .states-grid { grid-template-columns: 1fr !important; }
}

/* Keep the state directory in two columns on every device, including phones. */
.states-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
@media (max-width: 680px) {
  .states-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .state-card-name { font-size: 0.82rem; }
  .state-card-number { width: 1.45rem; margin-right: 0.15rem; font-size: 0.62rem; }
  .state-card-header,
  .state-card:not(.expandable) { gap: 0.4rem; }
}
@media (max-width: 380px) {
  .state-card-name { font-size: 0.74rem; }
  .state-card-number { width: 1.25rem; margin-right: 0.1rem; font-size: 0.58rem; }
  .state-card-arrow { font-size: 0.95rem; }
}

/* Compact responsive rhythm for phones, tablets, laptops, and desktop screens. */
@media (max-width: 1024px) {
  .section { padding-top: 32px; padding-bottom: 32px; }
  .section-header { margin-bottom: 1.25rem; }
  .card { padding: 18px; }
}
@media (max-width: 768px) {
  .container, .container-sm { padding-left: 16px; padding-right: 16px; }
  .section { padding: 28px 16px; }
  .section-header { margin-bottom: 1rem; }
  .card { padding: 16px; }
  .footer { padding-top: 28px; padding-bottom: 18px; }
}
@media (max-width: 480px) {
  .section { padding-top: 24px; padding-bottom: 24px; }
  .card { padding: 14px; }
  .footer { padding-top: 24px; padding-bottom: 16px; }
}
