:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-elevated: #0b1220;
  --surface: #101928;
  --surface-strong: #142033;
  --surface-soft: #0d1626;
  --surface-muted: #172235;
  --text: #f4f7fb;
  --text-soft: #c8d3e2;
  --muted: #728198;
  --border: #22314a;
  --border-strong: #2d4264;
  --primary: #3772ff;
  --primary-dark: #2456dc;
  --primary-light: #82a8ff;
  --primary-soft: rgba(55, 114, 255, 0.16);
  --success: #20d49b;
  --success-dark: #12936d;
  --success-soft: rgba(32, 212, 155, 0.14);
  --warning: #f6a51a;
  --warning-soft: rgba(246, 165, 26, 0.14);
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.13);
  --violet: #9b7cff;
  --violet-light: #bcaaff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-medium: 0 16px 48px rgba(0, 0, 0, 0.24);
  --shadow-strong: 0 32px 80px rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --content: 1280px;
  
  /* Modern gradients */
  --gradient-primary: linear-gradient(135deg, #3772ff 0%, #82a8ff 100%);
  --gradient-success: linear-gradient(135deg, #20d49b 0%, #16c98d 100%);
  --gradient-danger: linear-gradient(135deg, #ff5d73 0%, #ff9aaa 100%);
  --gradient-violet: linear-gradient(135deg, #9b7cff 0%, #bcaaff 100%);
  --gradient-surface: linear-gradient(135deg, rgba(18, 29, 46, 0.98) 0%, rgba(12, 20, 34, 0.95) 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(55, 114, 255, 0.15), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(155, 124, 255, 0.1), transparent 35%),
    radial-gradient(circle at 40% 80%, rgba(32, 212, 155, 0.08), transparent 30%),
    linear-gradient(135deg, #07101d 0%, #070b14 35%, #0a0f1a 70%, #090d16 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
  background-attachment: fixed;
}

a {
  color: inherit;
}

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

button {
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 11, 20, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-soft);
}

.topbar-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-grid;
  grid-template-columns: 46px minmax(0, auto);
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  font-weight: 850;
  font-size: 21px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand::before {
  content: "PA";
  grid-row: 1 / span 2;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2f6fff, #1849d8);
  box-shadow: 0 14px 30px rgba(38, 103, 255, 0.28);
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a,
.nav button,
.btn {
  min-height: 44px; /* Better touch target */
  border: 1px solid var(--border);
  background: rgba(16, 25, 40, 0.78);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 760;
  font-size: 14px;
  touch-action: manipulation; /* Improves touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Removes iOS tap highlight */
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav a:hover,
.nav button:hover,
.btn:hover {
  border-color: var(--border-strong);
  background: rgba(25, 38, 60, 0.92);
  color: var(--text);
}

.nav a.active,
.btn.primary {
  background: var(--gradient-primary);
  border-color: var(--primary-light);
  color: #fff;
  box-shadow: var(--shadow-medium);
  position: relative;
  overflow: hidden;
}

.btn.primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-glass);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn.primary:hover::before {
  opacity: 1;
}

.btn.primary:hover {
  box-shadow: var(--shadow-strong);
  transform: translateY(-1px);
  border-color: #fff;
}

.btn.danger {
  color: #ff9aaa;
}

.btn.success {
  background: var(--gradient-success);
  border-color: var(--success);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn.success:hover {
  box-shadow: var(--shadow-medium);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.page {
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
  min-width: 0;
}

/* Hero Section - More spacious and focused */
.hero-section {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 48px;
  padding: 32px 0;
  animation: fadeInUp 0.8s ease-out;
}

.hero-content {
  /* All content already styled with existing classes */
}

/* Account Section - Compact and less prominent */
.account-section {
  margin: 0 auto 48px;
  max-width: 600px;
  position: relative;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.account-section::after {
  content: '';
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 25, 40, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.account-info strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.account-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.limits-info {
  color: var(--muted);
  font-size: 14px;
}

.page.narrow {
  width: min(800px, calc(100% - 40px));
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  max-width: 760px;
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1.1; /* Better readability */
  font-weight: 900;
  letter-spacing: -0.02em; /* Tighter tracking for large text */
}

.page-subtitle {
  margin: 16px 0 0; /* More space from title */
  max-width: 650px;
  color: var(--text-soft); /* Slightly more prominent than muted */
  font-size: 18px; /* Bigger for better readability */
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  gap: 24px; /* More breathing room */
}

.grid > * {
  min-width: 0;
}

.grid.two {
  grid-template-columns: minmax(0, 0.85fr) minmax(380px, 1.05fr);
  align-items: start;
}

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

.grid.stats {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.card {
  background: var(--gradient-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px; /* More generous padding */
  transition: all 0.3s ease;
  position: relative;
  min-width: 0;
  max-width: 100%;
  backdrop-filter: blur(10px);
  animation: fadeInScale 0.6s ease-out;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--gradient-glass);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-strong);
  transform: translateY(-4px);
}

.card.compact {
  padding: 16px;
}

.card h2,
.card h3 {
  margin: 0 0 20px; /* More space after headings */
}

.card h2 + p {
  margin-bottom: 24px; /* More space after description */
}

.stat {
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.stat strong {
  display: block;
  margin-top: 12px;
  font-size: 38px;
  line-height: 1;
  color: var(--text);
}

.form-row {
  display: grid;
  gap: 12px; /* Bigger gap between label and input */
  margin-bottom: 24px; /* More space between form rows */
}

.form-row label {
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: -4px;
}

.input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f7f9fc;
  color: #111827;
  padding: 13px 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  font-size: 16px; /* Prevents zoom on iOS */
  min-height: 48px; /* Better touch target */
  transition: all 0.2s ease;
}

select {
  color: var(--text);
  background: var(--surface-soft);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(55, 114, 255, 0.16);
}

.upload-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: 
    linear-gradient(145deg, rgba(15, 25, 42, 0.8), rgba(20, 32, 51, 0.6)),
    var(--gradient-glass);
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  color: var(--text-soft);
  touch-action: manipulation;
  transition: all 0.4s ease;
  backdrop-filter: blur(8px);
}

.upload-box:hover {
  border-color: var(--primary);
  border-style: solid;
  background: 
    linear-gradient(145deg, rgba(55, 114, 255, 0.15), rgba(20, 32, 51, 0.8)),
    var(--gradient-glass);
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.upload-box::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(114, 129, 152, 0.45);
  border-radius: 14px;
  pointer-events: none;
}

.upload-box strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 18px;
}

.upload-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hidden {
  display: none !important;
}

.queue-list,
.activity-list,
.request-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.queue-item,
.activity-item,
.request-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  background: rgba(10, 17, 29, 0.62);
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.product-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(10, 17, 29, 0.72);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.product-editor-head {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  min-width: 0;
}

.product-editor-head > div,
.product-editor strong,
.product-editor .muted,
.activity-item,
.request-item {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.product-editor-head img,
.product-thumb {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: rgba(16, 25, 40, 0.8);
}

.product-thumb {
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.product-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  min-width: 0;
}

.preview-table {
  min-width: 980px;
}

.message-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.message-item {
  max-width: 82%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(10, 17, 29, 0.72);
  color: var(--text-soft);
  white-space: pre-wrap;
}

.message-item.own {
  justify-self: end;
  background: rgba(55, 114, 255, 0.14);
  border-color: rgba(55, 114, 255, 0.35);
  color: var(--text);
}

.message-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-message-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.5fr);
  gap: 24px;
  align-items: start;
}

.message-user-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.message-user-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(10, 17, 29, 0.72);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.message-user-option:hover,
.message-user-option.active {
  border-color: var(--primary);
  background: rgba(55, 114, 255, 0.12);
}

.message-user-option strong,
.message-user-option span {
  overflow-wrap: anywhere;
}

.message-user-details {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.message-unread-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef476f;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 760px) {
  .admin-message-layout {
    grid-template-columns: 1fr;
  }

  .message-user-list {
    max-height: 280px;
  }
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 900;
  background: rgba(114, 129, 152, 0.16);
  color: var(--text-soft);
  border: 1px solid rgba(114, 129, 152, 0.28);
}

.badge.trial {
  background: var(--gradient-success);
  color: #fff;
  border-color: var(--success);
  box-shadow: var(--shadow-soft);
}

.badge.standard {
  background: var(--gradient-primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.badge.super {
  background: var(--gradient-violet);
  color: #fff;
  border-color: var(--violet);
  box-shadow: var(--shadow-soft);
}

.badge.business {
  background: linear-gradient(135deg, #f6a51a 0%, #ffc76b 100%);
  color: #1a0f00;
  border-color: var(--warning);
  box-shadow: var(--shadow-soft);
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 13, 22, 0.72);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.settings-table {
  min-width: 0;
}

.settings-table th {
  width: 230px;
}

.settings-table td {
  white-space: pre-wrap;
  word-break: break-word;
}

th,
td {
  border-bottom: 1px solid rgba(34, 49, 74, 0.78);
  padding: 15px 16px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: rgba(14, 23, 38, 0.9);
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab-button {
  border: 1px solid var(--border);
  background: rgba(16, 25, 40, 0.72);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-weight: 850;
  cursor: pointer;
}

.tab-button.active {
  background: var(--primary-soft);
  border-color: rgba(55, 114, 255, 0.55);
  color: #b8ccff;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 0.9fr);
}

.auth-hero {
  padding: clamp(32px, 7vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(7, 19, 34, 0.94), rgba(6, 13, 23, 0.96)),
    radial-gradient(circle at 15% 12%, rgba(55, 114, 255, 0.22), transparent 32%);
}

.auth-hero-content {
  max-width: 620px;
}

.auth-hero h1 {
  margin: 56px 0 20px;
  font-size: clamp(44px, 7vw, 82px);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-hero h1 span {
  color: var(--primary);
}

.auth-hero p {
  max-width: 460px;
  color: var(--muted);
  font-size: 20px;
}

.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: 560px;
}

.auth-metrics strong {
  display: block;
  font-size: 34px;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(520px, 100%);
  box-shadow: none;
  background: transparent;
  border: 0;
}

.auth-card .brand {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 15, 0.72);
  backdrop-filter: blur(12px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  position: relative;
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(10, 17, 29, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  padding: 26px;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(16, 25, 40, 0.72);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.alert {
  display: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 760;
}

.alert.show {
  display: block;
}

.alert.error {
  background: var(--danger-soft);
  color: #ffb4bf;
  border: 1px solid rgba(255, 93, 115, 0.3);
}

.alert.success {
  background: var(--success-soft);
  color: #8ff0cf;
  border: 1px solid rgba(32, 212, 155, 0.28);
}

.plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(10, 17, 29, 0.62);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.plan-card.selected {
  border-color: rgba(55, 114, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(55, 114, 255, 0.14);
}

.shell-note {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: rgba(16, 25, 40, 0.56);
}

@media (max-width: 1100px) {
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .auth-hero h1 {
    margin-top: 34px;
  }

  .auth-panel {
    place-items: start;
  }
}

/* Tablet landscape */
@media (max-width: 680px) {
  .topbar-inner,
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .brand {
    white-space: normal;
  }

  .nav {
    justify-content: stretch;
    gap: 8px;
  }

  .nav a,
  .nav button {
    flex: 1 1 auto;
    text-align: center;
    padding: 12px 8px;
  }

  .page {
    width: min(100% - 24px, var(--content));
    padding-top: 22px;
  }

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

  .plans,
  .auth-metrics {
    grid-template-columns: 1fr;
  }

  .queue-item {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: clamp(28px, 5vw, 42px);
  }
}

/* Mobile landscape / Small tablets */
@media (max-width: 480px) {
  .hero-section {
    padding: 20px 0;
    margin-bottom: 32px;
  }

  .account-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 12px;
  }

  .account-status {
    justify-content: center;
  }
  .topbar-inner {
    padding: 12px 16px;
  }

  .brand {
    font-size: 18px;
    grid-template-columns: 36px minmax(0, auto);
    column-gap: 12px;
  }

  .nav {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a,
  .nav button {
    white-space: nowrap;
    min-width: max-content;
    padding: 10px 12px;
    font-size: 14px;
  }

  .page {
    width: min(100% - 16px, var(--content));
    padding-top: 16px;
  }

  .page-header {
    gap: 20px;
  }

  .page-title {
    font-size: clamp(24px, 6vw, 36px);
    line-height: 1.2;
  }

  .page-subtitle {
    font-size: 16px;
  }

  .card {
    padding: 16px;
  }

  .form-row {
    gap: 8px;
  }

  .input,
  .btn {
    padding: 14px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .btn {
    min-height: 48px; /* Better touch target */
  }

  .auth-card {
    padding: 24px 20px;
  }

  .auth-hero {
    padding: clamp(20px, 5vw, 40px);
  }

  .auth-hero h1 {
    font-size: clamp(32px, 8vw, 64px);
    margin: 32px 0 16px;
  }

  .auth-metrics strong {
    font-size: 28px;
  }
}

/* Mobile portrait */
@media (max-width: 360px) {
  .topbar-inner {
    padding: 10px 12px;
    gap: 12px;
  }

  .brand {
    font-size: 16px;
    grid-template-columns: 32px minmax(0, auto);
    column-gap: 10px;
  }

  .brand small {
    font-size: 11px;
  }

  .page {
    width: min(100% - 12px, var(--content));
    padding-top: 12px;
  }

  .page-header {
    gap: 16px;
  }

  .page-title {
    font-size: clamp(20px, 7vw, 32px);
  }

  .card {
    padding: 12px;
  }

  .input,
  .btn {
    padding: 12px 14px;
  }

  .auth-card {
    padding: 20px 16px;
  }

  .auth-hero {
    padding: clamp(16px, 4vw, 32px);
  }

  .grid.stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .modal {
    margin: 8px;
    max-height: calc(100vh - 16px);
  }
}

/* Loading States & Progress Indicators */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

.loading-spinner.large {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

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

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #82a8ff);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-indeterminate {
  position: relative;
  background: var(--surface);
}

.progress-indeterminate::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: progress-slide 2s ease-in-out infinite;
}

@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Loading overlay for cards */
.card-loading {
  position: relative;
  pointer-events: none;
}

.card-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(7, 11, 20, 0.8);
  border-radius: var(--radius);
  z-index: 10;
  backdrop-filter: blur(2px);
}

.card-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

/* Status messages with better styling */
.status-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

.status-message.loading {
  background: rgba(55, 114, 255, 0.1);
  border: 1px solid rgba(55, 114, 255, 0.3);
  color: var(--primary);
}

.status-message.success {
  background: rgba(32, 212, 155, 0.1);
  border: 1px solid rgba(32, 212, 155, 0.3);
  color: var(--success);
}

.status-message.error {
  background: rgba(255, 93, 115, 0.1);
  border: 1px solid rgba(255, 93, 115, 0.3);
  color: var(--danger);
}

/* Entrance animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.grid .card:nth-child(1) { animation-delay: 0.1s; }
.grid .card:nth-child(2) { animation-delay: 0.2s; }
.grid .card:nth-child(3) { animation-delay: 0.3s; }

/* Floating animation for accent elements */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.loading-spinner.large {
  animation: spin 1s linear infinite, float 3s ease-in-out infinite;
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
  /* This targets touch devices */
  .btn:hover,
  .nav a:hover,
  .nav button:hover {
    /* Remove hover effects on touch devices */
    border-color: var(--border);
    background: rgba(16, 25, 40, 0.78);
    color: var(--text-soft);
  }

  .btn:active,
  .nav a:active,
  .nav button:active {
    transform: scale(0.98);
    background: rgba(25, 38, 60, 0.92);
  }

  .upload-box:hover {
    border-color: var(--border-strong);
    background: linear-gradient(145deg, rgba(15, 25, 42, 0.95), rgba(20, 32, 51, 0.85));
  }

  .upload-box:active {
    transform: scale(0.995);
    border-color: var(--primary);
  }
}

/* Improved scrollable tables on mobile */
@media (max-width: 480px) {
  .table-wrap {
    border-radius: 8px;
  }

  table {
    min-width: 600px; /* Reduced for mobile */
  }

  th,
  td {
    padding: 8px 6px;
    font-size: 14px;
  }

  .message-item {
    max-width: 90%;
    font-size: 14px;
  }

  .badge {
    font-size: 11px;
    padding: 2px 8px;
  }
}
.prom-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-block: 12px;
}

#prom-import-status, #prom-connection-status {
  overflow-wrap: anywhere;
}

.prom-actions .input {
  width: 220px;
  max-width: 100%;
}
/* Bonus grants use a native modal with constrained mobile dimensions. */
.bonus-dialog { width: min(560px, calc(100% - 32px)); max-height: 85dvh; overflow: auto; padding: 24px; border: 1px solid #607080; border-radius: 8px; background: #182029; color: #f5f7fa; }
.bonus-dialog::backdrop { background: #0009; }
.bonus-dialog form { display: grid; gap: 12px; }
.bonus-dialog textarea { width: 100%; box-sizing: border-box; }
.bonus-dialog [data-bonus-history] { overflow-wrap: anywhere; }
.account-delete-dialog p { overflow-wrap: anywhere; }
.account-delete-confirm { display: flex; align-items: flex-start; gap: 10px; }
.account-delete-confirm input { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 3px; }
.account-delete-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.contact-footer {
  width: min(var(--content), calc(100% - 32px));
  margin: 16px auto 0;
  padding: 20px 0 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 14px;
}
.contact-footer-label { color: var(--text-soft); }
.contact-links { display: flex; flex-wrap: wrap; gap: 4px 20px; min-width: 0; }
.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 4px;
}
.contact-links a:hover { color: var(--success); }
.contact-links a:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 4px; }
.contact-links svg {
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.contact-links span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .contact-footer { align-items: flex-start; flex-direction: column; }
  .contact-links { width: 100%; gap: 4px 16px; }
}
/* Compact account navigation and bounded product queue. */
[role="tabpanel"][hidden] { display: none !important; }
.cabinet-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--border); }
.cabinet-tabs [role="tab"] { min-height: 48px; padding: 10px 8px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text, #edf2f7); font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.cabinet-tabs [aria-selected="true"] { border-bottom-color: #38d3a2; background: #38d3a215; }
.cabinet-tabs button:focus-visible, summary:focus-visible { outline: 2px solid #38d3a2; outline-offset: 2px; }
[role="tabpanel"] { min-width: 0; }
[role="tabpanel"] > .card, [role="tabpanel"] > .grid { margin-top: 0 !important; }
.grid.two.generator-workspace { align-items: stretch; }
.generator-queue { min-width: 0; }
.generator-queue .product-editor .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.generator-queue .queue-list { max-height: none; overflow: visible; }
.queue-export { margin-bottom: 12px; }
.other-products { min-width: 0; }
.other-products > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.other-products[open] > summary { margin-bottom: 8px; }
.product-editor > summary { cursor: pointer; grid-template-columns: 48px minmax(0, 1fr) 16px; margin-bottom: 0; }
.product-editor > summary::after { content: '\203A'; font-size: 24px; text-align: center; }
.product-editor[open] > summary::after { transform: rotate(90deg); }
.product-editor[open] > summary { margin-bottom: 16px; }
.product-editor > summary img, .product-editor > summary .product-thumb { width: 48px; height: 48px; border-radius: 6px; }
.product-editor > summary strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-editor > summary::-webkit-details-marker { display: none; }
.workspace-disclosure { margin-top: 18px; min-width: 0; }
.workspace-disclosure > summary { cursor: pointer; font-size: 18px; font-weight: 700; }
.workspace-disclosure[open] > summary { margin-bottom: 18px; }
#panel-messages .message-list { max-height: 50dvh; }
@media (max-width: 600px) {
  .cabinet-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-export > .btn { flex: 1 1 140px; min-width: 0; white-space: normal; }
  .generator-queue .product-editor .grid, .generator-queue .product-editor .grid.two { grid-template-columns: minmax(0, 1fr); }
}

/* Saved prompt settings become full-width rows on phones. */
@media (max-width: 768px) {
  #prompt-settings-summary,
  #prompt-settings-summary .table-wrap,
  #prompt-settings-summary .settings-table,
  #prompt-settings-summary .settings-table tbody,
  #prompt-settings-summary .settings-table tr {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  #prompt-settings-summary .table-wrap {
    overflow-x: hidden;
  }

  #prompt-settings-summary .settings-table,
  #prompt-settings-summary .settings-table tbody {
    display: block;
  }

  #prompt-settings-summary .settings-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    border-bottom: 1px solid rgba(34, 49, 74, 0.78);
  }

  #prompt-settings-summary .settings-table tr:last-child {
    border-bottom: 0;
  }

  #prompt-settings-summary .settings-table th,
  #prompt-settings-summary .settings-table td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    border-bottom: 0;
  }

  #prompt-settings-summary .settings-table th {
    padding: 13px 14px 4px;
    background: rgba(14, 23, 38, 0.72);
  }

  #prompt-settings-summary .settings-table td {
    padding: 5px 14px 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: normal;
    overflow-wrap: break-word;
  }
}
