:root {
  --background: #0a0b0b;
  --card: #131615;
  --foreground: #f0f2f1;
  --primary: #00e08a;
  --primary-foreground: #06170f;
  --secondary: #1d211f;
  --muted: #9aa39e;
  --border: #262b29;
  --destructive: #ef4444;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Space Grotesk', sans-serif;
}

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

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
}

.sidebar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.sidebar-brand .name {
  font-weight: 700;
  font-size: 14px;
}

.sidebar-brand .name span {
  color: var(--primary);
}

.sidebar-brand .version {
  font-size: 10px;
  color: var(--muted);
}

.nav-group {
  margin-bottom: 16px;
}

.nav-group-title {
  padding: 0 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px;
  padding: 8px 8px;
  border-radius: var(--radius);
  font-size: 14px;
  color: rgba(240, 242, 241, 0.8);
}

.nav-link:hover {
  background: var(--secondary);
}

.nav-link.active {
  background: var(--secondary);
  color: var(--primary);
}

.nav-operations-list {
  margin: 4px 8px 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-operation-accordion summary {
  list-style: none;
}

.nav-operation-title {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: rgba(240, 242, 241, 0.85);
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-operation-title::-webkit-details-marker {
  display: none;
}

.nav-operation-title:hover {
  background: var(--secondary);
}

.nav-operation-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav-operation-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.12s ease;
}

.nav-operation-accordion[open] > .nav-operation-title {
  color: var(--primary);
  background: var(--secondary);
}

.nav-operation-accordion[open] > .nav-operation-title .nav-operation-chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

.nav-operation-body {
  margin: 6px 0 4px 17px;
  padding-left: 7px;
  border-left: 1px solid var(--border);
}

.nav-operation-body .nav-link {
  margin-right: 0;
}

.nav-operation-body .nav-group:last-child {
  margin-bottom: 0;
}

.nav-operation-add {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.nav-operation-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.content {
  padding: 24px;
}

/* Typography */
h1.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

h1.page-title span {
  color: var(--primary);
}

.page-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card-body {
  padding: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-card {
  padding: 16px;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-outline {
  border-color: var(--border);
  color: var(--foreground);
  background: transparent;
}

.btn-outline:hover {
  background: var(--secondary);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--secondary);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='number'],
select,
textarea {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 1px solid var(--primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 8px 0;
}

tbody td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid rgba(38, 43, 41, 0.5);
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 224, 138, 0.15);
  color: var(--primary);
}

.badge-solid {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* Pedidos Manuais */
.pedidos-header { text-align: center; margin-bottom: 24px; }
.pedidos-header .icon-badge {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  border-radius: var(--radius);
  background: rgba(0, 224, 138, 0.12);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pedidos-header .icon-badge svg { width: 20px; height: 20px; }
.pedidos-header h1 { margin: 0; }
.pedidos-header p { margin: 4px 0 0; }

.stat-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card-center { text-align: center; padding: 24px; }
.stat-card-center svg { width: 24px; height: 24px; margin: 0 auto 8px; color: var(--primary); display: block; }
.stat-card-center .stat-value { font-size: 24px; }
.stat-card-center .stat-label { margin-top: 4px; }

.code-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 224, 138, 0.15);
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.code-badge button { background: none; border: none; color: inherit; cursor: pointer; padding: 0; display: flex; }
.code-badge button svg { width: 12px; height: 12px; }

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}
.link-btn svg { width: 14px; height: 14px; }

.customer-email { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.table-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 16px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-brand .name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.login-brand .name span {
  color: var(--primary);
}

.login-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.login-brand .tagline {
  color: var(--muted);
  font-size: 14px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
}

.login-card h1 {
  text-align: center;
  font-size: 20px;
  margin: 0;
}

.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 24px;
}

.error-text {
  color: var(--destructive);
  font-size: 13px;
  margin: -8px 0 8px;
}

.success-text {
  color: var(--primary);
  font-size: 13px;
}

pre.snippet {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
}

.carrier-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.carrier-row .form-group {
  margin-bottom: 0;
  flex: 1;
}

.carrier-row .form-group.small {
  flex: 0 0 100px;
}

/* Cabeçalho de card com ícone */
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header .icon-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(0, 224, 138, 0.12);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.card-header p {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

/* Banners de status */
.status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 20px;
}

.status-banner.success {
  background: rgba(0, 224, 138, 0.1);
  border: 1px solid rgba(0, 224, 138, 0.3);
  color: var(--primary);
}

.status-banner.info {
  background: var(--secondary);
  border: 1px solid var(--border);
  color: var(--muted);
}

.status-banner.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--destructive);
}

/* Grid de opções em pílula (radio-card) */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.option-card {
  position: relative;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: var(--secondary);
}

.option-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-card .title {
  font-weight: 700;
  font-size: 15px;
}

.option-card .subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.option-card .check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.option-card input:checked ~ .check {
  display: flex;
}

.option-card:has(input:checked) {
  border-color: var(--primary);
  background: rgba(0, 224, 138, 0.08);
}

/* Cards de plataforma/gateway (Integrações) */
.platform-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  position: relative;
}

.platform-card .platform-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 8px;
}

.platform-card .platform-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 224, 138, 0.15);
  color: var(--primary);
  position: absolute;
  top: 20px;
  right: 20px;
}

.platform-card p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.platform-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  font-size: 13px;
}

.platform-card ul li {
  margin-bottom: 6px;
  color: var(--foreground);
}

.platform-card ul li::before {
  content: '✓ ';
  color: var(--primary);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.week-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 180px;
  padding-top: 12px;
}

.week-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 8px;
}

.week-chart-bar {
  width: 100%;
  max-width: 32px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.week-chart-col span {
  font-size: 11px;
  color: var(--muted);
}

.color-swatches {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.color-swatches button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-swatches button.active {
  border-color: var(--foreground);
}

.code-preview {
  background: #0a0f0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #9aa39e;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tabs a {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.tabs a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.variable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.variable-chips code {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

textarea.code-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  min-height: 120px;
  resize: vertical;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--secondary);
  overflow: hidden;
  margin: 12px 0 8px;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
}

/* Menu mobile (off-canvas, CSS puro) */
.nav-toggle-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.nav-toggle-btn span {
  display: block;
  height: 2px;
  background: var(--foreground);
  border-radius: 2px;
}

.nav-toggle-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

@media (max-width: 900px) {
  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .nav-toggle-checkbox:checked ~ .app .sidebar {
    transform: translateX(0);
  }

  .nav-toggle-checkbox:checked ~ .nav-toggle-overlay {
    display: block;
  }

  .nav-toggle-btn {
    display: flex;
  }

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

  .content {
    padding: 16px;
  }

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

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

  .stat-grid-2 {
    grid-template-columns: 1fr;
  }

  .card {
    overflow-x: auto;
  }

  .carrier-row {
    flex-direction: column;
    align-items: stretch;
  }

  .carrier-row .form-group.small {
    flex: 1;
  }

  .login-card {
    padding: 24px;
  }
}
