:root {
  color-scheme: dark;
  --bg: #030712;
  --panel: #0f172a;
  --panel-strong: #020617;
  --panel-soft: #111827;
  --panel-border: #1e293b;
  --panel-border-soft: rgba(148, 163, 184, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --subtle: #64748b;
  --field: #020617;
  --field-border: #334155;
  --button: #020617;
  --button-border: #334155;
  --indigo: #6366f1;
  --indigo-deep: #4f46e5;
  --emerald: #10b981;
  --amber: #fbbf24;
  --rose: #fb7185;
  --table-row-bg: transparent;
  --table-row-hover: color-mix(in srgb, var(--indigo) 8%, transparent);
  --table-row-exported-bg: rgba(251, 191, 36, 0.1);
  --table-row-exported-hover: rgba(251, 191, 36, 0.14);
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root.light {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --panel-soft: #f1f5f9;
  --panel-border: #e2e8f0;
  --panel-border-soft: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --field: #f8fafc;
  --field-border: #e2e8f0;
  --button: #ffffff;
  --button-border: #e2e8f0;
  --table-row-bg: transparent;
  --table-row-hover: color-mix(in srgb, var(--indigo) 8%, transparent);
  --table-row-exported-bg: rgba(251, 191, 36, 0.1);
  --table-row-exported-hover: rgba(251, 191, 36, 0.14);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  transition: background-color 180ms ease, color 180ms ease;
}

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

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  overflow-x: hidden;
  padding: 24px;
}

.page-stack {
  width: 100%;
  max-width: 1536px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.panel,
.progress-panel {
  border: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--shadow);
}

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

.header-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
}

.header-toast {
  position: absolute;
  top: 26px;
  left: 50%;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  max-width: 260px;
  min-height: 38px;
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(6, 78, 59, 0.92);
  color: #a7f3d0;
  padding: 0 18px;
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.2);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.header-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.header-toast.is-error {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(127, 29, 29, 0.92);
  color: #fecdd3;
}

.header-toast.is-warning {
  border-color: rgba(251, 191, 36, 0.34);
  background: rgba(113, 63, 18, 0.92);
  color: #fde68a;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 2.4vw, 34px);
  line-height: 1.05;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats b {
  color: inherit;
  font-weight: 800;
}

.header-actions,
.toolbar-actions,
.toolbar-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions,
.toolbar-actions {
  flex-wrap: wrap;
}

.primary-button,
.action-button,
.ghost-button,
.danger-button,
.segment,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
  color: #fff;
  box-shadow: 0 14px 25px rgba(79, 70, 229, 0.28);
}

.primary-button:hover,
.ghost-button:hover:not(:disabled),
.danger-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ghost-button,
.danger-button {
  border: 1px solid var(--button-border);
  background: var(--button);
  color: var(--text);
  padding: 0 14px;
  box-shadow: 0 8px 16px rgba(2, 6, 23, 0.08);
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  white-space: nowrap;
}

.action-primary {
  background: #089f9b;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(8, 159, 155, 0.22);
}

.action-primary:hover:not(:disabled) {
  background: #0aa9a4;
}

.action-export {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.action-export:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #0f172a;
}

.action-button:disabled {
  opacity: 0.48;
}

.selection-count {
  display: none;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(99, 102, 241, 0.42);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  padding: 0 16px;
  font-weight: 900;
  white-space: nowrap;
}

.selection-count.is-visible {
  display: inline-flex;
}

.ghost-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--indigo) 75%, var(--button-border));
  color: #818cf8;
}

.danger-button {
  border-color: color-mix(in srgb, var(--rose) 45%, var(--button-border));
  color: var(--rose);
}

.danger-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--rose) 12%, var(--button));
}

.ghost-button:disabled,
.danger-button:disabled {
  opacity: 0.42;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 54px;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel-strong);
}

.segmented.compact {
  min-height: 48px;
  border-radius: 14px;
}

.segment-label {
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment {
  min-width: 82px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
}

.compact .segment {
  min-width: auto;
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}

.segment.is-active {
  background: linear-gradient(135deg, var(--indigo), var(--emerald));
  color: #fff;
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.24);
}

.compact .segment.is-active {
  background: var(--panel-soft);
  color: #a5b4fc;
  box-shadow: none;
}

.compact [data-theme="light"].is-active {
  color: var(--amber);
}

.toolbar-panel {
  padding: 18px;
}

.toolbar-top {
  align-items: stretch;
}

.field {
  min-height: 54px;
  border: 1px solid var(--field-border);
  border-radius: 16px;
  background: var(--field);
  color: var(--text);
  outline: 0;
}

.field:focus {
  border-color: color-mix(in srgb, var(--indigo) 78%, var(--field-border));
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.search-field {
  min-width: 0;
  flex: 1;
  padding: 0 18px;
}

.search-field::placeholder,
.import-textarea::placeholder {
  color: var(--subtle);
}

.select-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.select-field {
  height: 54px;
  min-width: 148px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0 42px 0 18px;
  line-height: 54px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  font-weight: 800;
}

.toolbar-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border-soft);
}

.export-type {
  margin-left: 4px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  height: 608px;
  overflow: auto;
}

.table-scroll::-webkit-scrollbar,
.import-textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-scroll::-webkit-scrollbar-thumb,
.import-textarea::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  background-clip: content-box;
}

.account-table {
  width: max-content;
  min-width: 100%;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 38px 170px 345px 56px 50px 66px 140px 140px 180px 108px;
  column-gap: 18px;
  align-items: center;
}

.table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 48px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-strong);
  color: var(--muted);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
}

.table-body {
  min-height: 560px;
  background: color-mix(in srgb, var(--panel) 96%, var(--panel-strong));
}

.empty-state,
.mobile-empty {
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
}

.mobile-empty {
  display: none;
  height: 360px;
}

.table-row {
  min-height: 64px;
  padding: 0 14px;
  border-bottom: 1px solid var(--panel-border-soft);
  background: var(--table-row-bg);
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  font-size: 13px;
  transition: background-color 160ms ease;
}

.table-head > span,
.table-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-head > span:nth-child(4),
.table-head > span:nth-child(5),
.table-head > span:nth-child(6),
.table-row > .cell-pill,
.table-row > .plan-pill,
.table-row > .loading-pill {
  justify-self: center;
}

.table-head > span:nth-child(10),
.table-row > .row-actions {
  justify-self: start;
}

.copy-cell {
  cursor: copy;
  border-radius: 8px;
}

.copy-cell:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.table-row.is-pending,
.table-row.is-normal,
.table-row.is-failed {
  background: var(--table-row-bg);
}

.table-row:hover,
.table-row.is-pending:hover,
.table-row.is-normal:hover,
.table-row.is-failed:hover {
  background: var(--table-row-hover);
}

.table-row.is-exported {
  background: var(--table-row-exported-bg);
}

.table-row.is-exported:hover {
  background: var(--table-row-exported-hover);
}

.check-cell {
  display: flex;
  align-items: center;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--indigo);
}

.cell-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  font-weight: 850;
}

.cell-pill.success {
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
}

.cell-pill.warning {
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
}

.cell-pill.danger {
  background: rgba(251, 113, 133, 0.14);
  color: #fecdd3;
}

.cell-pill.muted {
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
}

.loading-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 24px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
}

.cell-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(148, 163, 184, 0.28);
  border-top-color: #a7f3d0;
  border-radius: 999px;
  animation: cell-spin 760ms linear infinite;
}

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

.plan-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 900;
}

.plan-pill.free {
  background: rgba(14, 165, 233, 0.14);
  color: #bae6fd;
}

.plan-pill.plus {
  background: rgba(168, 85, 247, 0.16);
  color: #e9d5ff;
}

.plan-pill.muted {
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  min-width: 124px;
  overflow: visible !important;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--button-border);
  border-radius: 10px;
  background: var(--button);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.logs-panel {
  padding: 20px;
}

.logs-head,
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logs-head h2,
.progress-head h2 {
  font-size: 18px;
}

.log-list {
  min-height: 180px;
  margin-top: 16px;
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--muted);
  padding: 16px;
  font-weight: 700;
}

.log-line {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border-soft);
}

.is-hidden {
  display: none;
}

.progress-panel {
  border-radius: var(--radius-lg);
  background: #000;
  color: #fff;
  padding: 20px;
}

.progress-head {
  font-weight: 800;
}

.progress-head strong {
  font-size: 22px;
}

.muted {
  color: #64748b;
}

.success-count {
  color: #6ee7b7;
}

.progress-track {
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #1e293b;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #34d399);
  transition: width 200ms ease;
}

.import-dialog {
  width: min(620px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--text);
}

.import-dialog::backdrop {
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(8px);
}

.dialog-card {
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel);
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-card p {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.7;
}

.import-notice {
  display: none;
  margin-top: 12px;
  border: 1px solid rgba(99, 102, 241, 0.36);
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.1);
  color: #c7d2fe;
  padding: 10px 12px;
  font-weight: 800;
  line-height: 1.5;
}

.import-notice.is-visible {
  display: block;
}

.import-notice.is-warning {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
}

.import-notice.is-success {
  border-color: rgba(16, 185, 129, 0.42);
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 22px;
}

.import-textarea {
  width: 100%;
  margin-top: 16px;
  resize: vertical;
  border: 1px solid var(--field-border);
  border-radius: 16px;
  background: var(--field);
  color: var(--text);
  padding: 14px;
  outline: 0;
  line-height: 1.6;
}

.import-textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.export-dialog {
  width: min(430px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.export-dialog::backdrop {
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(8px);
}

.export-card {
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  padding: 20px;
}

.export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.export-head h2 {
  font-size: 22px;
  font-weight: 800;
}

.export-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.export-fields {
  display: grid;
  gap: 14px;
  padding: 18px 0 0;
}

.export-fields label {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}

.export-fields select {
  height: 42px;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  appearance: none;
  padding: 0 44px 0 16px;
  outline: 0;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.1);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 23px) 50%,
    calc(100% - 18px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
}

.export-cancel,
.export-confirm {
  min-width: 72px;
  height: 40px;
  border-radius: 12px;
  font-weight: 800;
}

.export-cancel {
  border: 1px solid var(--button-border);
  background: var(--button);
  color: var(--text);
}

.export-confirm {
  border: 0;
  background: #089f9b;
  color: #ffffff;
}

@media (max-width: 1180px) {
  .header-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .header-panel,
  .toolbar-panel,
  .progress-panel {
    padding: 16px;
  }

  .header-actions,
  .toolbar-actions,
  .toolbar-top {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .danger-button,
  .segmented,
  .select-label,
  .field,
  .export-type {
    width: 100%;
  }

  .segmented {
    justify-content: space-between;
  }

  .segment {
    flex: 1;
  }

  .select-label {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .table-scroll {
    display: none;
  }

  .mobile-empty {
    display: flex;
  }

  .progress-head,
  .logs-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
