/* Shared finishing layer for the existing design system. */
/* Global design tokens live in tokens.css. */


html,
body {
  min-width: 0;
  max-width: 100%;
}

img,
video,
iframe,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-color: var(--color-primary);
  outline-offset: 2px;
}

.ds-btn {
  min-height: 44px;
  max-width: 100%;
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ds-card,
.ds-alert,
.auth-card-v2,
.auth-card-premium {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ds-card {
  border-radius: var(--radius-lg);
}

.ds-alert {
  align-items: flex-start;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ds-alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.ds-alert-error { background: var(--color-error-bg); color: var(--color-error); border-color: var(--color-error-border); }
.ds-alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.ds-alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }

.ui-feedback-icon {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-top: 0.05rem;
}

.ui-feedback-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ui-feedback-label { flex: 0 0 auto; font-weight: 800; }
.ui-feedback-copy { min-width: 0; overflow-wrap: anywhere; }

.ds-alert[data-feedback-kind="success"], .flash-msg[data-feedback-kind="success"] { color: var(--color-success); background: var(--color-success-bg); border: 1px solid var(--color-success-border); }
.ds-alert[data-feedback-kind="error"], .flash-msg[data-feedback-kind="error"] { color: var(--color-error); background: var(--color-error-bg); border: 1px solid var(--color-error-border); }
.ds-alert[data-feedback-kind="warning"], .flash-msg[data-feedback-kind="warning"] { color: var(--color-warning); background: var(--color-warning-bg); border: 1px solid var(--color-warning-border); }
.ds-alert[data-feedback-kind="info"], .flash-msg[data-feedback-kind="info"] { color: var(--color-info); background: var(--color-info-bg); border: 1px solid var(--color-info-border); }

.flash-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.alert {
  max-width: 100%;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.alert-success { color: var(--color-success); background: var(--color-success-bg); border-color: var(--color-success-border); }
.alert-error, .alert-danger { color: var(--color-error); background: var(--color-error-bg); border-color: var(--color-error-border); }
.alert-warning { color: var(--color-warning); background: var(--color-warning-bg); border-color: var(--color-warning-border); }
.alert-info { color: var(--color-info); background: var(--color-info-bg); border-color: var(--color-info-border); }

.empty-state,
.empty-row,
.rl-empty,
.ds-empty-state {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.empty-state:not(td),
.ds-empty-state {
  padding: var(--space-8);
  border: 1px dashed var(--color-border-dk);
  border-radius: var(--radius-sm);
  background: var(--color-bg-soft);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-row td {
  padding: var(--space-6);
  color: var(--color-text-muted);
  text-align: center;
  white-space: normal;
}

@media (max-width: 640px) {
  table { max-width: 100%; }
  .table-responsive { max-width: 100%; }
}

.auth-page-v2,
.auth-page-wrap {
  min-height: calc(100svh - 80px);
  padding: 1rem 0.75rem;
  background: var(--color-bg-soft);
  background-image: none;
}

.auth-page-wrap::before { content: none; }

.auth-card-v2,
.auth-card-premium {
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card-v2:hover,
.auth-card-premium:hover {
  box-shadow: var(--shadow-md);
}

.auth-card-header-v2,
.auth-card-premium-header {
  padding: 0.9rem 1.25rem;
  background: var(--brand-navy);
}

.auth-card-premium-header { border-bottom: 0; }

.auth-card-body-v2,
.auth-card-premium-body {
  padding: 1rem 1.25rem;
}

.auth-card-footer-v2,
.auth-card-premium-footer {
  padding: 1rem 1.5rem;
  margin-top: 0;
  border-top: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

.auth-card-premium-title-group h1 { color: #fff; }
.auth-card-premium-title-group p { color: #e2e8f0; }
.auth-card-header-v2 h1 { font-size: 1.35rem; }
.auth-card-body-v2 .auth-field { margin-bottom: 0.65rem; }
.auth-card-body-v2 .auth-input { min-height: 44px; padding: 0.65rem 0.85rem; font-size: 0.9rem; }
.auth-card-body-v2 .auth-pw-input { padding-right: 2.75rem; }
.auth-card-body-v2 .auth-field-hint { margin-top: 0.25rem; font-size: 0.74rem; }
.auth-card-body-v2 .auth-submit { min-height: 44px; padding: 0.7rem; font-size: 0.95rem; }
.auth-card-body-v2 .reg-role-pills { margin-bottom: 0.7rem; }
.auth-card-premium-body .form-group { margin-bottom: 0.9rem !important; }
.auth-card-premium-body input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; padding-top: 0.65rem !important; padding-bottom: 0.65rem !important; }

.auth-input,
.auth-page-wrap input:not([type="checkbox"]):not([type="radio"]),
.auth-page-wrap select,
.auth-page-wrap textarea {
  max-width: 100%;
}

.cf-turnstile {
  width: 100%;
  max-width: 100%;
}

.cf-turnstile iframe { max-width: 100% !important; }

.ui-password-field {
  position: relative;
  display: block;
  min-width: 0;
  max-width: 100%;
}

.ui-password-field > input {
  width: 100% !important;
  max-width: 100%;
  padding-right: 2.75rem !important;
}

.ui-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.ui-password-toggle:hover { background: var(--color-bg-muted); color: var(--color-primary); }
.ui-password-toggle svg { width: 18px; height: 18px; }

.ui-is-loading {
  cursor: wait !important;
  opacity: 0.78;
  pointer-events: none;
}

.ui-is-loading::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.55em;
  vertical-align: -0.12em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ui-spin 0.7s linear infinite;
}

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

@media (max-width: 520px) {
  .auth-page-v2,
  .auth-page-wrap {
    min-height: calc(100svh - 64px);
    padding: 0.75rem 0.5rem;
  }

  .auth-card-header-v2,
  .auth-card-premium-header,
  .auth-card-body-v2,
  .auth-card-premium-body {
    padding: 0.8rem 1rem;
  }

  .auth-card-footer-v2,
  .auth-card-premium-footer {
    padding: 0.7rem 1rem;
  }
}

@media (max-width: 768px) {
  .admin-table-card,
  .premium-table-wrap,
  .table-responsive,
  .table-wrap,
  .table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table-card table { min-width: 560px; }

  .ds-card,
  .stat-card,
  .admin-table-card,
  .auth-card-v2,
  .auth-card-premium,
  .modal-content,
  [role="dialog"] {
    min-width: 0;
    max-width: 100%;
  }

  .modal-dialog { width: auto; max-width: calc(100vw - 1rem); margin: 0.5rem auto; }
  .modal-content { max-height: calc(100svh - 1rem); overflow-y: auto; }
  input, select, textarea { min-width: 0; max-width: 100%; }
}

.wrap,
.ds-container,
.container,
.container-fluid,
.row,
[class^="col-"],
[class*=" col-"] {
  min-width: 0;
}

img,
video,
iframe {
  height: auto;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  max-width: 100%;
}

@media (max-width: 768px) {
  .wrap,
  .ds-container {
    padding-inline: 1rem;
  }

  .nav-inner {
    gap: 0.75rem;
    padding-inline: 1rem;
  }

  .mobile-bottom-nav {
    height: calc(70px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }

  body {
    padding-bottom: calc(75px + env(safe-area-inset-bottom)) !important;
  }

  .table-responsive,
  .admin-table-card,
  .premium-table-wrap,
  .table-wrap,
  .table-wrapper {
    width: 100%;
  }
}

.invoice-checkout-wrap {
  min-height: calc(100svh - 80px) !important;
  padding: 2rem 1rem !important;
}

.invoice-checkout-card {
  min-width: 0;
}

@media (max-width: 480px) {
  .wrap,
  .ds-container {
    padding-inline: 0.75rem;
  }

  .invoice-checkout-wrap {
    padding: 1rem 0.75rem !important;
  }

  .invoice-checkout-card > div:first-child,
  .invoice-checkout-card > div:nth-child(2) {
    padding: 1.25rem !important;
  }

  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-body,
  .modal-footer {
    padding-inline: 1rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
