*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sepia-50: #fbf6ee;
  --sepia-100: #f4eadb;
  --sepia-200: #e4d2b7;
  --sepia-300: #cfb38f;
  --sepia-400: #b18a5f;
  --sepia-500: #8d673e;
  --sepia-600: #704f31;
  --sepia-700: #533b25;
  --sepia-800: #352416;
  --sepia-900: #21160d;
  --gold: #b89135;
  --gold-light: #d2b05d;
  --ink: #23170d;
  --parchment: #f8f2e8;
  --cream: #fcf7ef;
  --surface: rgba(255, 251, 245, 0.76);
  --surface-strong: rgba(255, 251, 245, 0.94);
  --border: rgba(112, 79, 49, 0.16);
  --border-strong: rgba(184, 145, 53, 0.38);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-soft: 0 16px 40px rgba(33, 22, 13, 0.06);
  --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  --radius-sm: 3px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 64px;
  --space-8: 80px;
  --content-max: 960px;
  --reading-max: 640px;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui: 'EB Garamond', Georgia, serif;

  /* Operational aliases used by dashboard/manual pages. */
  --bg: var(--parchment);
  --bg-deep: var(--sepia-900);
  --paper: #fffdf9;
  --paper-soft: var(--sepia-50);
  --ink-soft: var(--sepia-600);
  --line: rgba(112, 79, 49, 0.14);
  --gold-soft: var(--gold-light);
  --green: #557447;
  --green-strong: #6f8f61;
  --green-soft: #dfeede;
  --amber: #956613;
  --amber-soft: #f9edd0;
  --red: #8e4540;
  --red-strong: #a8615a;
  --red-soft: #f8dfda;
  --blue: #37587b;
  --blue-soft: #dde8f5;
  --shadow: var(--shadow-soft);
  --ease: var(--transition-smooth);
}

html { scroll-behavior: smooth; }

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(184, 145, 53, 0.72) rgba(53, 36, 22, 0.16);
}

body::-webkit-scrollbar { width: 14px; }

body::-webkit-scrollbar-track {
  background:
    linear-gradient(180deg, rgba(53, 36, 22, 0.06), rgba(53, 36, 22, 0.14)),
    var(--parchment);
  border-left: 1px solid rgba(112, 79, 49, 0.08);
}

body::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, rgba(210, 176, 93, 0.92), rgba(143, 103, 62, 0.92));
  border: 3px solid rgba(248, 242, 232, 0.94);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(112, 79, 49, 0.08);
}

body::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(216, 186, 109, 0.96), rgba(112, 79, 49, 0.96));
}

body::-webkit-scrollbar-corner { background: var(--parchment); }

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

button,
a,
input,
select,
textarea { transition: var(--transition-smooth); }

:focus-visible {
  outline: 2px solid rgba(184, 145, 53, 0.72);
  outline-offset: 3px;
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  letter-spacing: normal;
  text-transform: none;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings:
    'FILL' 0,
    'wght' 300,
    'GRAD' 0,
    'opsz' 24;
}

.ui-toast-region {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2200;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.ui-toast {
  pointer-events: auto;
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  background: rgba(255, 251, 245, 0.95);
  color: var(--ink);
  box-shadow: 0 22px 54px rgba(33, 22, 13, 0.24);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  opacity: 0;
  transform: translateY(-10px);
  animation: ui-toast-in 220ms ease forwards;
}

.ui-toast.is-success {
  border-color: rgba(85, 116, 71, 0.3);
  border-left-color: rgba(85, 116, 71, 0.72);
}

.ui-toast.is-error {
  border-color: rgba(142, 69, 64, 0.32);
  border-left-color: rgba(142, 69, 64, 0.72);
}

.ui-toast.is-info {
  border-color: rgba(55, 88, 123, 0.28);
  border-left-color: rgba(55, 88, 123, 0.72);
}

.ui-toast strong {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
}

.ui-toast p {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.ui-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(33, 22, 13, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ui-dialog-backdrop.is-active {
  display: flex;
}

.ui-dialog {
  width: min(440px, 100%);
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: rgba(255, 251, 245, 0.94);
  box-shadow: 0 24px 60px rgba(33, 22, 13, 0.24);
  animation: ui-dialog-in 180ms ease forwards;
}

.ui-dialog h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.ui-dialog p {
  margin-top: 10px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.ui-dialog .ui-form-grid {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.ui-dialog .ui-field {
  display: grid;
  gap: 6px;
}

.ui-dialog .ui-field label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.ui-dialog .ui-field input,
.ui-dialog .ui-field select,
.ui-dialog .ui-field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.ui-dialog .ui-field textarea {
  min-height: 100px;
  resize: vertical;
}

.ui-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.ui-dialog-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(112, 79, 49, 0.14);
}

/* UI PAGINATION - Integração Suave */
.ui-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: var(--space-4);
  padding: var(--space-2) 0;
  font-family: var(--font-body);
  border-top: 1px solid rgba(112, 79, 49, 0.08);
}

.ui-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 8px;
  transition: color 0.3s ease, opacity 0.3s ease;
  text-decoration: none;
}

.ui-pagination-btn:hover:not(:disabled) {
  color: var(--gold);
}

.ui-pagination-btn .material-symbols-outlined {
  font-size: 20px;
  font-variation-settings: 'wght' 200;
}

.ui-pagination-btn.is-active {
  color: var(--gold);
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.ui-pagination-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.ui-pagination-dots {
  color: var(--sepia-400);
  padding: 0 4px;
}

@keyframes ui-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ui-dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
