:root,
:root[data-theme="light"] {
  --bg: #eef1f6;
  --bg-accent: radial-gradient(1200px 500px at -5% -20%, rgba(112, 140, 255, 0.15), transparent 55%), radial-gradient(900px 400px at 95% -15%, rgba(84, 194, 255, 0.13), transparent 52%);
  --text: #1f2937;
  --text-strong: #111827;
  --muted: #6b7280;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-elevated: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 23, 42, 0.11);
  --border-strong: rgba(15, 23, 42, 0.18);
  --shadow-shell: 0 22px 60px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.12);
  --brand: #1573ff;
  --brand-strong: #0f5fd8;
  --danger: #d14343;
  --ring: rgba(21, 115, 255, 0.38);
  --radius-shell: 28px;
  --radius-card: 20px;
  --radius-control: 14px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 14px;
  --space-5: 18px;
  --space-6: 30px;
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-accent: radial-gradient(1300px 520px at -5% -30%, rgba(79, 122, 255, 0.28), transparent 54%), radial-gradient(950px 420px at 100% -20%, rgba(67, 177, 255, 0.2), transparent 52%);
  --text: #e5e7eb;
  --text-strong: #f9fafb;
  --muted: #9ca3af;
  --surface: rgba(20, 28, 44, 0.66);
  --surface-solid: #1a2437;
  --surface-elevated: rgba(26, 36, 55, 0.85);
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.36);
  --shadow-shell: 0 28px 70px rgba(2, 6, 23, 0.56);
  --shadow-soft: 0 12px 28px rgba(2, 6, 23, 0.45);
  --brand: #4a95ff;
  --brand-strong: #2f7eff;
  --danger: #ff7f7f;
  --ring: rgba(74, 149, 255, 0.44);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "SF Pro Display", "SF Pro Text", "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--bg-accent);
  pointer-events: none;
  z-index: -1;
}

#app {
  max-width: 1060px;
  margin: var(--space-5) auto;
  padding: 0 var(--space-3) var(--space-5);
}

.shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-shell);
  box-shadow: var(--shadow-shell);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: var(--space-5);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.05rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  font-weight: 650;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.utility-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 550;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon {
  width: 18px;
  height: 18px;
}

.card-grid {
  display: grid;
  gap: var(--space-3);
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  background: var(--surface-elevated);
}

.section-title {
  margin: 0 0 var(--space-3);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.section-title-inline {
  margin: 0;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

.row:last-child {
  margin-bottom: 0;
}

label {
  font-size: 0.9rem;
  color: var(--text);
}

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

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 9px 12px;
  background: var(--surface-solid);
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 580;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  border-color: var(--border-strong);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

button.primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: #fff;
  border-color: transparent;
}

button.danger {
  color: var(--danger);
  border-color: rgba(209, 67, 67, 0.45);
}

.file-picker-wrap {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: 22px;
  padding: var(--space-2);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.file-picker-wrap.drag-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--surface-solid);
}

.file-input-hidden {
  display: none;
}

.file-choose-button {
  width: 100%;
  min-height: 124px;
  border-radius: 20px;
  font-size: 1.2rem;
  font-weight: 640;
  letter-spacing: 0.01em;
}

.file-picked-name {
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.toggle-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.document-format-line {
  display: grid;
  grid-template-columns: max-content 1fr max-content 1fr max-content;
  align-items: center;
  width: 100%;
  gap: 0;
}

.document-inline-separator {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
  justify-self: center;
  margin: 0;
}

.document-pill-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--format-pill-gap);
}

.document-pill-group-format {
  justify-self: start;
  padding-right: 0;
}

.document-pill-group-lists {
  justify-self: center;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.document-pill-group-ai {
  justify-self: end;
  padding-left: 0;
}

.format-row {
  --format-pill-gap: 10px;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: calc(var(--format-pill-gap) * 2);
}

@media (max-width: 1400px) {
  .document-format-line {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .document-inline-separator {
    display: none;
  }
}

.toggle-pill {
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 560;
  line-height: 1;
}

.toggle-pill.is-on {
  border-color: transparent;
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: #fff;
}

.table-settings-title {
  margin: var(--space-1) 0 var(--space-2);
  font-size: 0.73rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.table-settings-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.advanced-columns {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.advanced-column {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-2);
  background: var(--surface-solid);
}

.option-label {
  font-size: 0.79rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.option-triplet {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: var(--space-2);
}

.option-duo {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: var(--space-2);
}

.date-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
}

.format-select {
  height: 42px;
  min-height: 42px;
  border-radius: var(--radius-control);
  -webkit-appearance: none;
  appearance: none;
}

.signin-note {
  margin: 0 0 var(--space-2);
}

.quota-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface-solid);
}

.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.status-row-subtle {
  margin-top: var(--space-2);
}

.muted {
  color: var(--muted);
  font-size: 0.89rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  z-index: 30;
}

.modal-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-shell);
  background: var(--surface-solid);
  padding: var(--space-5);
  width: min(680px, calc(100vw - 24px));
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-back {
  right: auto;
  left: 10px;
}

.modal-card h3 {
  margin: 0 0 var(--space-3);
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin: var(--space-3) 0 var(--space-1);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.login-card {
  max-width: 520px;
}

.provider-buttons {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.provider-btn {
  width: 100%;
  min-height: 44px;
}

.provider-btn-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.provider-logo {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: block;
}

.provider-logo-apple {
  width: 15px;
  height: 18px;
  flex: 0 0 15px;
}

.billing-card {
  padding-top: 44px;
}

.profile-kv {
  margin-top: var(--space-2);
  display: grid;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.profile-divider {
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.profile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.profile-key {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile-value {
  color: var(--text-strong);
  text-align: right;
}

pre {
  white-space: pre-wrap;
  margin: 0;
  color: var(--text);
}

@media (max-width: 900px) {
  #app {
    margin: var(--space-3) auto;
  }

  .shell {
    padding: var(--space-4);
    border-radius: 22px;
  }

  .header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .option-triplet,
  .option-duo,
  .table-settings-grid,
  .advanced-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #app {
    margin: 0;
    padding: 0;
  }

  .shell {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .file-choose-button {
    min-height: 106px;
  }
}
