:root {
  --altitude-blue: #145385;
  --altitude-blue-dark: #0f416b;
  --altitude-teal: #0f766e;
  --accent-green: #2e9f7f;
  --accent-gold: #c9962f;
  --ink: #1c2633;
  --muted: #657386;
  --line: #d7e2ec;
  --line-soft: #e7edf3;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --sidebar: #132131;
  --sidebar-active: #1f344b;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: #f2f6f9;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.app-shell:not(.is-admin) .admin-only {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(20, 83, 133, 0.08), rgba(20, 83, 133, 0) 260px),
    linear-gradient(90deg, rgba(46, 159, 127, 0.05), rgba(46, 159, 127, 0) 420px),
    #f2f6f9;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(20, 83, 133, 0.14), transparent 320px),
    #edf3f7;
}

.auth-view.is-hidden,
.app-shell.is-auth-hidden {
  display: none;
}

.login-panel {
  display: grid;
  width: min(520px, 100%);
  gap: 24px;
  border: 1px solid rgba(20, 83, 133, 0.16);
  border-radius: 8px;
  padding: 32px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(15, 35, 55, 0.14);
}

.login-panel .brand {
  align-items: center;
  color: var(--ink);
}

.login-panel p {
  margin-bottom: 0;
  color: #6b7887;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 20px 16px;
  background:
    linear-gradient(180deg, rgba(20, 83, 133, 0.2), rgba(20, 83, 133, 0) 210px),
    linear-gradient(180deg, #0d1722 0%, #142335 100%);
  color: #f8fafc;
  box-shadow: 14px 0 34px rgba(10, 25, 41, 0.11);
}

.sidebar .brand {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
  border: 1px solid rgba(174, 195, 215, 0.13);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(115, 178, 218, 0.36);
  border-radius: 8px;
  background: #070d13;
  box-shadow: 0 10px 24px rgba(7, 18, 30, 0.16);
}

.brand-icon img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
  user-select: none;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: #f8fafc;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.brand span {
  color: #afc0d1;
  font-size: 13px;
}

.login-panel .brand-icon {
  width: 56px;
  height: 56px;
}

.login-panel .brand-icon img {
  width: 48px;
  height: 48px;
}

.login-panel .brand strong {
  color: var(--ink);
  font-size: 19px;
}

.login-panel .brand span {
  color: #8b9aab;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: transparent;
  color: #d7e3ef;
  text-align: left;
  font-weight: 750;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 #39a9dc;
}

.nav-item:hover {
  transform: translateX(2px);
}

.connection-box {
  margin-top: auto;
  border: 1px solid rgba(174, 195, 215, 0.13);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.connection-box + .sidebar-action {
  margin-top: -10px;
}

.connection-box label {
  display: none;
  margin-bottom: 7px;
  color: #b6c4d2;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.inline-control {
  display: none;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.connection-box input {
  width: 100%;
  border: 1px solid rgba(174, 195, 215, 0.24);
  border-radius: 7px;
  padding: 9px;
  background: rgba(7, 16, 27, 0.48);
  color: #f8fafc;
}

.connection-box p {
  margin: 9px 0 0;
  color: #b6c4d2;
  font-size: 13px;
}

.sidebar-action {
  width: 100%;
}

.workspace {
  min-width: 0;
  padding: 28px 32px 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  border: 1px solid rgba(215, 226, 236, 0.9);
  border-radius: 8px;
  padding: 18px 20px;
  background:
    linear-gradient(90deg, rgba(20, 83, 133, 0.1), rgba(255, 255, 255, 0) 42%),
    rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 38px rgba(15, 35, 55, 0.065);
}

.eyebrow {
  color: var(--altitude-blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

h1 {
  margin-bottom: 0;
  color: #152131;
  font-size: 34px;
  font-weight: 850;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  color: #1a2635;
  font-size: 24px;
}

h3 {
  margin-bottom: 12px;
  color: #213247;
  font-size: 15px;
}

.selection-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
  min-width: min(720px, 100%);
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.selection-strip label {
  color: #64758a;
}

.selection-strip select {
  min-height: 38px;
  background: #f8fbfd;
}

label {
  color: #5b6a7c;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cbd9e5;
  border-radius: 7px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--altitude-blue);
  box-shadow: 0 0 0 3px rgba(20, 83, 133, 0.14);
}

input[readonly] {
  background: #f4f8fb;
  color: #425265;
}

.field-note {
  display: block;
  margin-top: 5px;
  color: #73849a;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  text-transform: none;
}

.api-config-field {
  display: none;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(215, 226, 236, 0.75);
  padding-bottom: 14px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.compact-metrics {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(15, 35, 55, 0.05);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px 18px 16px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--altitude-blue);
}

.metric:nth-child(2)::before {
  background: var(--accent-green);
}

.metric:nth-child(3)::before {
  background: #4677a5;
}

.metric:nth-child(4)::before {
  background: var(--accent-gold);
}

.metric span {
  display: block;
  color: #66778b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: #152131;
  font-size: 32px;
  line-height: 1;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h3::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--altitude-blue);
}

.top-space {
  margin-top: 18px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-title-row h3 {
  margin-bottom: 4px;
}

.panel-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.list-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fbfdff;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.list-item:hover {
  border-color: #bfd1df;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 35, 55, 0.045);
}

.list-item strong {
  color: var(--ink);
}

.list-item.is-selected {
  border-color: rgba(20, 83, 133, 0.34);
  background: #f1f7fb;
  box-shadow: inset 3px 0 0 var(--altitude-blue);
}

.list-item span {
  color: #687789;
  font-size: 13px;
}

.list-pick {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.product-total {
  border-color: #b9d2e5;
  background: #f2f8fc;
}

.accessory-list-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.accessory-list-item div {
  min-width: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.user-profile-item {
  gap: 10px;
}

.user-profile-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px) minmax(130px, 170px) auto;
  gap: 10px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(15, 35, 55, 0.045);
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.accessory-form {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(15, 35, 55, 0.045);
}

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

.accessory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fbfdff;
  color: #2d3b4a;
  font-size: 13px;
}

.accessory-row span {
  overflow-wrap: anywhere;
}

.accessory-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
}

.accessory-row.select-row {
  align-items: flex-start;
  flex-direction: column;
}

.accessory-row.select-row select {
  margin-top: 0;
}

.accessory-catalog-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 12px;
  background: #fbfdff;
}

.accessory-catalog-option span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.accessory-catalog-option strong,
.accessory-catalog-option small {
  overflow-wrap: anywhere;
}

.accessory-catalog-option small {
  color: var(--muted);
  font-size: 12px;
}

.accessory-catalog-option input[type="checkbox"] {
  order: 2;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
}

.accessory-catalog-option select {
  flex: 0 0 min(220px, 45%);
  min-width: 150px;
  margin-top: 0;
}

.manual-accessory {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 35, 55, 0.035);
}

.manual-accessory summary {
  cursor: pointer;
  padding: 14px 18px;
  color: var(--altitude-blue);
  font-weight: 800;
}

.manual-accessory .form-grid {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  box-shadow: none;
}

.budget-pricing-panel {
  margin-bottom: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h3 {
  margin-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eaf4fb;
  color: var(--altitude-blue);
  font-weight: 800;
}

.pricing-preview {
  color: #5f6f80;
}

.pricing-table-wrap {
  overflow-x: auto;
}

.pricing-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 14px;
}

.pricing-table th,
.pricing-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.pricing-table th {
  color: #516176;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.pricing-table td strong,
.pricing-table td span {
  display: block;
}

.pricing-table td span {
  margin-top: 2px;
  color: #6d7c90;
  font-size: 12px;
}

.pricing-table tfoot th {
  color: var(--altitude-blue);
}

.pricing-warnings {
  margin-bottom: 10px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff8e6;
  color: #7a4c00;
}

.pricing-warnings p {
  margin: 0;
}

.pricing-warnings p + p {
  margin-top: 4px;
}

.pricing-error {
  color: #8f1d2c;
}

.settings-list {
  display: grid;
  gap: 14px;
}

.settings-hub {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.settings-shortcut {
  display: block;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  box-shadow: 0 12px 30px rgba(15, 35, 55, 0.05);
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.settings-shortcut:hover {
  border-color: rgba(20, 83, 133, 0.45);
  box-shadow: 0 16px 36px rgba(15, 35, 55, 0.08);
  transform: translateY(-1px);
}

.settings-shortcut span {
  display: block;
  color: var(--altitude-blue);
  font-size: 15px;
  font-weight: 900;
}

.settings-shortcut small {
  display: block;
  margin-top: 8px;
  color: #6a7b8d;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.settings-group h3 {
  color: var(--altitude-blue);
  text-transform: uppercase;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.2fr) auto;
  align-items: end;
  gap: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.settings-group .setting-row[data-setting-key^="empresa_"] {
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 1fr) auto;
}

.setting-row label {
  margin: 0;
}

.setting-row label span,
.setting-row strong {
  color: #5f6f80;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.setting-row small {
  color: #6b7887;
}

.setting-row div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.span-2 {
  grid-column: span 2;
}

.form-subtitle {
  grid-column: span 2;
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  color: var(--altitude-blue);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.technical-budget-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7fbfd;
}

.technical-budget-summary span {
  display: block;
  color: #64758a;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.technical-budget-summary strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.door-field.is-hidden,
.kit-field.is-hidden,
.hydraulic-field.is-hidden,
.liquid-field.is-hidden {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-top: 22px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  padding: 0 18px;
  background: var(--altitude-blue);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(20, 83, 133, 0.22);
}

.primary-button:hover {
  background: var(--altitude-blue-dark);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid #b8c9d8;
  padding: 0 15px;
  background: #ffffff;
  color: #1f3a4f;
}

.secondary-button:hover,
.icon-button:hover {
  background: #f1f7fb;
  border-color: #91aec5;
}

.danger-button {
  border: 1px solid #f1b4bd;
  padding: 0 12px;
  background: #fff5f6;
  color: #8f1d2c;
}

.danger-button:hover {
  background: #ffe6ea;
}

.icon-button {
  border: 1px solid #3d4f62;
  background: #263545;
  color: #ffffff;
}

#proposalFrame {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 35, 55, 0.045);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #162334;
  color: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.22);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

#toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-strip,
  .metric-grid,
  .split-layout,
  .accessory-grid,
  .settings-hub {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .nav-list,
  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .accessory-list-item {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
