:root {
  --primary: #4b2cc8;
  --primary-dark: #3a20a8;
  --bg: #f3f4f8;
  --text-main: #1f2933;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
}

body.dark {
  --bg: #020617;
  --card-bg: #020617;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #f3f4ff 0, #f9fafb 45%, #edf2ff 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

body.dark {
  background: radial-gradient(circle at top, #020617 0, #020617 45%, #020617 100%);
}

.page {
  width: 100%;
  max-width: 1100px;
  margin: 24px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
}

/* HEADER / NAV */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.brand-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.nav-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* CARDS */

.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.08);
}

/* LOGIN */

.login-page {
  max-width: 420px;
  margin: auto;
}

.login-hero {
  text-align: center;
  margin-bottom: 22px;
}

.login-hero img {
  max-height: 40px;
  margin-bottom: 6px;
}

.login-hero h1 {
  margin: 0;
  font-size: 26px;
  color: var(--primary);
}

.login-hero p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.login-highlight {
  font-size: 12px;
  color: var(--primary-dark);
}

/* FORM */

form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #374151;
}

body.dark form label {
  color: #e5e7eb;
}

form input,
form textarea,
form select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 12px;
  background: #fff;
  color: var(--text-main);
}

body.dark form input,
body.dark form textarea,
body.dark form select {
  background: #020617;
  color: #e5e7eb;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.row {
  display: flex;
  gap: 12px;
}

.col {
  flex: 1;
}

.section-title {
  font-size: 14px;
  margin-top: 10px;
  margin-bottom: 6px;
}

/* BUTTONS */

.btn-primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  width: 100%;
  font-size: 15px;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-small {
  width: auto;
  padding-inline: 16px;
}

.btn-secondary {
  background: #fff;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.btn-tab {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.btn-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

.btn-link-small {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-main);
  background: #fff;
}

/* ALERTAS */

.alert {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
}

.alert-success {
  background: #ecfdf3;
  color: #166534;
}

/* LAYOUT APP */

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 18px;
}

.preview-card {
  font-size: 13px;
  background: linear-gradient(135deg, #eef2ff, #f9fafb);
}

body.dark .preview-card {
  background: linear-gradient(135deg, #020617, #020617);
}

.preview-header {
  font-weight: 600;
  margin-bottom: 10px;
  color: #4b5563;
}

/* HISTÓRICO */

.history-list {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--border);
  gap: 8px;
}

/* TABELA ADMIN */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: #ecfdf3;
  color: #16a34a;
}

.badge-danger {
  background: #fef2f2;
  color: #dc2626;
}

.theme-toggle {
  margin-left: 8px;
}

/* REMEMBER LABEL */

.remember-label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

/* FOOTER */

.site-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding-top: 12px;
}

.site-footer span {
  display: block;
}

@media (min-width: 640px) {
  .site-footer span {
    display: inline-block;
    margin: 0 6px;
  }
}

/* LOGO PREVIEW */

.logo-preview {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.logo-preview img {
  max-height: 50px;
  display: block;
  margin-top: 6px;
}

/* RESPONSIVO MOBILE */

@media (max-width: 768px) {
  body {
    align-items: flex-start;
  }

  .page {
    margin: 12px;
    min-height: calc(100vh - 24px);
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-buttons {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-buttons .btn-tab,
  .nav-buttons .btn-secondary {
    font-size: 11px;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-page {
    margin: 16px;
    max-width: 100%;
  }
}
