:root {
  --ink: #241e1b;
  --muted: #746b65;
  --line: #eadfd7;
  --canvas: #faf7f4;
  --surface: #ffffff;
  --brand: #a83228;
  --brand-dark: #76261f;
  --brand-soft: #f9e5e1;
  --gold: #df9e38;
  --success: #337354;
  --warning: #ad6a0d;
  --danger: #ad3a32;
  --shadow: 0 12px 32px rgba(56, 30, 20, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 30px 18px 20px;
  color: #fff8f3;
  background: linear-gradient(165deg, #5c201b 0%, #8d2d25 54%, #aa352a 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 248, 243, 0.6);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 25px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
}

.brand strong {
  font-family: Georgia, serif;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.21em;
  text-transform: uppercase;
  opacity: 0.78;
}

.navigation {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 12px 14px;
  color: rgba(255, 248, 243, 0.77);
  background: transparent;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: white;
  background: rgba(255, 255, 255, 0.14);
}

.nav-link span {
  width: 17px;
  text-align: center;
  font-size: 18px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 10px;
  font-size: 12px;
  color: rgba(255, 248, 243, 0.78);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a5d49d;
  box-shadow: 0 0 0 4px rgba(165, 212, 157, 0.18);
}

.main-content {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 98px;
  padding: 22px 42px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, serif;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
}

h3 {
  margin-bottom: 5px;
  font-size: 15px;
}

.view {
  padding: 30px 42px 48px;
}

.view-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.view-intro p {
  margin: 0;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.14s ease, background 0.14s ease, border 0.14s ease;
}

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

.button-primary {
  color: white;
  background: var(--brand);
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-secondary {
  color: var(--brand-dark);
  border-color: #dfc6bf;
  background: #fff;
}

.button-quiet {
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.button-small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.metric-card,
.panel,
.filter-panel,
.table-panel,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(58, 37, 27, 0.02);
}

.metric-card {
  min-height: 128px;
  padding: 19px;
}

.metric-card .metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card .metric-value {
  margin-top: 14px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 34px;
  line-height: 1;
}

.metric-card .metric-note {
  display: block;
  margin-top: 7px;
  color: var(--brand);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(360px, 1.45fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.panel-heading,
.table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}

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

.bar-list {
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 115px 1fr 28px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 100px;
  background: #f3e9e4;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #dd7f4f);
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #f0e7e2;
}

.event-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.event-date {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.event-meta {
  min-width: 0;
  flex: 1;
}

.event-meta strong,
.event-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.filter-panel {
  padding: 16px;
  margin-bottom: 17px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: #5f5650;
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ddcfc7;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fffdfb;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(168, 50, 40, 0.12);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  font-size: 12px;
}

.check-label input {
  width: auto;
  margin: 0;
}

.table-panel {
  overflow: hidden;
}

.table-heading {
  padding: 18px 20px 0;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  padding: 11px 20px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #fcfaf8;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid #f0e8e3;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr[data-action] {
  cursor: pointer;
}

tbody tr[data-action]:hover {
  background: #fffaf7;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.table-name {
  display: block;
  font-weight: 800;
}

.table-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-new {
  color: #892b21;
  background: #f9dfdb;
}

.badge-recurring {
  color: #6a5518;
  background: #fbefcf;
}

.badge-neutral {
  color: #5d554f;
  background: #eee9e5;
}

.badge-success {
  color: #256144;
  background: #dcefe3;
}

.badge-warning {
  color: #80510d;
  background: #fbecc9;
}

.badge-danger {
  color: #8a312a;
  background: #f7dedb;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.detail-card {
  padding: 21px;
}

.detail-card + .detail-card {
  margin-top: 18px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-top: 17px;
}

.detail-meta div {
  padding-bottom: 9px;
  border-bottom: 1px solid #f1e9e4;
}

.detail-meta small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  padding: 0 0 18px 20px;
  border-left: 1px solid #e8d7d0;
}

.timeline-item::before {
  position: absolute;
  top: 3px;
  left: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  content: "";
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item strong,
.timeline-item span,
.timeline-item small {
  display: block;
}

.timeline-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.timeline-item small {
  margin-top: 5px;
  color: #988b83;
}

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

.form-grid .full-width {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.section-stack {
  display: grid;
  gap: 18px;
}

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

.config-list {
  display: grid;
  gap: 9px;
}

.config-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #eee3dc;
  border-radius: 9px;
}

.config-row.inactive {
  opacity: 0.55;
}

.import-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 17px 19px;
  border: 1px solid #edcdbf;
  border-radius: 12px;
  background: #fff7f1;
}

.import-callout p {
  margin: 3px 0 0;
  color: #765f55;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(35, 24, 20, 0.48);
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, 94vh);
  overflow: auto;
  border-radius: 14px;
  padding: 23px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(35, 24, 20, 0.3);
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: #f7f1ed;
  font-size: 18px;
}

.toast-root {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 8px;
  max-width: min(390px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border-radius: 9px;
  color: #fff;
  background: #35302d;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  background: var(--danger);
}

.loading {
  display: grid;
  place-items: center;
  min-height: 300px;
  color: var(--muted);
}

.mobile-menu {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--brand);
  background: #fff;
}

@media (max-width: 1050px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .detail-layout,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    display: none;
  }

  .sidebar.is-open {
    position: fixed;
    z-index: 15;
    inset: 0 25% 0 0;
    display: flex;
  }

  .topbar {
    min-height: 78px;
    padding: 15px 18px;
  }

  .mobile-menu {
    display: grid;
    place-items: center;
  }

  .topbar {
    justify-content: flex-start;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .view {
    padding: 21px 18px 34px;
  }

  .view-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-grid,
  .filter-grid,
  .form-grid,
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .filter-grid .button {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 95px 1fr 24px;
  }

  .import-callout {
    align-items: flex-start;
    flex-direction: column;
  }

  th,
  td {
    padding-right: 14px;
    padding-left: 14px;
  }
}

/* OLEGARIO visual identity refresh */
:root {
  --ink: #292929;
  --muted: #707070;
  --line: #e8e8e8;
  --canvas: #f7f7f7;
  --surface: #ffffff;
  --brand: #ff6a13;
  --brand-dark: #e85b08;
  --brand-soft: #fff0e6;
  --gold: #d99a35;
  --success: #28734f;
  --warning: #98600d;
  --danger: #b83a32;
  --shadow: 0 12px 32px rgba(35, 35, 35, 0.07);
  font-family: 'Poppins', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

body { background: var(--canvas); }
button, input, select, textarea { font-family: inherit; }

.sidebar {
  color: var(--ink);
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 24px rgba(25, 25, 25, 0.025);
}
.brand { color: var(--ink); }
.brand-mark {
  color: var(--brand);
  border: 2px solid var(--brand);
  border-radius: 11px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
}
.brand strong {
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.045em;
}
.brand small {
  color: #777;
  font-weight: 600;
  letter-spacing: 0.19em;
}
.nav-link {
  color: #626262;
  border-radius: 8px;
  font-weight: 500;
}
.nav-link:hover,
.nav-link.is-active {
  color: var(--brand-dark);
  background: var(--brand-soft);
}
.nav-link.is-active { font-weight: 650; }
.sidebar-footer { color: #777; }
.status-dot { background: #42a879; }

.topbar {
  border-bottom-color: var(--line);
  background: rgba(255, 255, 255, 0.94);
}
.eyebrow { color: var(--brand-dark); font-weight: 700; }
h1, h2, h3 { font-family: 'Poppins', sans-serif; color: var(--ink); }
h1 { font-weight: 650; letter-spacing: -0.04em; }
h2 { font-weight: 650; letter-spacing: -0.025em; }
h3 { font-weight: 600; }
.view { background: var(--canvas); }
.button { border-radius: 8px; font-weight: 600; }
.button-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 4px 10px rgba(255, 106, 19, 0.16);
}
.button-primary:hover { background: var(--brand-dark); }
.button-secondary {
  color: var(--brand-dark);
  border-color: #ffd0b3;
  background: #fff;
}
.button-secondary:hover { border-color: var(--brand); background: var(--brand-soft); }
.button-quiet { color: #555; }

.card-grid, .dashboard-grid, .detail-layout, .config-grid { align-items: start; }
.detail-card, .metric-card, .panel, .filter-panel, .table-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(25, 25, 25, 0.025);
}
.metric-card, .detail-card, .panel { padding: 20px; }
.table-heading { border-bottom-color: var(--line); }
.table-panel { overflow: hidden; }
th { color: #777; font-weight: 600; }
td { color: #383838; }
tr:hover td { background: #fffaf6; }
.table-name { color: var(--ink); font-weight: 600; }
.table-subtitle { color: var(--muted); }
input, select, textarea {
  border-color: #dedede;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 106, 19, 0.13);
}
.badge-new { color: #a94b0d; background: #fff0e6; }
.empty-state { color: var(--muted); }
.import-callout {
  border: 1px solid #ffdec9;
  border-radius: 12px;
  background: #fff8f3;
}
.import-callout p { color: #725d50; }
.modal { border: 1px solid var(--line); border-radius: 16px; }
.icon-button { color: #666; background: #f3f3f3; }
.mobile-menu { color: var(--brand-dark); background: #fff; }

@media (max-width: 760px) {
  .sidebar.is-open {
    right: 18%;
    background: #fff;
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.12);
  }
  .topbar { background: #fff; }
}

/* Acesso administrativo */
[hidden] { display: none !important; }
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background: #f5f5f4;
}
.auth-card {
  width: min(100%, 430px);
  padding: 42px;
  border: 1px solid #e8e6e3;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(28, 28, 28, .08);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; color: #252525; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 18px; font-weight: 800; }
.auth-brand small { color: #777; font-size: 12px; }
.auth-card .eyebrow { margin: 0 0 8px; color: #FF6A13; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.auth-card h1 { margin: 0; color: #222; font-size: 27px; line-height: 1.25; }
.auth-description { margin: 10px 0 26px; color: #777; font-size: 13px; line-height: 1.6; }
.auth-card form label { display: block; margin-bottom: 8px; color: #333; font-size: 12px; font-weight: 600; }
.auth-card input { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid #dedbd7; border-radius: 8px; font: inherit; }
.auth-submit { width: 100%; min-height: 48px; margin-top: 16px; }
.auth-footnote { display: block; margin-top: 28px; color: #999; font-size: 11px; text-align: center; }
.auth-error { padding: 10px 12px; border-radius: 7px; background: #fff1ed; color: #a7351c; font-size: 12px; }
@media (max-width: 520px) { .auth-card { padding: 30px 24px; } }
