:root {
  color-scheme: dark;
  --bg: #090909;
  --surface: #111111;
  --surface-2: #171717;
  --surface-3: #202020;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(240, 162, 2, 0.45);
  --text: #f8f8f8;
  --muted: #b8b8b8;
  --accent: #f0a202;
  --accent-2: #ffcf5a;
  --success: #21c45a;
  --danger: #d92323;
  --info: #62c7e8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(240, 162, 2, 0.10), transparent 260px),
    linear-gradient(90deg, rgba(98, 199, 232, 0.05), transparent 40%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  gap: 24px;
  align-items: center;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: clamp(120px, 10vw, 154px);
  height: clamp(146px, 12.6vw, 188px);
  object-fit: contain;
  filter:
    drop-shadow(0 0 18px rgba(255, 180, 0, 0.42))
    drop-shadow(0 0 42px rgba(255, 110, 0, 0.18));
  flex: 0 0 auto;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.nav-button {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  color: #101010;
  background: var(--accent);
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.nav-button.subtle {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

.quote-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.72);
  box-shadow: var(--shadow);
}

.quote-status div {
  padding: 12px 16px;
  border-left: 1px solid var(--line);
}

.quote-status div:first-child {
  border-left: 0;
}

.quote-status span,
.field span,
.totals span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.quote-status strong {
  font-size: 1rem;
  white-space: nowrap;
}

.timer-cell strong {
  color: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px 28px;
}

.catalog-panel,
.quote-panel,
.summary-panel,
.payment-panel,
.signature-panel {
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.86);
  box-shadow: var(--shadow);
}

.catalog-panel {
  position: relative;
  overflow: hidden;
}

.catalog-panel::before {
  content: "";
  position: absolute;
  inset: auto -80px -150px auto;
  width: 320px;
  height: 320px;
  background: url("assets/finix-icon.png") center / contain no-repeat;
  opacity: 0.045;
  pointer-events: none;
}

.catalog-panel,
.quote-panel {
  min-height: calc(100vh - 138px);
}

.catalog-panel {
  padding: 16px;
}

.quote-panel {
  padding: 18px;
}

.panel-head,
.quote-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.field {
  display: block;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 162, 2, 0.16);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.filter,
.small-button,
.ghost-button,
.primary-action,
.confirm-action,
.secondary-action,
.whatsapp-action,
.danger-action {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.filter {
  padding: 8px 10px;
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}

.filter.active {
  color: #101010;
  background: var(--accent);
}

.small-button,
.ghost-button {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
  padding: 8px 12px;
}

.product-list {
  display: grid;
  gap: 10px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}

.product-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.product-row h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.product-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.product-controls {
  display: grid;
  grid-template-columns: minmax(84px, 0.55fr) minmax(90px, 0.65fr) minmax(104px, 0.8fr);
  gap: 8px;
  align-items: end;
}

.product-price {
  min-height: 44px;
  display: grid;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  color: var(--accent-2);
  background: rgba(240, 162, 2, 0.08);
  font-weight: 900;
  text-align: center;
}

.custom-product {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.two-fields,
.quote-form {
  display: grid;
  gap: 12px;
}

.two-fields {
  grid-template-columns: 0.7fr 1fr;
}

.quote-form {
  grid-template-columns: 1.3fr 1fr 0.65fr 0.75fr;
  align-items: end;
}

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

.alert-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  padding: 13px 14px;
  border: 1px solid rgba(217, 35, 35, 0.55);
  color: #ffffff;
  background: rgba(217, 35, 35, 0.12);
}

.alert-strip strong {
  color: #ff6b6b;
  text-transform: uppercase;
}

.alert-strip span {
  color: var(--muted);
}

.line-table-wrap {
  position: relative;
  min-height: 250px;
  border: 1px solid var(--line);
  overflow: auto;
  background: rgba(0, 0, 0, 0.22);
}

.line-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--accent-2);
  background: rgba(0, 0, 0, 0.42);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.line-name {
  display: grid;
  gap: 2px;
}

.line-name span {
  color: var(--muted);
  font-size: 0.82rem;
}

.qty-input,
.price-input {
  max-width: 132px;
}

.remove-line {
  width: 42px;
  min-height: 42px;
  border: 1px solid rgba(217, 35, 35, 0.5);
  border-radius: 8px;
  color: #fff;
  background: rgba(217, 35, 35, 0.16);
  cursor: pointer;
  font-weight: 900;
}

.empty-state {
  position: absolute;
  inset: 72px 12px 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.line-table-wrap.has-lines .empty-state {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  margin-top: 14px;
}

.summary-panel,
.payment-panel,
.signature-panel {
  padding: 14px;
}

.signature-panel {
  grid-column: 1 / -1;
}

.invoice-panel {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, rgba(240, 162, 2, 0.12), rgba(17, 17, 17, 0.94));
  box-shadow: var(--shadow);
}

.invoice-status {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid rgba(33, 196, 90, 0.45);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--success);
  background: rgba(33, 196, 90, 0.12);
  font-size: 0.78rem;
  font-weight: 900;
}

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

.invoice-grid div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(17, 17, 17, 0.7);
}

.invoice-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.invoice-grid strong {
  font-size: 1.05rem;
}

.payment-link-field {
  margin-top: 12px;
}

.payment-link-field input {
  color: var(--accent-2);
  font-size: 0.86rem;
}

.invoice-actions {
  display: grid;
  grid-template-columns: 0.85fr 1.25fr 0.85fr;
  gap: 10px;
  margin-top: 12px;
}

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

.totals div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.totals strong {
  font-size: clamp(1.1rem, 2.4vw, 2rem);
  line-height: 1;
}

.totals .grand-total {
  grid-column: 1 / -1;
  border-color: var(--line-strong);
}

.totals .grand-total strong {
  color: var(--accent);
}

.success {
  color: var(--success);
}

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

.payment-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

#signatureCanvas {
  width: 100%;
  height: 180px;
  display: block;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f6f1e8;
  touch-action: none;
}

.primary-action,
.confirm-action,
.secondary-action,
.whatsapp-action,
.danger-action {
  width: 100%;
  padding: 11px 14px;
}

.primary-action {
  color: #101010;
  background: var(--accent);
}

.secondary-action {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--line);
}

.confirm-action {
  color: #101010;
  background: var(--accent);
  border-color: var(--accent);
}

.whatsapp-action {
  color: #05150a;
  background: var(--success);
}

.danger-action {
  color: #fff;
  background: var(--danger);
}

.action-bar {
  display: grid;
  grid-template-columns: 0.9fr 1.35fr 1fr 0.9fr;
  gap: 12px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  background: #151515;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .topbar,
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .nav-button {
    flex: 1 1 160px;
  }

  .catalog-panel,
  .quote-panel {
    min-height: auto;
  }

  .product-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    gap: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-logo {
    width: 100px;
    height: 124px;
  }

  .quote-status {
    grid-template-columns: 1fr;
  }

  .quote-status div,
  .quote-status div:first-child {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .quote-status div:first-child {
    border-top: 0;
  }

  .filters,
  .product-controls,
  .quote-form,
  .summary-grid,
  .totals,
  .invoice-grid,
  .invoice-actions,
  .action-bar {
    grid-template-columns: 1fr;
  }

  .line-table {
    min-width: 680px;
  }

  .alert-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .catalog-panel,
  .toolbar-actions,
  .action-bar,
  .toast,
  .filters,
  .custom-product,
  #clearSearchButton {
    display: none !important;
  }

  .topbar,
  .app-shell {
    max-width: none;
    padding: 0;
  }

  .topbar {
    grid-template-columns: 1fr;
    margin-bottom: 12px;
  }

  .app-shell {
    display: block;
  }

  .quote-panel,
  .summary-panel,
  .payment-panel,
  .invoice-panel,
  .signature-panel,
  .line-table-wrap,
  .quote-status {
    border-color: #d0d0d0;
    box-shadow: none;
    background: #fff;
    color: #111;
  }

  .quote-form,
  .alert-strip,
  .payment-panel,
  .invoice-panel {
    break-inside: avoid;
  }

  input,
  select {
    border-color: #d0d0d0;
    color: #111;
    background: #fff;
  }

  th {
    color: #111;
    background: #f2f2f2;
  }
}
