:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #edf7f3;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --brand-gold: #eba83a;
  --brand-navy: #203a49;
  --gold: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 14px 40px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

a {
  text-decoration: none;
}

button {
  cursor: pointer;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}

.auth-screen.hidden,
.app-shell.locked,
.hidden {
  display: none;
}

.auth-panel {
  display: grid;
  width: min(960px, 100%);
  grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  align-content: center;
  align-items: center;
  background: var(--brand-navy);
  color: #ffffff;
  margin: 0;
  padding: 32px;
}

.auth-form {
  display: grid;
  gap: 16px;
  padding: 32px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.auth-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 0 12px;
}

.auth-form input:focus {
  border-color: rgba(15, 118, 110, 0.6);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
  outline: none;
}

.auth-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 750;
}

.auth-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-brand .brand-logo {
  width: 132px;
  height: 92px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.auth-brand strong {
  font-size: 1rem;
}

.auth-brand small {
  color: #a7b0bf;
  font-size: 0.82rem;
}

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

.sidebar {
  position: sticky;
  display: flex;
  flex-direction: column;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--brand-navy);
  color: #ffffff;
  padding: 24px 16px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 12px;
}

.brand-logo {
  width: 82px;
  height: 62px;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 7px;
}

.auth-logo {
  width: 132px;
  height: 92px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.brand small {
  display: block;
  color: #a7b0bf;
  margin-top: 4px;
  font-size: 0.78rem;
}

.brand strong {
  display: block;
  color: #ffffff;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
}

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

.mobile-menu-toggle {
  display: none;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9dee7;
  padding: 12px 14px;
  text-align: left;
}

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

.sidebar-footer {
  margin-top: auto;
  padding-top: 24px;
  padding-bottom: 4px;
}

.sidebar-logout {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(235, 168, 58, 0.38);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(235, 168, 58, 0.18), rgba(255, 255, 255, 0.08));
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.16);
  font-weight: 800;
  text-align: center;
  padding: 10px 16px;
}

.sidebar-logout:hover {
  border-color: rgba(235, 168, 58, 0.65);
  background: linear-gradient(135deg, rgba(235, 168, 58, 0.28), rgba(255, 255, 255, 0.12));
}

.sidebar-export {
  width: 100%;
  min-height: 40px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #d9dee7;
  font-weight: 800;
  padding: 8px 12px;
}

.sidebar-export:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.admin-backup-panel {
  grid-column: 1 / -1;
}

.maintenance-layout {
  display: grid;
  grid-template-columns: minmax(0, 920px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.backup-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

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

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

body[data-view="users"] .search {
  display: none !important;
}

.search input,
.task-composer input,
.modal-card input,
.modal-card select,
.quote-client-form input,
.quote-client-form select,
.quote-client-form textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.quote-client-form input:focus,
.quote-client-form select:focus,
.quote-client-form textarea:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
  outline: none;
}

.quote-client-form textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
}

.search input {
  width: min(34vw, 360px);
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.quote-card-actions .primary-button {
  border-color: #b45309;
  background: #eba83a;
  color: #17202b;
}

.quote-card-actions .primary-button:hover {
  background: #d9972f;
}

.ghost-button {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  font-size: 1.35rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

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

.compact-pipeline,
.pipeline-board {
  display: grid;
  gap: 12px;
}

.pipeline-board {
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.stage-column {
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  padding: 12px;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.deal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  margin-bottom: 10px;
}

.deal-card strong {
  display: block;
  line-height: 1.25;
}

.deal-card p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.deal-meta,
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  padding: 0 9px;
  font-weight: 800;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 740px;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

.task-composer {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) 170px auto;
  gap: 10px;
  margin-bottom: 16px;
}

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

.task-list.roomy {
  max-width: 920px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 13px 14px;
}

.task-item.done {
  opacity: 0.62;
}

.task-title {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.task-title input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(29, 36, 48, 0.22);
}

dialog::backdrop {
  background: rgba(23, 32, 43, 0.45);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.modal-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.modal-header,
menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.quote-client-form {
  align-content: start;
  gap: 18px;
  padding: 18px;
}

.quote-client-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.quote-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid #edf0f5;
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.08), rgba(235, 168, 58, 0.08));
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 850;
  margin-top: 8px;
  padding: 12px 12px;
  border-radius: 8px;
  text-transform: uppercase;
}

.quote-section-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--brand-gold);
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 9px !important;
  color: var(--ink) !important;
}

.checkbox-row input {
  min-height: auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.form-checkbox-row {
  justify-content: flex-start;
  margin-top: -2px;
  padding: 4px 0;
}

.quotes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.quote-client-form {
  width: 100%;
}

.quote-products {
  display: grid;
  gap: 10px;
}

.quote-product-row {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 130px 98px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.quote-product-price,
.quote-price-input {
  color: var(--accent-strong);
  font-weight: 850;
}

.quote-price-input {
  color: var(--muted);
  font-size: 0.78rem;
}

.quote-price-input input {
  width: 100%;
  margin-top: 5px;
}

.quote-price-input input:disabled {
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}

.quote-quantity {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.quote-quantity input {
  width: 100%;
  margin-top: 5px;
}

.zip-field {
  max-width: 160px;
}

.price-unlock-button {
  justify-self: start;
}

.percent-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
}

.percent-input input {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.percent-input span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #f9fafb;
  color: var(--muted);
  font-weight: 850;
}

.quote-total-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 16px;
}

.internal-commission-box {
  display: grid;
  gap: 12px;
  border: 1px solid #ead7ad;
  border-radius: 8px;
  background: #fffaf0;
  padding: 16px;
}

.commission-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.commission-result div {
  display: grid;
  gap: 4px;
}

.commission-result span,
.quote-internal-note {
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: 800;
}

.commission-result strong {
  color: var(--ink);
}

.quote-total-box div,
.quote-card-total,
.quote-form-actions,
.quote-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.products-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.product-form {
  display: grid;
  gap: 14px;
}

.product-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.product-form input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

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

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 13px 14px;
}

.signature-editor {
  display: grid;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

#signature-pad {
  width: 100%;
  height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.quote-form-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.quote-card-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.danger-button {
  min-height: 42px;
  border: 1px solid #f3c0bc;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--red);
  font-weight: 750;
  padding: 0 14px;
}

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

.whatsapp-button,
.email-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 750;
  padding: 0 14px;
}

.whatsapp-button {
  border: 1px solid #86efac;
  background: #f0fdf4;
  color: #166534;
}

.whatsapp-button:hover {
  background: #dcfce7;
}

.email-button {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.email-button:hover {
  background: #dbeafe;
}

.app-action-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.button-icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  flex: 0 0 auto;
}

.button-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.quote-total-box span,
.quote-card-total span {
  color: var(--muted);
}

.quote-grand-total {
  border-top: 1px solid var(--line);
  color: var(--ink);
  padding-top: 8px;
}

.quote-grand-total strong,
.quote-card-total strong {
  color: var(--accent-strong);
}

.quote-warning {
  color: var(--red);
  font-weight: 800;
}

.quote-client-list {
  display: grid;
  gap: 12px;
}

.quote-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.quote-list-item:hover {
  border-color: rgba(15, 118, 110, 0.28);
  box-shadow: 0 12px 28px rgba(29, 36, 48, 0.08);
  transform: translateY(-1px);
}

.quote-list-main {
  min-width: 0;
}

.quote-list-main strong {
  display: block;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.25;
}

.quote-list-main span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.quote-list-total {
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 999px;
  background: #edf7f3;
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 950;
  padding: 7px 12px;
  white-space: nowrap;
}

.quote-list-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
}

.quote-list-actions .app-action-button {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

.quote-list-actions .primary-button {
  border-color: #b45309;
  background: var(--brand-gold);
  color: #17202b;
}

.quote-list-actions .primary-button:hover {
  background: #d9972f;
}

.quote-client-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.quote-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.quote-card-header strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
}

.quote-card-header span {
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 900;
  white-space: nowrap;
}

.quote-card-details {
  display: grid;
  gap: 7px;
}

.quote-detail-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.quote-detail-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.quote-detail-row strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

.quote-client-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.quote-card-products {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.quote-card-products span {
  color: var(--ink);
  font-size: 0.86rem;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

@media (max-width: 980px) {
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    padding: 22px;
  }

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .sidebar-footer {
    margin-top: 12px;
    padding-top: 0;
  }

  .brand {
    margin-bottom: 14px;
  }

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

  .nav-item {
    text-align: center;
  }

  .main {
    padding: 20px;
  }

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

  .search input {
    width: 100%;
  }

  .metrics,
  .dashboard-grid,
  .task-composer,
  .quotes-layout,
  .products-layout,
  .maintenance-layout {
    grid-template-columns: 1fr;
  }
}
