:root {
  color-scheme: light;
  --bg: linear-gradient(135deg, #f7f9fb, #e5ebff 45%, #fdfdfd);
  --surface: rgba(255, 255, 255, 0.8);
  --fg: #0f172a;
  --muted: #5f6c80;
  --primary: #0070f3;
  --primary-dark: #0051c3;
  --card-bg: rgba(255, 255, 255, 0.75);
  --border: rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 30px 60px rgb(15 23 42 / 0.15);
  --shadow-soft: 0 10px 25px rgb(15 23 42 / 0.08);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  font-size: 16px;
  line-height: 1.5;
}

.app-shell {
  width: min(100%, 2400px);
  margin: 0 auto;
  padding: 3rem 1.5rem 8rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand-block {
  flex: 2;
}

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.25rem 0;
}

h1 {
  margin: 0 0 0.4rem 0;
  font-size: clamp(1.85rem, 3vw, 2.3rem);
  font-weight: 650;
}

h2 {
  font-size: 1.3rem;
  margin: 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.brand-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.csv-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

button.primary {
  background: linear-gradient(180deg, #4da4ff, #0f6fff);
  color: #fff;
  box-shadow: 0 10px 20px rgb(0 111 255 / 0.3);
}

button.primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 12px 24px rgb(0 81 195 / 0.35);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 8px rgb(15 23 42 / 0.08);
}

.ghost-button.small {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.ghost-button.tiny {
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
}

.card {
  background: var(--card-bg);
  border-radius: 1.25rem;
  padding: 2rem;
  box-shadow: var(--shadow-soft);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.card-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #fff, #d8e4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 10px 20px rgb(15 23 42 / 0.1);
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.main-content {
  min-height: 500px;
}

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
  gap: 2rem;
}

/* Wizard */
.wizard {
  background: var(--surface);
  border-radius: 1.5rem;
  box-shadow: var(--shadow-strong);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
}

.wizard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.wizard-progress {
  min-width: 200px;
  text-align: right;
  font-weight: 600;
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.wizard form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.captcha-code {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  font-weight: 600;
}

.field-group {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.9);
}

.group-tags-panel {
  border: 1px dashed var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.85);
  margin-top: 0.5rem;
}

.group-tags-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
}

.group-tags-summary {
  font-size: 0.85rem;
  color: var(--muted);
}

.group-tags-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.group-tag {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  background: rgba(15, 23, 42, 0.04);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.group-tag.active {
  background: rgba(0, 112, 243, 0.12);
  border-color: rgba(0, 112, 243, 0.4);
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(0, 112, 243, 0.15);
}

.field-group h3 {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
}

.field-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #d1d5db;
  transition: 0.2s;
  border-radius: 26px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ios-slider::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgb(15 23 42 / 0.25);
}

.ios-switch input:checked + .ios-slider {
  background: linear-gradient(180deg, #34d399, #10b981);
}

.ios-switch input:checked + .ios-slider::before {
  transform: translateX(20px);
}

.ios-switch input[data-state='neutral'] + .ios-slider {
  background: #e2e8f0;
}

.switch-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.wizard-summary {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* Consultation */
.consultation {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--surface);
  padding: 2rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem;
  border-radius: 1.2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.filter label {
  font-size: 0.9rem;
  color: var(--muted);
}

.filter input,
.filter select {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}

.dropdown {
  position: relative;
}

.dropdown button {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.65rem 0.85rem;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.dropdown .chevron {
  font-size: 1rem;
  color: var(--muted);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  max-height: 260px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dropdown.open .dropdown-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 20;
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.35rem;
  font-size: 0.92rem;
  cursor: pointer;
}

.dropdown-option input {
  appearance: none;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.2);
  position: relative;
  background: #fff;
  transition: all 0.2s ease;
}

.dropdown-option input:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 112, 243, 0.35);
}

.dropdown-option input:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.filter.toggle label {
  display: block;
  margin-bottom: 0.4rem;
}

.filter.toggle div {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.reset-filter {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
}

.device-buttons {
  display: flex;
  gap: 0.35rem;
}

.device-buttons .ghost-button.tiny.active {
  background: rgba(0, 112, 243, 0.12);
  color: var(--primary);
  border-color: rgba(0, 112, 243, 0.4);
}

.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.insight-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 1rem;
  padding: 1.25rem;
  border: 1px solid rgba(15, 23, 42, 0.06);
  color: var(--fg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.insight-card p {
  margin: 0.2rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.insight-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  pointer-events: none;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.5), transparent 60%);
}

.progress {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.25);
  margin-top: 0.8rem;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0f6fff, #4da4ff);
  transition: width 0.3s ease;
}

.report table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 1rem;
  overflow: hidden;
  min-width: 900px;
  table-layout: fixed;
}

.report thead {
  background: #f3f6fb;
}

.report th,
.report td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: top;
  position: relative;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}

.report tbody tr:hover {
  background: rgba(15, 23, 42, 0.04);
}

.report tbody tr {
  cursor: pointer;
}

.th-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  user-select: none;
}

.sort-indicator {
  font-size: 0.8rem;
  color: var(--muted);
}

.sort-indicator.asc::after {
  content: '▲';
}

.sort-indicator.desc::after {
  content: '▼';
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.col-resizer::after {
  content: '';
  position: absolute;
  inset: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.8rem;
  background: rgba(0, 112, 243, 0.15);
  color: var(--primary);
}

.group-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--fg);
  font-size: 0.8rem;
}


.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  box-shadow: var(--shadow-soft);
  background: rgba(255, 255, 255, 0.95);
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.app-footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.85rem 1.5rem;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 -8px 30px rgb(2 6 23 / 0.35);
  backdrop-filter: blur(10px);
  z-index: 50;
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  max-width: 70vw;
  width: calc(100% - 2rem);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 40px 80px rgb(15 23 42 / 0.25);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.modal-content th,
.modal-content td {
  text-align: left;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-content th {
  width: 40%;
  font-weight: 600;
  color: var(--muted);
}

.modal-content td {
  color: var(--fg);
}

.password-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-mask {
  font-family: "SFMono-Regular", "Menlo", monospace;
  letter-spacing: 0.15rem;
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .wizard-head {
    flex-direction: column;
  }
  button {
    width: 100%;
  }
  .wizard-nav {
    flex-direction: column;
  }
  .brand-actions,
  .header-actions {
    width: 100%;
  }
  .toolbar {
    grid-template-columns: 1fr;
  }
}
.access-check {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

.access-check .captcha-code {
  justify-content: center;
}

.access-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
