:root {
  --bg: #eef4fb;
  --bg-soft: #f7faff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-2: rgba(248, 251, 255, 0.96);
  --surface-strong: #ffffff;
  --surface-strong-2: #f5f9ff;
  --border: rgba(71, 101, 138, 0.14);
  --border-strong: rgba(71, 101, 138, 0.2);
  --text: #17304a;
  --text-soft: #48627e;
  --muted: #617a95;
  --accent: #2f78db;
  --accent-2: #4f90e6;
  --success: #4fa56a;
  --danger: #d14545;
  --warning: #b6781c;
  --shadow: 0 20px 48px rgba(49, 88, 132, 0.14);
  --radius-xl: 36px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --max-width: 1180px;
  --transition: 240ms ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(47, 120, 219, 0.12), transparent 28%),
    linear-gradient(180deg, #f7fbff 0%, #eef4fb 48%, #e8eff8 100%);
  min-height: 100vh;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.container {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 251, 255, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(71, 101, 138, 0.1);
  box-shadow: 0 10px 28px rgba(49, 88, 132, 0.08);
}

.nav {
  display: grid;
  gap: 0.7rem;
  padding: 0.95rem 0 0.85rem;
}

.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-bottom {
  display: flex;
  justify-content: center;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.04em;
  font-size: 1.08rem;
}

.brand span {
  color: var(--accent);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(71, 101, 138, 0.2);
  background: rgba(255, 255, 255, 0.86);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.nav-toggle-bar {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  list-style: none;
  color: var(--muted);
  font-size: 0.95rem;
  flex-wrap: wrap;
  min-width: 0;
}

.header-user-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text-soft);
  text-align: right;
}

.header-user-info {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.header-user-company {
  display: inline-flex;
  align-items: center;
}

.header-user-greeting {
  color: var(--text-soft);
}

.header-user-actions {
  display: inline-flex;
  align-items: center;
}

.header-user-actions form {
  display: inline-flex;
  margin: 0;
}

.header-company-switch {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.header-company-select {
  width: auto;
  min-height: 32px;
  padding: 0.26rem 1.8rem 0.26rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(71, 101, 138, 0.2);
  background-color: rgba(255, 255, 255, 0.74);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(71, 101, 138, 0.58) 50%),
    linear-gradient(135deg, rgba(71, 101, 138, 0.58) 50%, transparent 50%);
  background-position:
    calc(100% - 0.95rem) 48%,
    calc(100% - 0.65rem) 48%;
  background-size: 0.34rem 0.34rem, 0.34rem 0.34rem;
  background-repeat: no-repeat;
}

.header-company-select:hover {
  border-color: rgba(71, 101, 138, 0.34);
  color: var(--text);
}

.header-company-select:focus-visible {
  border-color: rgba(47, 120, 219, 0.45);
  box-shadow: 0 0 0 3px rgba(47, 120, 219, 0.12);
}

.header-company-select option {
  color: var(--text);
}

.header-separator {
  color: var(--muted);
}

.user-role {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 0.92rem;
}

.user-role {
  color: var(--accent);
}

.nav-links a {
  position: relative;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  transition: color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(47, 120, 219, 0.1);
}

.nav-logout {
  border: 1px solid rgba(71, 101, 138, 0.2);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-soft);
  font: inherit;
  cursor: pointer;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  min-height: 32px;
  width: auto;
}

.nav-logout:hover {
  color: var(--text);
  border-color: rgba(71, 101, 138, 0.3);
}

main {
  padding-top: 2.8rem;
  padding-bottom: 3rem;
}

.flash-stack {
  margin-bottom: 1rem;
}

.flash-list {
  list-style: none;
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}

.flash-message {
  margin: 0;
  padding: 0.3rem 0 0.32rem 0.62rem;
  border-left: 2px solid rgba(47, 120, 219, 0.4);
  color: #2b5d93;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
}

.flash-message.flash-success {
  border-left-color: rgba(79, 165, 106, 0.5);
  color: #2f7e4b;
}

.flash-message.flash-warning {
  border-left-color: rgba(182, 120, 28, 0.5);
  color: #966015;
}

.flash-message.flash-error,
.flash-message.flash-danger {
  border-left-color: rgba(209, 69, 69, 0.55);
  color: #a33333;
}

section {
  padding: 1rem 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.section-heading h2 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: -0.045em;
}

.section-heading p {
  color: var(--text-soft);
  max-width: 700px;
  line-height: 1.7;
}

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, var(--surface-strong), var(--surface-strong-2));
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.panel h3 {
  font-size: 1.08rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.03em;
}

.panel p,
.panel li,
.panel td,
.panel .muted,
.panel small {
  color: var(--text-soft);
}

.panel h2,
.panel h3,
.panel strong,
.panel th,
.panel label {
  color: var(--text);
}

.form-panel form {
  display: grid;
  gap: 1rem;
}

.form-panel {
  padding: 1.35rem 1.45rem;
  border-radius: 24px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: var(--shadow);
}

.form-panel-compact {
  max-width: 760px;
}

.form-note {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(182, 120, 28, 0.18);
  background: rgba(255, 246, 227, 0.92);
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.6;
}

.form-note strong {
  color: var(--warning);
}

.form-panel p {
  margin-bottom: 0;
}

.form-panel ul.errorlist {
  list-style: none;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(209, 69, 69, 0.22);
  background: rgba(209, 69, 69, 0.08);
  color: #9f2e2e;
  font-size: 0.92rem;
  line-height: 1.55;
}

.form-panel ul.errorlist li {
  color: inherit;
}

.form-panel fieldset {
  border: 0;
}

.form-submenu {
  margin-top: 1rem;
  border: 1px solid rgba(71, 101, 138, 0.14);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(244, 248, 255, 0.96));
  overflow: hidden;
}

.form-submenu summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.15rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-submenu summary::-webkit-details-marker {
  display: none;
}

.form-submenu summary::after {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform var(--transition);
}

.form-submenu[open] summary::after {
  transform: rotate(225deg);
}

.form-submenu-body {
  padding: 0 1.15rem 1.15rem;
}

.form-panel form.is-collapsed fieldset,
.form-panel form.is-collapsed .inline-actions {
  display: none;
}

.muted {
  color: var(--text-soft);
}

.editor-shell {
  display: grid;
  gap: 1rem;
}

.editor-grid {
  display: grid;
  gap: 1rem;
}

.editor-sidebar {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.inline-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  min-height: 44px;
  padding: 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition), color var(--transition);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.btn:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(118, 169, 255, 0.34);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(180deg, rgba(235, 244, 255, 0.98) 0%, rgba(222, 236, 255, 0.98) 100%);
  border-color: rgba(47, 120, 219, 0.18);
  color: #2d6bbf;
  box-shadow: 0 10px 24px rgba(118, 169, 255, 0.12);
}

.btn-primary:hover {
  background: linear-gradient(180deg, rgba(229, 240, 255, 1) 0%, rgba(214, 231, 255, 1) 100%);
  box-shadow: 0 12px 28px rgba(118, 169, 255, 0.16);
}

.btn-primary-lite {
  min-height: 40px;
  padding: 0 0.9rem;
  background: rgba(232, 242, 255, 0.96);
  color: #2d6bbf;
  border-color: rgba(47, 120, 219, 0.16);
  box-shadow: none;
}

.btn-primary-lite:hover {
  box-shadow: none;
  background: rgba(223, 237, 255, 0.98);
}

.btn-soft {
  min-height: 40px;
  padding: 0 0.95rem;
  background: rgba(240, 247, 255, 0.98);
  color: #316dbf;
  border-color: rgba(47, 120, 219, 0.14);
  box-shadow: none;
}

.btn-soft:hover {
  box-shadow: none;
  background: rgba(231, 241, 255, 0.98);
}

.btn-status-draft {
  min-height: 40px;
  background: rgba(108, 130, 154, 0.12);
  color: #6c829a;
  border-color: rgba(108, 130, 154, 0.22);
  box-shadow: none;
}

.btn-status-draft:hover {
  background: rgba(108, 130, 154, 0.18);
  border-color: rgba(108, 130, 154, 0.28);
  box-shadow: none;
}

.btn-status-approved {
  min-height: 40px;
  background: rgba(61, 143, 86, 0.12);
  color: #3d8f56;
  border-color: rgba(61, 143, 86, 0.22);
  box-shadow: none;
}

.btn-status-approved:hover {
  background: rgba(61, 143, 86, 0.18);
  box-shadow: none;
}

.btn-status-rejected {
  min-height: 40px;
  background: rgba(190, 68, 68, 0.12);
  color: #be4444;
  border-color: rgba(190, 68, 68, 0.22);
  box-shadow: none;
}

.btn-status-rejected:hover {
  background: rgba(190, 68, 68, 0.18);
  box-shadow: none;
}

.btn-status-cancelled {
  min-height: 40px;
  background: rgba(96, 116, 136, 0.12);
  color: #607488;
  border-color: rgba(96, 116, 136, 0.22);
  box-shadow: none;
}

.btn-status-cancelled:hover {
  background: rgba(96, 116, 136, 0.18);
  box-shadow: none;
}

.btn-icon {
  min-width: 44px;
  padding: 0;
}

.btn-icon-action {
  min-width: 40px;
  width: 40px;
  min-height: 40px;
  padding: 0;
}

.action-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-color: rgba(71, 101, 138, 0.22);
}

.btn-compact {
  min-height: 38px;
  padding: 0 0.8rem;
  gap: 0.38rem;
  font-size: 0.9rem;
}

.btn-danger {
  background: rgba(209, 69, 69, 0.1);
  color: #b63e3e;
  border-color: rgba(209, 69, 69, 0.18);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #ffffff, #f6faff);
  padding: 1rem;
}

.stat-card .label {
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.stat-card .value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

form p {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--text);
  font-weight: 600;
}

.required-mark {
  color: #b63e3e;
  margin-left: 0.2rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.82rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

input[data-force-uppercase="1"] {
  text-transform: uppercase;
}

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

input::placeholder,
textarea::placeholder {
  color: #8aa0b8;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff;
  border-color: rgba(118, 169, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(118, 169, 255, 0.14);
}

select option {
  background: #ffffff;
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  accent-color: var(--accent);
  transform: scale(1.08);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.3rem;
}

.checkbox-row label {
  margin-bottom: 0;
  font-weight: 500;
}

.filters-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.compact-filters {
  margin-bottom: 0;
}

.filters-form input {
  flex: 1 1 320px;
}

.filters-form select {
  width: auto;
  min-width: 180px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.96);
}

th,
td {
  padding: 0.9rem;
  border-bottom: 1px solid rgba(71, 101, 138, 0.12);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text);
  background: #f3f8ff;
  font-size: 0.92rem;
}

td {
  color: var(--text-soft);
}

tr:hover td {
  background: rgba(47, 120, 219, 0.04);
}

.money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.36rem 0.68rem;
  border-radius: 999px;
  background: rgba(47, 120, 219, 0.08);
  border: 1px solid rgba(47, 120, 219, 0.1);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.1;
  text-align: center;
}

.badge-warning {
  background: rgba(182, 120, 28, 0.1);
  border-color: rgba(182, 120, 28, 0.14);
  color: #925d16;
}

.badge-success {
  background: rgba(79, 165, 106, 0.12);
  border-color: rgba(79, 165, 106, 0.18);
  color: #2f7d49;
}

.badge-info {
  background: rgba(47, 120, 219, 0.1);
  border-color: rgba(47, 120, 219, 0.14);
  color: #2d6bbf;
}

.badge-danger {
  background: rgba(209, 69, 69, 0.12);
  border-color: rgba(209, 69, 69, 0.18);
  color: #b63e3e;
}

.badge-danger-soft {
  background: rgba(209, 69, 69, 0.1);
  border-color: rgba(209, 69, 69, 0.16);
  color: #b63e3e;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.62rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--category-color, #2563eb) 12%, white);
  border: 1px solid color-mix(in srgb, var(--category-color, #2563eb) 18%, white);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.1;
}

.category-chip-inline {
  padding: 0.22rem 0.5rem;
  font-size: 0.76rem;
}

.category-chip-dot,
.category-color-preview {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: var(--category-color, #2563eb);
  flex: 0 0 auto;
}

.category-color-preview {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(71, 101, 138, 0.14);
}

.status-rascunho { color: #445f7d; }
.status-em_elaboracao { color: #a16b18; }
.status-enviado { color: #2f78db; }
.status-aprovado { color: #3d8f56; }
.status-rejeitado { color: #be4444; }
.status-cancelado { color: #607488; }

.modal-panel {
  margin-top: 1rem;
  background: linear-gradient(180deg, #ffffff, #f6faff);
  border: 1px solid rgba(71, 101, 138, 0.16);
  box-shadow: var(--shadow);
}

.item-entry-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-radius: 22px;
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(circle at top right, rgba(47, 120, 219, 0.08), transparent 35%),
    linear-gradient(180deg, #ffffff, #f6faff);
  box-shadow: var(--shadow);
}

.item-entry-panel-compact {
  width: min(100%, 760px);
  padding: 1rem 1.1rem;
  border-radius: 20px;
}

.editor-shell > #item-create-panel-region {
  display: none;
}

.item-entry-panel-compact .section-heading h3,
.item-entry-panel-compact .item-block-header h4 {
  font-size: 0.96rem;
}

.item-entry-panel-compact .form-grid {
  gap: 0.8rem;
}

.item-entry-panel-compact .form-grid,
.item-entry-panel-compact .catalog-picker,
.item-entry-panel-compact .item-builder-grid,
.item-entry-panel-compact .inline-feedback,
.item-entry-panel-compact .item-builder {
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.item-entry-panel-compact textarea {
  min-height: 92px;
}

.item-entry-panel-compact textarea[name="descricao"] {
  min-height: 3.8rem;
}

.item-builder {
  display: grid;
  gap: 1rem;
}

.item-builder-intro {
  display: block;
}

.item-builder-preview,
.catalog-summary {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(247, 250, 255, 0.92);
}

.catalog-summary[data-category-active="1"] {
  background: color-mix(in srgb, var(--category-color, #2563eb) 12%, white);
  border-color: color-mix(in srgb, var(--category-color, #2563eb) 24%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--category-color, #2563eb) 10%, white);
}

.item-builder-preview strong,
.catalog-summary strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.item-builder-preview {
  display: grid;
  align-content: center;
}

.item-builder-preview strong {
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}

.preview-label {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-inline {
  margin-top: 1rem;
}

.item-builder-grid {
  display: grid;
  gap: 1rem;
}

.item-block {
  padding: 0.9rem 0;
  border-top: 1px solid rgba(71, 101, 138, 0.14);
  background: transparent;
}

.item-builder-grid .item-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.item-block-header {
  margin-bottom: 0.7rem;
}

.item-block-header h4 {
  font-size: 1rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.item-block-header p,
.catalog-summary small,
.item-builder-preview small {
  color: var(--text-soft);
}

.catalog-picker {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.catalog-search-row {
  display: grid;
  grid-template-columns: minmax(0, 24rem) 40px;
  align-items: center;
  gap: 0.65rem;
  justify-content: start;
  width: min(100%, calc(24rem + 40px + 0.65rem));
}

.catalog-search-row input {
  width: 100%;
  min-width: 0;
}

.catalog-search-row .btn {
  width: 40px;
  min-width: 40px;
  justify-self: start;
}

.catalog-summary {
  min-height: 84px;
}

.catalog-summary small {
  display: block;
}

.actions-col {
  min-width: 220px;
  text-align: center;
}

.status-col {
  min-width: 220px;
  text-align: center;
}

.status-cell {
  display: grid;
  gap: 0.65rem;
  justify-items: center;
}

.actions-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: stretch;
}

.actions-stack-inline {
  flex-wrap: wrap;
}

.actions-stack form {
  display: inline-flex;
}

.actions-stack .btn,
.actions-stack form .btn {
  min-width: 132px;
  min-height: 40px;
}

.actions-stack .btn-icon-action,
.actions-stack form .btn-icon-action {
  min-width: 40px;
}

.table-subline {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.table-subline-muted {
  font-size: 0.83rem;
  color: var(--muted);
}

.table-subline-warning {
  font-size: 0.83rem;
  color: #a16b18;
}

.budget-main-cell,
.budget-meta-cell,
.budget-title-cell,
.budget-total-cell {
  min-width: 0;
}

.budget-main-cell strong,
.budget-meta-cell strong,
.budget-title-cell strong,
.budget-total-cell strong {
  color: var(--text);
}

.simple-list {
  display: grid;
  gap: 0.75rem;
}

.simple-list-item {
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.92);
}

.empty-state {
  color: var(--text-soft);
  padding: 0.5rem 0;
}

.auth-shell {
  width: 100%;
  min-height: calc(100vh - 180px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
}

.auth-card {
  width: min(100%, 460px);
  padding: 2rem;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.auth-header {
  margin-bottom: 1.5rem;
}

.auth-header h2 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.045em;
  margin-bottom: 0.4rem;
}

.auth-header p {
  color: var(--text-soft);
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-submit {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-visitor-section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(71, 101, 138, 0.14);
}

.auth-visitor-section p {
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}

.auth-disclaimer {
  margin-top: 1.25rem;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(71, 101, 138, 0.12);
  background: rgba(244, 248, 255, 0.86);
}

.auth-disclaimer p {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.65;
}

.form-errors {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(209, 69, 69, 0.16);
  background: rgba(209, 69, 69, 0.08);
  color: #b63e3e;
}

.form-errors p + p {
  margin-top: 0.35rem;
}

.inline-feedback {
  min-height: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--accent-2);
  font-size: 0.92rem;
}

.inline-feedback-inline {
  min-height: 0;
  margin-bottom: 0;
}

.item-feedback-success {
  border-color: rgba(144, 211, 164, 0.28);
  background: rgba(144, 211, 164, 0.10);
}

.preview-warning {
  color: #ffd9a1;
}

.is-loading {
  opacity: 0.7;
  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;
}

.adjustment-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.items-compact-table td strong {
  color: var(--text);
}

.item-row-detail td {
  padding: 0;
  background: rgba(243, 248, 255, 0.96);
}

.item-row-inline-edit td {
  padding: 0;
  background: rgba(243, 248, 255, 0.96);
}

.item-row-detail.is-hidden {
  display: none;
}

.item-row-card {
  padding: 1rem;
}

.item-modal[hidden] {
  display: none;
}

.item-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.item-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 48, 74, 0.42);
  backdrop-filter: blur(8px);
}

.item-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  overflow: auto;
}

.item-modal-content .item-entry-panel {
  border-radius: 24px;
  border: 1px solid rgba(71, 101, 138, 0.18);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: 0 24px 48px rgba(23, 48, 74, 0.18);
}

.item-modal-content .item-builder {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.modal-open {
  overflow: hidden;
}

.item-row-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.item-row-card-grid p + p {
  margin-top: 0.35rem;
}

.report-status-card {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.9);
}

.report-status-card strong {
  display: block;
  margin-bottom: 0.35rem;
}

.report-status-success {
  border-color: rgba(79, 165, 106, 0.18);
  background: rgba(79, 165, 106, 0.08);
}

.report-status-info {
  border-color: rgba(47, 120, 219, 0.18);
  background: rgba(47, 120, 219, 0.08);
}

.report-status-warning {
  border-color: rgba(182, 120, 28, 0.18);
  background: rgba(182, 120, 28, 0.08);
}

.report-status-danger {
  border-color: rgba(209, 69, 69, 0.18);
  background: rgba(209, 69, 69, 0.08);
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.report-meta-card {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.9);
}

.report-logo-card {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
}

.report-logo {
  max-width: 220px;
  max-height: 96px;
  object-fit: contain;
}

.report-export-list {
  display: grid;
  gap: 0.65rem;
}

.report-export-list-compact {
  justify-items: center;
}

.report-export-list-compact .btn {
  min-width: 140px;
}

.pagination {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pagination-summary {
  color: var(--text-soft);
}

#totais-card-region {
  margin-bottom: 0.5rem;
}

.section-heading-compact {
  margin-bottom: 1rem;
  align-items: center;
}

.section-heading-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.item-modal-heading {
  margin-bottom: 0;
}

.item-modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.table-section {
  display: grid;
  gap: 1rem;
}

#item-feedback-region {
  margin-top: 0.25rem;
}

.editor-shell > .inline-actions > .btn {
  width: 100%;
  justify-content: center;
}

.totals-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.totals-category-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.totals-strip-general {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.totals-card {
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: var(--shadow);
}

.totals-card strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.totals-card small {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-soft);
}

.totals-card-emphasis {
  background: linear-gradient(180deg, #eef5ff, #deebff);
}

.actions-cluster {
  display: grid;
  gap: 0.65rem;
}

.actions-stack-status {
  padding-top: 0.65rem;
  border-top: 1px solid rgba(71, 101, 138, 0.12);
}

.auth-error-text {
  margin-bottom: 1rem;
  color: #c43d3d;
  font-size: 0.95rem;
  font-weight: 600;
}

.dashboard-welcome {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 1rem;
  color: var(--text-soft);
}

.dashboard-welcome strong {
  color: var(--text);
}

.manual-grid {
  margin-bottom: 1rem;
}

.manual-grid p,
.manual-role-card p {
  margin-top: 0.45rem;
  color: var(--text-soft);
}

.manual-list {
  padding-left: 1.15rem;
}

.manual-list li {
  padding-left: 0.15rem;
}

.manual-icon-label {
  display: inline-block;
}

.manual-icon-label .action-icon {
  width: 18px;
  height: 18px;
  margin-right: 0.55rem;
  vertical-align: text-bottom;
}

.report-options-group + .report-options-group {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.report-options-divider {
  height: 1px;
  margin: 1.1rem 0;
  background: var(--border);
}

.report-options-group h4 {
  margin-bottom: 0.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.report-options-helper {
  margin-bottom: 0.6rem;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.manual-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.manual-roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.inline-actions-end {
  justify-content: flex-end;
}

.manual-status-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.manual-status-flow p {
  margin-top: 0.35rem;
}

.manual-panel-gap {
  margin-top: 1.35rem;
}

.manual-role-card {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.88);
}

.list-footer-toggle {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.list-footer-toggle a {
  color: var(--accent);
  font-size: 0.95rem;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .item-builder-intro {
    grid-template-columns: 1fr;
  }

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

  .report-summary-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  .nav {
    gap: 0.5rem;
    padding: 0.65rem 0;
  }

  .nav-top {
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    flex-wrap: wrap;
  }

  .brand {
    font-size: 1rem;
    order: 1;
  }

  .nav-toggle {
    display: inline-flex;
    order: 2;
  }

  .header-user-meta,
  .nav-bottom {
    display: none;
  }

  .header-user-meta {
    order: 3;
    flex: 1 0 100%;
  }

  .nav.nav-open .header-user-meta,
  .nav.nav-open .nav-bottom {
    display: flex;
    width: 100%;
  }

  .nav.nav-open .header-user-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding-top: 0.3rem;
  }

  .nav.nav-open .nav-bottom {
    justify-content: center;
  }

  .nav.nav-open .nav-links {
    gap: 0.45rem;
  }

  .nav.nav-open .header-user-info {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 0.3rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(71, 101, 138, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
  }

  .nav.nav-open .header-user-company {
    width: 100%;
    justify-content: center;
  }

  .nav.nav-open .header-user-actions {
    width: 100%;
    justify-content: center;
  }

  .nav.nav-open .header-user-actions form,
  .nav.nav-open .header-user-actions .nav-logout {
    width: auto;
    max-width: 100%;
  }

  .header-separator,
  .header-logout {
    display: none;
  }

  .header-user-meta .header-company-select {
    max-width: min(84vw, 320px);
  }
}

@media (max-width: 760px) {
  .table-wrap > table:not(.items-compact-table) {
    border: 0;
    background: transparent;
  }

  .table-wrap > table:not(.items-compact-table) thead {
    display: none;
  }

  .table-wrap > table:not(.items-compact-table) tbody,
  .table-wrap > table:not(.items-compact-table) tr,
  .table-wrap > table:not(.items-compact-table) td {
    display: block;
    width: 100%;
  }

  .table-wrap > table:not(.items-compact-table) tr {
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
  }

  .table-wrap > table:not(.items-compact-table) tr:hover td {
    background: transparent;
  }

  .table-wrap > table:not(.items-compact-table) td {
    margin: 0;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(71, 101, 138, 0.1);
    text-align: left;
  }

  .table-wrap > table:not(.items-compact-table) td:last-child {
    border-bottom: 0;
  }

  .table-wrap > table:not(.items-compact-table) td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
    letter-spacing: 0.01em;
  }

  .table-wrap > table:not(.items-compact-table) td[data-label=""]::before {
    display: none;
  }

  .table-wrap > table.items-compact-table {
    border: 0;
    background: transparent;
  }

  .table-wrap > table.items-compact-table thead {
    display: none;
  }

  .table-wrap > table.items-compact-table tbody,
  .table-wrap > table.items-compact-table tr,
  .table-wrap > table.items-compact-table td {
    display: block;
    width: 100%;
  }

  .table-wrap > table.items-compact-table tr {
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
  }

  .table-wrap > table.items-compact-table tr:hover td {
    background: transparent;
  }

  .table-wrap > table.items-compact-table td {
    margin: 0;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(71, 101, 138, 0.1);
    text-align: left;
  }

  .table-wrap > table.items-compact-table td:last-child {
    border-bottom: 0;
  }

  .table-wrap > table.items-compact-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
    letter-spacing: 0.01em;
  }

  .table-wrap > table.items-compact-table td[data-label=""]::before {
    display: none;
  }

  .actions-col,
  .status-col {
    min-width: 0;
    text-align: left;
  }

  .status-cell {
    justify-items: start;
  }

  .actions-stack {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .container {
    width: min(calc(100% - 1.25rem), var(--max-width));
  }

  main {
    padding-top: 1.45rem;
    padding-bottom: 2rem;
  }

  .panel,
  .form-panel,
  .item-entry-panel {
    padding: 1rem;
    border-radius: 18px;
  }

  .nav-top {
    width: 100%;
  }

  .brand {
    max-width: calc(100% - 50px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-user-meta {
    width: 100%;
  }

  .header-separator {
    display: none;
  }

  .header-user-meta .header-company-select,
  .header-company-select {
    width: auto !important;
    max-width: 92vw;
    min-height: 30px !important;
    line-height: 1.35 !important;
  }

  .user-role,
  .header-logout {
    width: auto;
  }

  .nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 0.45rem;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 0.1rem 0.18rem;
  }

  .nav-links li {
    min-width: 0;
  }

  .nav-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }

  .section-heading h2 {
    font-size: clamp(1.45rem, 6vw, 1.75rem);
  }

  .stats-grid,
  .form-grid,
  .totals-strip {
    grid-template-columns: 1fr;
  }

  .filters-form {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .filters-form input,
  .filters-form select,
  .filters-form button {
    width: 100%;
    min-width: 0;
    flex: initial;
  }

  .filters-form .btn-icon-action {
    min-width: 44px;
    justify-content: center;
  }

  .manual-layout,
  .manual-roles,
  .manual-status-flow {
    grid-template-columns: 1fr;
  }

  .section-heading {
    flex-direction: column;
    align-items: start;
  }

  .inline-actions {
    width: 100%;
    align-items: stretch;
  }

  .inline-actions .btn,
  .inline-actions form {
    width: 100%;
  }

  .inline-actions form .btn {
    width: 100%;
  }

  .catalog-search-row {
    grid-template-columns: 1fr 44px;
    width: 100%;
  }

  .catalog-search-row .btn {
    width: 44px;
    min-width: 44px;
  }

  .actions-stack .btn,
  .actions-stack form .btn {
    min-width: 44px;
  }

  .actions-col {
    min-width: 130px;
  }

  .status-col {
    min-width: 160px;
  }

  .pagination {
    justify-content: center;
  }

  .auth-shell {
    min-height: auto;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .auth-card {
    padding: 1.3rem;
    border-radius: 20px;
  }

  .auth-header {
    margin-bottom: 1.1rem;
  }

  .auth-header h2 {
    font-size: clamp(1.45rem, 7vw, 1.9rem);
    margin-bottom: 0.2rem;
  }

  .auth-header p {
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .auth-form {
    gap: 0.8rem;
  }

  .auth-visitor-section {
    margin-top: 0.95rem;
    padding-top: 0.9rem;
  }

  .auth-disclaimer {
    margin-top: 0.95rem;
    padding: 0.8rem 0.85rem;
  }

  .auth-disclaimer p {
    font-size: 0.86rem;
    line-height: 1.52;
  }
}

@media (max-width: 420px) {
  .auth-shell {
    padding-top: 0.55rem;
    padding-bottom: 0.8rem;
  }

  .auth-card {
    padding: 1rem;
    border-radius: 16px;
  }

  .auth-submit.btn {
    min-height: 42px;
  }
}

@media (max-width: 420px) {
  .nav-links {
    grid-template-columns: 1fr;
  }
}

/* Header company switch: keep this override at the end to beat generic form controls */
.header-user-meta .header-company-switch {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.header-user-meta .header-company-select {
  width: auto !important;
  min-height: 34px !important;
  min-width: 10ch !important;
  padding: 0.24rem 0.72rem !important;
  border-radius: 999px !important;
  border: 1px solid rgba(71, 101, 138, 0.2) !important;
  border-bottom: 1px solid rgba(71, 101, 138, 0.2) !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: var(--text-soft) !important;
  font-size: 0.92em !important;
  font-weight: 500 !important;
  line-height: inherit !important;
  letter-spacing: 0.01em !important;
  box-shadow: none !important;
  appearance: auto !important;
  -webkit-appearance: menulist !important;
  background-image: none !important;
  background-position: initial !important;
  background-size: initial !important;
  background-repeat: no-repeat !important;
  flex: 0 0 auto !important;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
  text-align: left !important;
  text-align-last: left !important;
}

.header-user-meta .header-company-select option {
  text-align: left;
}

.header-user-meta .header-company-select:hover {
  border-color: rgba(71, 101, 138, 0.34) !important;
  color: var(--text) !important;
}

.header-user-meta .header-company-select:focus,
.header-user-meta .header-company-select:focus-visible {
  border-color: rgba(47, 120, 219, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(47, 120, 219, 0.12) !important;
  background: rgba(255, 255, 255, 0.94) !important;
}

@media (max-width: 700px) {
  .header-user-meta .header-company-switch {
    width: auto;
    justify-content: center;
  }

  .header-user-meta .header-company-select {
    width: auto !important;
    max-width: 92vw !important;
  }
}
