/* ════════════════════════════════════════════
   TOKENS
   ════════════════════════════════════════════ */
:root {
  --sand:        #F7F1EC;
  --clay:        #EFE5DC;
  --stone:       #D6C7BA;
  --ink:         #3A2E28;
  --ink-2:       #2E2420;
  --muted:       #A69488;
  --clay-red:    #B14A3C;
  --clay-red-lt: #C96A5C;
  --sage:        #5E7A6B;

  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body:    'Manrope', sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-card: 12px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 4px rgba(58,46,40,0.06);
  --shadow-sm: 0 2px 10px rgba(58,46,40,0.08);
  --shadow-md: 0 4px 24px rgba(58,46,40,0.10);
  --shadow-lg: 0 8px 40px rgba(58,46,40,0.14);
  --shadow-xl: 0 20px 60px rgba(58,46,40,0.20);
}

/* ════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-body);
  font-weight: 300;
  background-color: var(--sand);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════════════════════
   SHELL & SIDEBAR
   ════════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink-2);
  color: #D9CFC6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 35;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--sand);
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand span {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

.sidebar-nav {
  list-style: none;
  margin: 14px 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav li {
  margin: 2px 10px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: #D9CFC6;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sand);
}

.sidebar-nav a.active {
  background: var(--clay-red);
  color: var(--sand);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sidebar-user {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-form {
  margin: 0;
}

.sidebar-logout {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: none;
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--muted);
  padding: 6px 10px;
  min-height: 44px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.sidebar-logout:hover {
  border-color: var(--clay-red);
  color: var(--sand);
}

.app-main {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle-btn {
  display: none;
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 40;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--ink-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle-btn span,
.sidebar-toggle-btn span::before,
.sidebar-toggle-btn span::after {
  content: '';
  display: block;
  width: 18px;
  height: 2px;
  background: var(--sand);
  position: relative;
  transition: transform 0.2s, background 0.2s;
}

.sidebar-toggle-btn span::before {
  position: absolute;
  top: -6px;
}

.sidebar-toggle-btn span::after {
  position: absolute;
  top: 6px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(46,36,32,0.5);
  z-index: 30;
}

@media (max-width: 767px) {
  .sidebar-toggle-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-xl);
  }

  .sidebar-brand {
    padding-top: var(--space-8);
  }

  .sidebar-toggle:checked ~ .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle:checked ~ .app-shell .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle:checked ~ .sidebar-toggle-btn span {
    background: transparent;
  }

  .sidebar-toggle:checked ~ .sidebar-toggle-btn span::before {
    transform: rotate(45deg) translate(4px, 5px);
  }

  .sidebar-toggle:checked ~ .sidebar-toggle-btn span::after {
    transform: rotate(-45deg) translate(4px, -5px);
  }
}

/* ════════════════════════════════════════════
   FLASH MESSAGES
   ════════════════════════════════════════════ */
.messages {
  list-style: none;
  padding: var(--space-4) var(--space-6) 0;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 13px var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.78rem;
  margin-bottom: var(--space-2);
  line-height: 1.5;
}

.message--success {
  background: #F0FDF4;
  color: #166534;
  border-left: 3px solid #16A34A;
}

.message--error {
  background: #FEF2F2;
  color: #991B1B;
  border-left: 3px solid #DC2626;
}

.message--warning {
  background: #FFF8EC;
  color: #B45309;
  border-left: 3px solid #D97706;
}

.message--info {
  background: #EDF4FF;
  color: #1A56DB;
  border-left: 3px solid #1A56DB;
}

/* ════════════════════════════════════════════
   FORMULÁRIOS — CAMPOS
   ════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 300;
  color: var(--ink);
  background-color: var(--clay);
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--clay-red);
  box-shadow: 0 0 0 3px rgba(158,107,98,0.12);
}

.form-input::placeholder {
  color: var(--muted);
}

.form-input--error {
  border-color: #C62828;
}

/* Inputs numéricos: esconde as setinhas (alinhamento padrão à esquerda) */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-errors {
  list-style: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-left: 3px solid #DC2626;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.form-error {
  font-size: 0.65rem;
  color: #C62828;
  margin-top: 2px;
}

/* Input com ícone */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .form-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--clay-red);
}

.eye-icon {
  width: 18px;
  height: 18px;
}

/* ════════════════════════════════════════════
   BOTÕES
   ════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 var(--space-5);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn--primary {
  background-color: var(--ink-2);
  color: var(--sand);
  width: 100%;
}

.btn--primary:hover {
  background-color: var(--clay-red);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(158,107,98,0.28);
}

.btn--primary:active {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .btn--primary {
    width: auto;
  }
}

.btn--sm {
  min-height: 44px;
  padding: 0 var(--space-4);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
  width: auto;
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--stone);
}

.btn--ghost:hover {
  background: var(--clay);
  color: var(--ink);
  border-color: var(--clay-red-lt);
}

/* ════════════════════════════════════════════
   LOGIN — PÁGINA
   ════════════════════════════════════════════ */
.login-bg {
  min-height: 100vh;
  background: var(--ink-2);
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-4);
  position: relative;
  overflow: hidden;
}

/* Orbes de fundo */
.login-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.1;
}

.login-orb:nth-child(1) {
  width: 480px;
  height: 480px;
  background: var(--clay-red);
  top: -160px;
  left: -160px;
  animation: orb-drift-1 20s ease-in-out infinite;
}

.login-orb:nth-child(2) {
  width: 360px;
  height: 360px;
  background: var(--sage);
  bottom: -80px;
  right: -80px;
  animation: orb-drift-2 16s ease-in-out infinite;
}

.login-orb:nth-child(3) {
  width: 260px;
  height: 260px;
  background: var(--clay-red-lt);
  top: 45%;
  left: 55%;
  animation: orb-drift-3 24s ease-in-out infinite;
}

@keyframes orb-drift-1 {
  0%, 100% { transform: translate(0, 0); }
  50%       { transform: translate(50px, 35px); }
}
@keyframes orb-drift-2 {
  0%, 100% { transform: translate(0, 0); }
  50%       { transform: translate(-35px, -50px); }
}
@keyframes orb-drift-3 {
  0%, 100% { transform: translate(-50%, -50%); }
  50%       { transform: translate(-44%, -56%); }
}

/* Anéis decorativos */
.login-rings {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.login-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(184,147,90,0.10);
  animation: ring-pulse 9s ease-out infinite;
}

.login-ring:nth-child(1) { width: 260px; height: 260px; animation-delay: 0s; }
.login-ring:nth-child(2) { width: 420px; height: 420px; animation-delay: 1.2s; }
.login-ring:nth-child(3) { width: 580px; height: 580px; animation-delay: 2.4s; }

@keyframes ring-pulse {
  0%   { opacity: 0.35; }
  100% { opacity: 0.03; }
}

/* Card de login */
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--sand);
  border-radius: var(--radius-card);
  padding: var(--space-7) var(--space-5);
  box-shadow: var(--shadow-xl);
  animation: card-appear 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 480px) {
  .login-card {
    padding: var(--space-7) var(--space-7);
  }
}

/* Marca dentro do card */
.login-brand {
  text-align: center;
  margin-bottom: var(--space-5);
}

.login-logo-mark {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 2.2rem;
  color: var(--ink);
  line-height: 1;
  letter-spacing: 0.01em;
}

.login-logo-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 7px;
}

/* Divisor ornamental */
.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  margin: var(--space-4) 0 var(--space-5);
}

.login-divider-line {
  height: 1px;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--stone));
}

.login-divider-line:last-child {
  transform: scaleX(-1);
}

.login-divider-diamond {
  width: 5px;
  height: 5px;
  background: var(--clay-red-lt);
  transform: rotate(45deg);
  opacity: 0.55;
}

/* Subtítulo do formulário */
.login-subtitle {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: var(--space-5);
  letter-spacing: 0.03em;
}

/* Stack do formulário */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ════════════════════════════════════════════
   FOCO ACESSÍVEL (global)
   ════════════════════════════════════════════ */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--clay-red);
  outline-offset: 2px;
}

/* ════════════════════════════════════════════
   SUPPLIERS — LAYOUT
   ════════════════════════════════════════════ */
.page {
  padding: var(--space-8) var(--space-6) var(--space-8);
}

.page--form {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 768px) {
  .page {
    padding: var(--space-7) var(--space-8) var(--space-8);
  }
}

.suppliers-header {
  margin-bottom: var(--space-4);
}

.suppliers-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.section-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.suppliers-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.55rem;
  color: var(--ink);
  line-height: 1.05;
}


/* ════════════════════════════════════════════
   SUPPLIERS — BUSCA
   ════════════════════════════════════════════ */
.suppliers-search-wrap {
  margin-bottom: var(--space-4);
  transition: opacity 0.2s;
}

.suppliers-search-wrap.htmx-request {
  opacity: 0.5;
}

.search-input-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  padding-left: 44px !important;
}

/* ════════════════════════════════════════════
   SUPPLIERS — LISTA
   ════════════════════════════════════════════ */
.suppliers-list {
  min-height: 48px;
}

.supplier-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  margin-bottom: var(--space-2);
  min-height: 64px;
  text-decoration: none;
  transition: background 0.15s;
}

.supplier-row:hover {
  background: var(--clay);
}

.supplier-row__body {
  flex: 1;
  min-width: 0;
}

.supplier-row__name {
  display: block;
  font-weight: 500;
  font-size: 0.98rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supplier-row__phone {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.supplier-row__chevron {
  color: var(--stone);
  font-size: 1.1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.supplier-row__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--clay);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.customer-debt-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--clay-red);
  background: rgba(177,74,60,0.12);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .customer-debt-badge {
    display: none;
  }
}

/* ════════════════════════════════════════════
   SUPPLIERS — ESTADO VAZIO
   ════════════════════════════════════════════ */
.supplier-empty {
  background: var(--clay);
  border: 1px dashed var(--stone);
  border-radius: var(--radius-card);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.supplier-empty__icon {
  font-size: 2rem;
  margin-bottom: var(--space-3);
}

.supplier-empty__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: var(--space-1);
}

.supplier-empty__sub {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ════════════════════════════════════════════
   SUPPLIERS — FORMULÁRIO
   ════════════════════════════════════════════ */
.form-card {
  background: white;
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  margin: 0 0 var(--space-4);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-input--textarea {
  width: 100%;
  box-sizing: border-box;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  resize: vertical;
}

.label-optional {
  color: var(--muted);
  font-weight: 300;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.62rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-3);
}

.checkbox-input {
  width: 18px;
  height: 18px;
  accent-color: var(--clay-red);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-label {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.form-actions {
  margin-top: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.cancel-link {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  text-decoration: underline;
  margin-top: var(--space-3);
}

.back-link {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: var(--space-2);
  transition: color 0.15s;
}

.back-link::before {
  content: '←';
  display: inline-block;
  margin-right: 6px;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  transition: transform 0.15s;
}

.back-link:hover {
  color: var(--ink);
}

.back-link:hover::before {
  transform: translateX(-2px);
}

/* ════════════════════════════════════════════
   SUPPLIERS — FICHA (DETAIL)
   ════════════════════════════════════════════ */
.detail-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: 2px;
}

@media (max-width: 767px) {
  .detail-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.7rem;
  color: var(--ink);
  line-height: 1.05;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px 3px 8px;
  border-radius: 3px 8px 8px 3px;
  flex-shrink: 0;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}

.badge--active {
  background: rgba(94,122,107,0.16);
  color: #3E5548;
}

.badge--inactive {
  background: var(--clay);
  color: var(--muted);
}

.detail-section {
  margin-bottom: var(--space-4);
}

.detail-section .section-label {
  margin-bottom: var(--space-2);
}

.contact-card {
  background: white;
  border-radius: var(--radius-card);
  padding: 0 var(--space-5);
  box-shadow: var(--shadow-xs);
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--clay);
  text-decoration: none;
}

.contact-row > .btn {
  align-self: center;
}

.contact-row > .btn--sm {
  min-height: 44px;
  padding: 0 var(--space-3);
  font-size: 0.65rem;
}

.contact-row--last {
  border-bottom: none;
}

.contact-icon {
  font-size: 1rem;
  line-height: 1.6;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  align-self: center;
}

.contact-icon--danger {
  color: var(--clay-red);
}

.contact-data {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.order-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

@media (max-width: 767px) {
  .order-row__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .order-row__sep {
    display: none;
  }
}

.contact-value {
  font-size: 0.85rem;
  color: var(--ink);
}

.notes-text {
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.6;
  padding: var(--space-4) 0;
  white-space: pre-line;
}

/* ════════════════════════════════════════════
   PRODUCTS — LISTA (linha + meta)
   ════════════════════════════════════════════ */
.product-row__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.product-row__code {
  font-size: 0.92rem;
  color: var(--muted);
  flex-shrink: 0;
}

.product-row__low {
  color: var(--clay-red);
  font-weight: 500;
}

.product-row__out {
  color: var(--muted);
}

/* ── Filtro por tipo (chips) ── */
.type-filter {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.type-chip {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 0.74rem;
  color: var(--muted);
  background: white;
  border: 1px solid var(--stone);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.type-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.type-chip--active {
  background: var(--clay-red);
  border-color: var(--clay-red);
  color: var(--sand);
}

/* Filtros de pedidos: quebram linha no mobile em vez de estourar a largura */
@media (max-width: 767px) {
  #order-filters-indicator .type-filter {
    flex-wrap: wrap;
  }

  #order-filters-indicator .type-chip {
    flex: 0 0 auto;
  }
}

/* ════════════════════════════════════════════
   PRODUCTS — FORM DINÂMICO
   ════════════════════════════════════════════ */
.type-select {
  display: flex;
  gap: var(--space-2);
}

.type-option {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink);
  background: white;
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.type-option input {
  accent-color: var(--clay-red);
  margin-right: var(--space-2);
}

.type-option--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Toggle de campos por tipo — sem JavaScript, via :has() do CSS */
.type-physical-fields,
.type-kit-fields {
  display: none;
  flex-direction: column;
  gap: var(--space-4);
}

.product-form:has(input[name="type"][value="physical"]:checked) .type-physical-fields {
  display: flex;
}

.product-form:has(input[name="type"][value="assembled_kit"]:checked) .type-kit-fields {
  display: flex;
}

/* "Composição" não soma margin ao gap do bloco (ficava mais afastada que os outros) */
.type-kit-fields > .section-label {
  margin-bottom: 0;
}

/* Fornecedor não se aplica a kit: some quando o tipo kit está selecionado */
.product-form:has(input[name="type"][value="assembled_kit"]:checked) .supplier-group {
  display: none;
}

/* ── Categoria + botão de nova categoria ── */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.form-label-row .form-label {
  margin-bottom: 0;
}

.category-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--clay-red);
  background: transparent;
  border: 1px solid var(--stone);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  min-height: 28px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.category-add-btn:hover {
  background: var(--clay);
  border-color: var(--clay-red-lt);
  color: var(--ink);
}

.category-add-btn:focus-visible {
  outline: 2px solid var(--clay-red);
  outline-offset: 2px;
}

/* ── Modal (dialog nativo) ── */
.modal {
  /* margin:auto centraliza o dialog; o reset global zera margin, então repõe aqui */
  margin: auto;
  border: none;
  padding: 0;
  background: transparent;
  max-width: 420px;
  width: calc(100% - var(--space-5));
}

.modal::backdrop {
  background: rgba(61, 37, 32, 0.32);
  backdrop-filter: blur(2px);
}

.modal__panel {
  background: var(--sand);
  border: 1px solid var(--stone);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-5);
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--space-4);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.modal[open] .modal__panel {
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open] .modal__panel {
    animation: none;
  }
}

/* ── Composição de kit ── */
.component-picker {
  position: relative;
}

.component-picker__input {
  padding-right: 44px; /* espaço pro chevron */
}

.component-picker__chevron {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
  transition: transform 0.15s;
}

.component-picker.is-open .component-picker__chevron {
  transform: translateY(-30%) rotate(225deg);
}

.component-picker__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--sand);
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
}

.component-picker__menu[hidden] {
  display: none;
}

.component-picker__option {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.component-picker__option:hover,
.component-picker__option:focus-visible {
  background: var(--clay);
}

.component-picker__option-name {
  font-size: 0.84rem;
  color: var(--ink);
}

.component-picker__option-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.component-picker__empty {
  font-size: 0.78rem;
  color: var(--muted);
  padding: var(--space-2) var(--space-3);
}

.component-results {
  margin-top: var(--space-2);
}

.component-results__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.component-result {
  width: 100%;
  text-align: left;
  background: var(--clay);
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.component-result__name {
  font-size: 0.84rem;
  color: var(--ink);
}

.component-result__meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.component-results__empty {
  font-size: 0.78rem;
  color: var(--muted);
  padding: var(--space-2) 0;
}

.kit-components {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.kit-component-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: white;
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.kit-component-row__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kit-component-row__name {
  font-size: 0.84rem;
  color: var(--ink);
}

.kit-component-row__meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.kit-component-row__qty {
  width: 72px;
  flex-shrink: 0;
  padding: 0 var(--space-2);
  text-align: center;
}

.kit-component-row__remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  min-width: 44px;
  min-height: 44px;
}

.kit-empty {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  padding: var(--space-4);
  margin-top: var(--space-2);
  border: 1px dashed var(--stone);
  border-radius: var(--radius-md);
}

/* Resumo ao vivo do kit, no espírito de um subtotal de recibo */
.kit-ledger {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--clay);
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
}

.kit-ledger__stock {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.kit-ledger__stock--out {
  color: var(--clay-red);
}

.kit-ledger__price {
  display: flex;
  align-items: baseline;
  margin-top: var(--space-1);
  font-size: 0.78rem;
  color: var(--muted);
}

.kit-ledger__leader {
  flex: 1 1 auto;
  position: relative;
  top: -3px;
  margin: 0 var(--space-2);
  border-bottom: 1px dotted var(--stone);
}

.kit-ledger__price-value {
  color: var(--ink);
  font-weight: 500;
}

/* ════════════════════════════════════════════
   PRODUCTS — FICHA
   ════════════════════════════════════════════ */
.badge--neutral {
  background: var(--clay);
  color: var(--ink);
}

.badge--alert {
  background: rgba(177,74,60,0.14);
  color: #8A3527;
}

/* Botão de desmontar: respira longe do card de composição */
.kit-disassemble {
  margin-top: var(--space-4);
}

.btn--danger {
  color: #B71C1C;
  border-color: #E5C2C2;
}

/* Confirmar ação destrutiva: vermelho cheio dentro do modal */
.btn--danger-solid {
  background-color: #B71C1C;
  color: var(--sand);
}

.btn--danger-solid:hover {
  background-color: #9E1414;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(183, 28, 28, 0.28);
}

.btn--danger-solid:active {
  transform: translateY(0);
}

/* ════════════════════════════════════════════
   BILLING — RECEBÍVEIS
   ════════════════════════════════════════════ */
.installment-overdue {
  background: rgba(177,74,60,0.14);
}

.contact-row--highlight {
  background: var(--clay);
  border-left: 3px solid var(--clay-red);
  padding-left: var(--space-3);
}

.kit-component-row__date {
  width: 132px;
  flex-shrink: 0;
}

.detail-section--spaced {
  margin-top: var(--space-5);
}

.installment-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

@media (max-width: 767px) {
  .installment-row-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.modal__text {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: var(--space-4);
}

/* ── Cards de resumo financeiro (ficha do fornecedor) ── */
.finance-summary {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.finance-card {
  flex: 1;
  background: white;
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  text-align: center;
}

.finance-card__value {
  display: block;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.4rem;
  color: var(--ink);
  margin-top: var(--space-1);
}

.finance-card--debt .finance-card__value {
  color: var(--clay-red);
}

/* ════════════════════════════════════════════
   DASHBOARD
   ════════════════════════════════════════════ */
.dashboard-greeting {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.55rem;
  color: var(--ink);
  line-height: 1.05;
}

.dashboard-date {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: var(--space-1);
}

.dashboard-subsection-label {
  display: block;
  margin: var(--space-3) 0 var(--space-2);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi-card {
  background: white;
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.kpi-card__value {
  display: block;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  color: var(--ink);
  margin-top: 2px;
  white-space: nowrap;
}

.upcoming-columns {
  display: flex;
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

@media (max-width: 767px) {
  .upcoming-columns {
    flex-direction: column;
  }
}

.upcoming-column {
  flex: 1;
  min-width: 0;
  padding: var(--space-4) var(--space-5);
}

.upcoming-column + .upcoming-column {
  border-left: 1px solid var(--clay);
}

@media (max-width: 767px) {
  .upcoming-column + .upcoming-column {
    border-left: none;
    border-top: 1px solid var(--clay);
  }
}

.upcoming-column .dashboard-subsection-label {
  margin-top: 0;
}

.upcoming-empty {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.upcoming-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--clay);
  font-size: 0.85rem;
}

.upcoming-empty__icon--in {
  color: var(--sage);
}

.upcoming-empty__icon--out {
  color: var(--clay-red);
}

.upcoming-empty__text {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ════════════════════════════════════════════
   AJUSTES DE USABILIDADE
   ════════════════════════════════════════════ */

/* Indicador de progresso htmx: escondido por padrão, visível durante a requisição */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

/* Lista (ul) dentro das listas de registros: tira o reset inline dos partials */
.suppliers-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Botão de CTA dentro do estado vazio ganha respiro abaixo do título */
.supplier-empty .btn {
  margin-top: var(--space-3);
}

/* Badge inline em rótulos (ex.: "Vencida") com afastamento consistente */
.form-label .badge {
  margin-left: var(--space-2);
}

/* Cabeçalho de seção (rótulo + ação) com espaçamento abaixo, sem style inline */
.detail-section--spaced .suppliers-header-row {
  margin-bottom: var(--space-3);
}

/* Campo de custo unitário na linha de item de compra */
.kit-component-row__cost {
  width: 96px;
  flex-shrink: 0;
  padding: 0 var(--space-2);
}

/* Valor de texto multilinha (observações/endereço) preserva as quebras de linha */
.contact-value--preline {
  white-space: pre-line;
}

/* Filtros da lista de produtos (tipo + fornecedor) */
.product-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.product-filters .type-filter {
  margin-top: 0;
}

/* ════════════════════════════════════════════
   BILLING — CONTAS A RECEBER (lista)
   ════════════════════════════════════════════ */

/* Resumo: três números divididos por hairlines, como um cabeçalho de livro-caixa */
.receivables-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.receivables-stat {
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}

.receivables-stat + .receivables-stat {
  border-left: 1px solid var(--clay);
}

.receivables-stat__label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.receivables-stat__value {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1rem, 3.2vw, 1.5rem);
  color: var(--ink);
  line-height: 1.1;
  margin-top: var(--space-1);
  white-space: nowrap;
}

.receivables-stat--overdue .receivables-stat__value {
  color: var(--clay-red);
}

/* Lista de parcelas */
.receivables-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.receivable {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "due body amount actions";
  align-items: center;
  column-gap: var(--space-3);
  background: white;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  min-height: 64px;
}

.receivable.installment-overdue {
  box-shadow: inset 3px 0 0 var(--clay-red), var(--shadow-xs);
}

/* Ladrilho de calendário: o vencimento é o próprio ícone da linha */
.receivable__due {
  grid-area: due;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 48px;
  border: 1px solid var(--stone);
  border-radius: var(--radius-md);
  background: var(--sand);
  line-height: 1;
}

.receivable__due--overdue {
  border-color: var(--clay-red-lt);
  background: rgba(177, 74, 60, 0.08);
}

.receivable__due-day {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
}

.receivable__due--overdue .receivable__due-day {
  color: var(--clay-red);
}

.receivable__due-month {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.receivable__due--overdue .receivable__due-month {
  color: var(--clay-red);
}

.receivable__body {
  grid-area: body;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.receivable__name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receivable__amount {
  grid-area: amount;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 0.95rem;
  color: var(--ink);
  white-space: nowrap;
}

.receivable__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 0.72rem;
  color: var(--muted);
}

.receivable__actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.copy-icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 767px) {
  .receivables-stat {
    padding: var(--space-3);
  }

  .receivable {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "due body amount"
      "actions actions actions";
    row-gap: var(--space-2);
  }

  .receivable__due {
    width: 40px;
    height: 44px;
  }

  .receivable__actions {
    flex-direction: column;
  }

  .receivable__actions .btn {
    width: 100%;
  }
}
