:root {
  --bg: #e8eef5;
  --panel: #ffffff;
  --panel-soft: #f4f7fa;
  --panel-deep: #eef2f7;
  --border: #d0dae6;
  --border-strong: #a8bad0;
  --border-subtle: rgba(170, 185, 202, 0.45);
  --text: #0f1c2e;
  --text-secondary: #3a4f66;
  --muted: #5e7590;
  --accent: #0d7a73;
  --accent-strong: #095f59;
  --accent-soft: rgba(13, 122, 115, 0.11);
  --accent-subtle: rgba(13, 122, 115, 0.06);
  --danger: #b83c3c;
  --danger-soft: rgba(184, 60, 60, 0.1);
  --warning: #a5600f;
  --warning-soft: rgba(165, 96, 15, 0.1);
  --success: #127a46;
  --success-soft: rgba(18, 122, 70, 0.1);
  --shadow-xs: 0 1px 3px rgba(15, 28, 46, 0.06);
  --shadow-sm: 0 4px 12px rgba(15, 28, 46, 0.07);
  --shadow: 0 8px 28px rgba(15, 28, 46, 0.09);
  --shadow-lg: 0 16px 48px rgba(15, 28, 46, 0.12);
  --shadow-xl: 0 24px 72px rgba(15, 28, 46, 0.16);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --input-height: 44px;
  --input-height-sm: 36px;
  --font-ui: "IBM Plex Sans", sans-serif;
  --font-stage: "IBM Plex Sans Condensed", sans-serif;
  --font-heading: "Montserrat", sans-serif;
  --transition-fast: 0.12s ease;
  --transition: 0.18s ease;
  --transition-slow: 0.28s ease;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top left, rgba(13, 122, 115, 0.12), transparent 38%),
    radial-gradient(ellipse at bottom right, rgba(185, 108, 36, 0.10), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.hidden {
  display: none !important;
}

/* ── Layout shells ─────────────────────────────────────── */

.app-shell {
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px;
}

.landing-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-stack {
  display: grid;
  gap: 16px;
}

/* ── Topbar ─────────────────────────────────────────────── */

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

.topbar h1,
.panel h2,
.panel h3 {
  margin: 0;
}

.topbar h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}

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

/* ── Labels & eyebrow ───────────────────────────────────── */

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 700;
}

/* ── Panel ──────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 20px;
}

.panel--deep {
  background: var(--panel-deep);
  box-shadow: var(--shadow-sm);
}

/* ── Buttons ────────────────────────────────────────────── */

.button {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 18px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    transform var(--transition-fast),
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition-fast),
    color var(--transition);
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.button.sm {
  min-height: 34px;
  padding: 0 13px;
  font-size: 0.82rem;
  gap: 5px;
}

.button.sm svg {
  width: 14px;
  height: 14px;
}

.button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 122, 115, 0.28);
}

.button.primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 6px 18px rgba(13, 122, 115, 0.36);
}

.button.secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(13, 122, 115, 0.2);
}

.button.secondary:hover {
  background: rgba(13, 122, 115, 0.16);
  border-color: rgba(13, 122, 115, 0.32);
}

.button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.button.ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--panel-soft);
}

.button.danger-outline {
  color: var(--danger);
  border-color: rgba(184, 60, 60, 0.32);
  background: var(--danger-soft);
}

.button.danger-outline:hover {
  background: rgba(184, 60, 60, 0.16);
  border-color: rgba(184, 60, 60, 0.5);
}

.button.full-width {
  width: 100%;
}

/* Icon-only button */
.button.icon-only {
  min-width: 38px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.button.icon-only.sm {
  min-width: 32px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: var(--radius-xs);
}

/* ── Fields ─────────────────────────────────────────────── */

.field {
  display: grid;
  gap: 6px;
}

.field-label,
.status-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.input {
  min-height: var(--input-height);
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 13px;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  font-size: 0.9rem;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 122, 115, 0.1);
}

.input.sm {
  min-height: var(--input-height-sm);
  padding: 7px 10px;
  font-size: 0.84rem;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235e7590' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-row.stretch-actions > * {
  flex: 1 1 160px;
}

/* ── Section headers ────────────────────────────────────── */

.section-title-row,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

/* ── Typography helpers ─────────────────────────────────── */

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ── Badge ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.neutral {
  background: #e9eef5;
  color: #3a4f66;
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── Empty states ───────────────────────────────────────── */

.empty-state,
.empty-inline {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--muted);
  padding: 22px 20px;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
}

.empty-state h2 {
  margin: 0 0 6px;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ── Toast ──────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  background: rgba(15, 28, 46, 0.94);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  animation: toast-in 0.22s cubic-bezier(0.34, 1.36, 0.64, 1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.success { background: rgba(18, 110, 70, 0.94); }
.toast.error   { background: rgba(155, 44, 44, 0.94); }
.toast.warning { background: rgba(140, 84, 18, 0.94); }

/* ── Status strip ───────────────────────────────────────── */

.status-strip {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
}

/* ── Toolbar row ────────────────────────────────────────── */

.page-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1 1 300px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── Stats ──────────────────────────────────────────────── */

.stats-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stat-box {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
  display: grid;
  gap: 5px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-box strong {
  font-size: 1.7rem;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text);
  line-height: 1;
}

/* ── Landing ────────────────────────────────────────────── */

.hero-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 300px;
}

.landing-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr);
  align-items: stretch;
  flex: 1;
}

.hero-card h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 2.4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.flow-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.flow-list li strong {
  color: var(--text);
}

/* ── Composition (viewer shared) ────────────────────────── */

.composition-stage {
  position: relative;
  transform-origin: top left;
  overflow: hidden;
}

.composition-layer {
  position: absolute;
  inset: auto;
  user-select: none;
  transform-origin: center center;
}

.composition-layer[data-hidden="true"] {
  display: none;
}

.composition-layer__inner {
  width: 100%;
  height: 100%;
}

.composition-layer__text {
  width: 100%;
  height: 100%;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.composition-layer__image {
  width: 100%;
  height: 100%;
  display: block;
}

.composition-layer[data-overflow="true"] {
  outline: 2px solid rgba(184, 60, 60, 0.85);
  outline-offset: 1px;
}

/* ── Dividers ───────────────────────────────────────────── */

.section-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2px 0;
}

/* ── Kbd shortcut ───────────────────────────────────────── */

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: var(--font-stage);
  color: var(--muted);
}

/* ── Responsive ─────────────────────────────────────────── */

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

  .topbar,
  .page-toolbar,
  .section-title-row,
  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

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

/* ────────────────────────────────────────────────────────── */
/* Painel do Operador (mobile-first, alto contraste)          */
/* Tokens prefixados --op-* para isolar do design system base */
/* ────────────────────────────────────────────────────────── */

:root {
  --op-bg:        #0b0d10;
  --op-surface:   #14181d;
  --op-surface-2: #1d232b;
  --op-border:    #2a3340;
  --op-text:      #f5f7fa;
  --op-text-dim:  #98a3b3;
  --op-accent:    #00d18f;
  --op-accent-ink:#001a10;
  --op-live:      #ff3b30;
  --op-warn:      #ffb020;
  --op-radius:    14px;
  --op-tap:       56px;
}

[data-theme="op"] {
  background: var(--op-bg);
  color: var(--op-text);
}

[data-theme="op"] body,
body[data-theme="op"] {
  background: var(--op-bg);
  color: var(--op-text);
  -webkit-tap-highlight-color: transparent;
}

/* Animação de saída do GC — usada por viewer e preview */
@keyframes gcSlideOutDown {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(40px); }
}

@keyframes gcFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.gc-exit {
  animation: gcSlideOutDown 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.gc-exit-fade {
  animation: gcFadeOut 0.28s ease-out forwards;
  pointer-events: none;
}
