:root {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1e222c;
  --surface-3: #252b36;
  --field: #10141b;
  --field-2: #0c1016;
  --line: #2b3240;
  --line-strong: #465162;
  --text: #eef3f8;
  --muted: #9faaba;
  --muted-strong: #c3cad5;
  --blue: #70a7ff;
  --blue-dark: #4b85e8;
  --teal: #62d6bf;
  --amber: #f2c96f;
  --red: #ff765e;
  --red-dark: #ffab9a;
  --green-soft: #123129;
  --red-soft: #351c1a;
  --amber-soft: #342916;
  --blue-soft: #162842;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(112, 167, 255, 0.06), transparent 270px),
    linear-gradient(90deg, rgba(98, 214, 191, 0.035), transparent 38%, rgba(255, 118, 94, 0.025)),
    var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

::selection {
  background: rgba(112, 167, 255, 0.32);
  color: #ffffff;
}

* {
  scrollbar-color: #596579 #11151c;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #11151c;
}

::-webkit-scrollbar-thumb {
  background: #4a5668;
  border: 3px solid #11151c;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #647085;
}

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

button,
a.secondary-link {
  border-radius: 6px;
  min-height: 36px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  flex: 0 0 auto;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 470px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(112, 167, 255, 0.09), transparent 44%),
    var(--surface);
  box-shadow: var(--shadow), var(--shadow-soft);
  padding: 20px;
  animation: panelIn 360ms ease both;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(112, 167, 255, 0.42);
  border-radius: 8px;
  background: var(--blue-soft);
  color: #d8e8ff;
  font-weight: 900;
}

.auth-brand h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.05;
}

.auth-brand p,
.auth-setup p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auth-form input {
  margin-top: 6px;
}

.auth-submit {
  width: 100%;
  min-height: 42px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-setup {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(98, 214, 191, 0.28);
  border-radius: 8px;
  background: rgba(18, 49, 41, 0.54);
}

.auth-setup input {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
}

.auth-error {
  margin-bottom: 0;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  animation: pageIn 420ms ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
  color: #ffffff;
}

.topbar p,
.panel-heading p,
#outputPath {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.result-actions,
.payload-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-strong);
  font-size: 13px;
}

.status-pill.ok {
  border-color: rgba(98, 214, 191, 0.45);
  background: var(--green-soft);
  color: var(--teal);
}

.status-pill.waiting {
  border-color: rgba(242, 201, 111, 0.55);
  background: var(--amber-soft);
  color: var(--amber);
}

.token-bar {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 26, 33, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.token-bar label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cooldown-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: -2px 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(30, 34, 44, 0.98), rgba(18, 22, 30, 0.98));
  box-shadow: var(--shadow-soft);
}

.cooldown-banner.active {
  border-color: rgba(242, 201, 111, 0.55);
  background: linear-gradient(180deg, rgba(52, 41, 22, 0.76), rgba(23, 26, 33, 0.98));
}

.cooldown-banner.ready {
  border-color: rgba(98, 214, 191, 0.42);
  background: linear-gradient(180deg, rgba(18, 49, 41, 0.62), rgba(23, 26, 33, 0.96));
}

.cooldown-led {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(159, 170, 186, 0.08);
}

.cooldown-banner.active .cooldown-led {
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(242, 201, 111, 0.12), 0 0 22px rgba(242, 201, 111, 0.28);
}

.cooldown-banner.ready .cooldown-led {
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(98, 214, 191, 0.12), 0 0 22px rgba(98, 214, 191, 0.22);
}

.cooldown-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.cooldown-copy strong {
  color: #ffffff;
  font-size: 14px;
}

.cooldown-copy span {
  color: var(--muted);
  font-size: 13px;
}

.cooldown-clock {
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: #ffffff;
  text-align: center;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

input,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-soft);
}

input::placeholder,
textarea::placeholder {
  color: #737f90;
}

input {
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  background: var(--field-2);
  color: #dbe7f5;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(112, 167, 255, 0.16), var(--shadow-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.side-rail,
.main-area {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow), var(--shadow-soft);
  animation: panelIn 360ms ease both;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.panel:hover {
  border-color: #39465a;
  box-shadow: 0 22px 72px rgba(0, 0, 0, 0.42), var(--shadow-soft);
}

.operation-panel,
.payload-panel,
.work-panel,
.result-panel,
.log-panel {
  padding: 14px;
}

.panel-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tab-button,
.mini-tab {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.tab-button:hover,
.mini-tab:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
  transform: translateY(-1px);
}

.tab-button.active,
.mini-tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #d8e8ff;
}

.danger-tab.active {
  border-color: rgba(255, 118, 94, 0.55);
  background: var(--red-soft);
  color: var(--red-dark);
}

.mini-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.payload-panel textarea {
  min-height: 350px;
  max-height: 56vh;
}

.payload-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.field-error {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--red-dark);
  font-size: 12px;
}

.work-panel {
  display: none;
}

.work-panel.active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.compact-heading {
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.form-grid label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-grid input {
  margin-top: 6px;
}

.ids-box {
  min-height: 150px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--red-dark);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.safe-check {
  align-self: end;
  min-height: 38px;
  margin: 0;
  color: var(--muted-strong);
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary-button {
  background: var(--blue);
  color: #06111f;
  box-shadow: 0 10px 24px rgba(75, 133, 232, 0.24);
}

.primary-button:hover {
  background: var(--blue-dark);
  color: #ffffff;
  transform: translateY(-1px);
}

.danger-button {
  background: var(--red);
  color: #190806;
  box-shadow: 0 10px 24px rgba(255, 118, 94, 0.18);
}

.danger-button:hover {
  background: #ff5f45;
  color: #ffffff;
  transform: translateY(-1px);
}

.secondary-button,
.secondary-link {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.ghost-button,
.icon-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted-strong);
}

.secondary-button:hover,
.secondary-link:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--blue);
  background: var(--surface-3);
  color: #ffffff;
  transform: translateY(-1px);
}

.icon-button {
  width: 38px;
  padding: 8px;
}

button:disabled,
.disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stats-row div {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-2), #1a1f28);
  padding: 10px;
  box-shadow: var(--shadow-soft);
}

.stats-row span {
  display: block;
  font-size: 21px;
  font-weight: 900;
  color: #ffffff;
}

.stats-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rpa-sync-panel {
  padding: 14px;
}

.rpa-sync-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, auto);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.rpa-sync-grid label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rpa-sync-grid input[type="text"] {
  margin-top: 6px;
}

.rpa-sync-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.sync-metric {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151922;
  padding: 10px;
  box-shadow: var(--shadow-soft);
}

.sync-metric.good {
  border-color: rgba(98, 214, 191, 0.32);
  background: rgba(18, 49, 41, 0.62);
}

.sync-metric.warn {
  border-color: rgba(242, 201, 111, 0.36);
  background: rgba(52, 41, 22, 0.66);
}

.sync-metric.muted {
  grid-column: 1 / -1;
}

.sync-metric span {
  display: block;
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.sync-metric small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rpa-sync-details {
  min-height: 96px;
  max-height: 230px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b10;
  color: #d6deea;
  padding: 10px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.table-wrap {
  min-width: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1360px;
  background: var(--field);
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a202a;
  color: var(--muted-strong);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  color: #d8e1ed;
}

.result-row {
  animation: rowIn 180ms ease both;
}

.result-row:hover td {
  background: rgba(112, 167, 255, 0.055);
}

.result-row.deleted td {
  background: rgba(98, 214, 191, 0.035);
}

.result-row.created td {
  background: rgba(112, 167, 255, 0.035);
}

.result-row.created.revealed td {
  background: rgba(112, 167, 255, 0.05);
}

.result-row.deleted.deleted td {
  background: rgba(98, 214, 191, 0.06);
}

.result-row.error td {
  background: rgba(255, 118, 94, 0.035);
}

.empty-row td {
  color: var(--muted);
  font-family: inherit;
  text-align: center;
}

.state {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  padding: 4px 7px;
  border-radius: 999px;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  font-weight: 800;
}

.state.created {
  background: var(--blue-soft);
  color: #b9d7ff;
}

.state.listed {
  background: var(--amber-soft);
  color: var(--amber);
}

.state.revealed {
  background: var(--green-soft);
  color: var(--teal);
}

.state.deleted {
  background: #242b35;
  color: #c9d3df;
}

.state.error {
  background: var(--red-soft);
  color: var(--red-dark);
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-width: 72px;
  justify-content: center;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.type-pill.deleted {
  border-color: rgba(98, 214, 191, 0.45);
  background: var(--green-soft);
  color: var(--teal);
}

.type-pill.created {
  border-color: rgba(112, 167, 255, 0.5);
  background: var(--blue-soft);
  color: #b9d7ff;
}

.type-pill.old {
  border-color: rgba(242, 201, 111, 0.5);
  background: var(--amber-soft);
  color: var(--amber);
}

.log-list {
  min-height: 90px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b10;
  color: #d6deea;
  padding: 10px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
}

.log-item {
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.log-item.error {
  color: #fecaca;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 10;
}

.toast {
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  animation: toastIn 180ms ease both;
}

.toast.error {
  border-color: rgba(255, 118, 94, 0.55);
  background: var(--red-soft);
  color: var(--red-dark);
}

.hidden {
  display: none !important;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rowIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .payload-panel textarea {
    min-height: 230px;
    max-height: none;
  }
}

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

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .token-bar {
    grid-template-columns: 1fr auto;
  }

  .token-bar label,
  .token-bar input {
    grid-column: 1 / -1;
  }

  .cooldown-banner {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .cooldown-clock {
    grid-column: 1 / -1;
    width: 100%;
  }

  .form-grid,
  .stats-row,
  .rpa-sync-grid,
  .rpa-sync-summary {
    grid-template-columns: 1fr;
  }

  .tab-list {
    grid-template-columns: 1fr;
  }
}
