:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface2: #232d3a;
  --text: #e8eaed;
  --muted: #8b9aab;
  --accent: #e8a54b;
  --accent-dim: #c4852e;
  --ok: #5cb88a;
  --warn: #e8a54b;
  --err: #e07a7a;
  --border: #2f3d4d;
  --radius: 10px;
  --font: "Source Sans 3", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(232, 165, 75, 0.08), transparent),
    radial-gradient(ellipse 80% 50% at -10% 50%, rgba(92, 184, 138, 0.05), transparent);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: #f0c070;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(26, 34, 44, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav__cta {
  background: var(--accent);
  color: var(--bg) !important;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
}
.nav__cta:hover {
  background: var(--accent-dim);
  color: var(--bg) !important;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
}

.page-desc {
  color: var(--muted);
  margin: 0 0 1.75rem;
}

.flash {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}
.flash--ok {
  background: rgba(92, 184, 138, 0.12);
  border-color: rgba(92, 184, 138, 0.35);
  color: #a8e0c4;
}
.flash--err {
  background: rgba(224, 122, 122, 0.12);
  border-color: rgba(224, 122, 122, 0.35);
  color: #f0b0b0;
}
.flash--warn {
  background: rgba(232, 165, 75, 0.12);
  border-color: rgba(232, 165, 75, 0.35);
  color: #f5d4a8;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

table.data th,
table.data td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data tr:hover td {
  background: var(--surface2);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.badge--rascunho { background: #3d4a5c; color: #c5d0e0; }
.badge--enviando { background: #4a4a3d; color: #e8e0a5; }
.badge--autorizada { background: rgba(92, 184, 138, 0.25); color: #8fe0b8; }
.badge--rejeitada { background: rgba(224, 122, 122, 0.25); color: #f0a8a8; }
.badge--denegada { background: rgba(232, 165, 75, 0.25); color: #f0d4a0; }
.badge--cancelada { background: #3d3d4a; color: #b8b8d0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}
.btn:hover {
  border-color: var(--muted);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.btn--danger {
  background: rgba(200, 80, 80, 0.35);
  color: #f5c4c4;
  border: 1px solid rgba(220, 120, 120, 0.45);
}
.btn--danger:hover {
  background: rgba(220, 90, 90, 0.45);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--bg);
}
.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

.form-grid {
  display: grid;
  gap: 1rem 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.form-grid--wide {
  grid-column: 1 / -1;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

label.field span.hint {
  font-weight: 400;
  color: var(--muted);
  opacity: 0.85;
  font-size: 0.75rem;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 165, 75, 0.2);
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.dl-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.9375rem;
}
.dl-grid dt {
  color: var(--muted);
  font-weight: 600;
}
.dl-grid dd {
  margin: 0;
}

.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
}
.footer p {
  margin: 0;
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  word-break: break-all;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 2rem 0 1rem;
  letter-spacing: -0.02em;
}

.section-title:first-of-type {
  margin-top: 0;
}

.nav__user {
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__logout {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
}
.nav__logout:hover {
  color: var(--err);
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-card {
  margin: 0;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
  text-align: center;
}

.login-sub {
  color: var(--muted);
  text-align: center;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

.items-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.25rem;
  margin: 0;
  background: var(--surface2);
  position: relative;
}

.item-card .item-remove {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
}

.item-legend {
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 0 0.35rem;
}

.ibge-status {
  margin: 0.5rem 0 0;
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.ibge-status--error {
  color: var(--err);
}

.table-actions-cell {
  vertical-align: top;
  min-width: 11rem;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.table-actions__form {
  display: inline;
  margin: 0;
}

.print-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.btn--icon {
  width: 2.1rem;
  padding: 0.35rem 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 28rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.35rem 1.5rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.modal__desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1rem;
}

.list-toolbar__search {
  flex: 1 1 16rem;
  min-width: 12rem;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}

.list-toolbar__search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 165, 75, 0.2);
}

.list-toolbar__perpage {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.list-meta__count {
  margin: 0;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pager__status {
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
}

.pager__disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
