/* ═══════════════════════ TOKENS ═══════════════════════ */
:root {
  --bg:           #0a0a0a;
  --surface:      #111111;
  --surface-2:    #1a1a1a;
  --border:       #222222;
  --border-hover: #333333;
  --text:         #f5f5f5;
  --text-muted:   #666666;
  --text-subtle:  #444444;
  --green:        #22c55e;
  --amber:        #f59e0b;
  --red:          #ef4444;
}

/* ═══════════════════════ RESET ═══════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* ═══════════════════════ LAYOUT UTILITIES ═══════════════════════ */
.flex         { display: flex; }
.inline-flex  { display: inline-flex; }
.grid         { display: grid; }
.block        { display: block; }
.hidden       { display: none; }

.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.items-end       { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }

.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.w-full  { width: 100%; }
.w-auto  { width: auto; }
.min-w-0 { min-width: 0; }

.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }

/* ═══════════════════════ SPACING UTILITIES ═══════════════════════ */
.p-0 { padding: 0; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.p-6 { padding: 24px; }

.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }

.py-2 { padding-top: 8px;  padding-bottom: 8px;  }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }

.m-0  { margin: 0; }
.mt-1 { margin-top: 4px;  }
.mt-2 { margin-top: 8px;  }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px;  }
.mb-2 { margin-bottom: 8px;  }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* ═══════════════════════ TYPOGRAPHY UTILITIES ═══════════════════════ */
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-base { font-size: 13px; }
.text-md   { font-size: 14px; }
.text-lg   { font-size: 16px; }
.text-xl   { font-size: 18px; }
.text-2xl  { font-size: 22px; }
.text-3xl  { font-size: 28px; }

.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.uppercase         { text-transform: uppercase; }
.tracking-wide     { letter-spacing: 0.06em; }
.leading-tight     { line-height: 1.2; }
.leading-snug      { line-height: 1.4; }
.truncate          { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }

.text-primary { color: var(--text); }
.text-muted   { color: var(--text-muted); }
.text-subtle  { color: var(--text-subtle); }
.text-white   { color: #fff; }
.text-black   { color: #000; }
.text-green   { color: var(--green); }
.text-amber   { color: var(--amber); }
.text-red     { color: var(--red); }

/* ═══════════════════════ BACKGROUND UTILITIES ═══════════════════════ */
.bg-bg        { background: var(--bg); }
.bg-surface   { background: var(--surface); }
.bg-surface-2 { background: var(--surface-2); }
.bg-white     { background: #fff; }

/* ═══════════════════════ BORDER UTILITIES ═══════════════════════ */
.border        { border: 1px solid var(--border); }
.border-top    { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }

.rounded-md   { border-radius: 6px; }
.rounded-lg   { border-radius: 8px; }
.rounded-xl   { border-radius: 10px; }
.rounded-2xl  { border-radius: 12px; }
.rounded-full { border-radius: 999px; }

/* ═══════════════════════ HOVER / TRANSITION ═══════════════════════ */
.transition { transition: background .15s, border-color .15s, color .15s; }

.hover\:bg-surface-2:hover { background: var(--surface-2); }
.hover\:text-primary:hover { color: var(--text); }
.hover\:border-hover:hover { border-color: var(--border-hover); }

.cursor-pointer { cursor: pointer; }

/* ═══════════════════════ TOP NAVIGATION ═══════════════════════ */
.topnav {
  position: fixed;
  inset: 0 0 auto 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 32px;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #000;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.nav-links { display: flex; align-items: center; gap: 2px; flex: 1; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s, background .15s;
  cursor: pointer;
  border: none;
  background: transparent;
}

.nav-link:hover      { color: var(--text); background: var(--surface-2); }
.nav-link.active     { color: var(--text); background: var(--surface-2); }
.nav-link svg        { opacity: 0.6; }
.nav-link.active svg,
.nav-link:hover svg  { opacity: 1; }

/* ═══════════════════════ APP SHELL ═══════════════════════ */
.app-shell {
  padding: 84px 40px 48px;
  max-width: 1280px;
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* ═══════════════════════ BUTTONS ═══════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover         { border-color: var(--border-hover); background: #222; }
.btn-primary       { background: #fff; color: #000; border-color: #fff; }
.btn-primary:hover { background: #e5e5e5; border-color: #e5e5e5; }
.btn-sm            { padding: 5px 10px; font-size: 12px; }
.btn-danger        { color: var(--red); border-color: transparent; background: transparent; }
.btn-danger:hover  { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.2); }

/* ═══════════════════════ BADGES ═══════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge.prospect,
.badge.reuniao_marcada,
.badge.negociacao,
.badge.proposta_enviada     { background: rgba(245,158,11,.1); color: #fbbf24; }

.badge.fechado,
.badge.ativo,
.badge.pago,
.badge.tudo_concluido       { background: rgba(34,197,94,.1);  color: #4ade80; }

.badge.perdido,
.badge.cancelado,
.badge.atrasada,
.badge.aguardando_pagamento { background: rgba(239,68,68,.1);  color: #f87171; }

.badge.sem_cobranca,
.badge.sem_acao,
.badge.pausado              { background: var(--surface-2); color: var(--text-muted); }

.badge-green   { background: rgba(34,197,94,.1);  color: #4ade80; }
.badge-amber   { background: rgba(245,158,11,.1); color: #fbbf24; }
.badge-red     { background: rgba(239,68,68,.1);  color: #f87171; }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* ═══════════════════════ ALERTS ═══════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

.alert.success,
.alert-success {
  background: rgba(34,197,94,.1);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,.2);
}

.alert.error,
.alert-error {
  background: rgba(239,68,68,.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,.2);
}

/* ═══════════════════════ FORM ELEMENTS ═══════════════════════ */
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

input:not([type="submit"]):not([type="file"]):not([type="checkbox"]),
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

input:focus,
select:focus,
textarea:focus { border-color: var(--border-hover); }

textarea { resize: vertical; line-height: 1.5; }

/* ═══════════════════════ TABLE ═══════════════════════ */
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td      { background: rgba(255,255,255,.02); }
td strong        { display: block; font-weight: 600; }
td small         { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════ METRIC CARDS ═══════════════════════ */
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: border-color .15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-card:hover { border-color: var(--border-hover); }

.metric-card > span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-card > strong {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.metric-card > small {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-card.highlight          { background: #fff; border-color: #fff; }
.metric-card.highlight > span   { color: #666; }
.metric-card.highlight > strong { color: #000; }
.metric-card.highlight > small  { color: #888; }

/* ═══════════════════════ FINANCE CARDS ═══════════════════════ */
.finance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finance-card > span   { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.finance-card > strong { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.finance-card > small  { font-size: 12px; color: var(--text-muted); }

.finance-card.positive { border-color: rgba(34,197,94,.2); }
.finance-card.warning  { border-color: rgba(245,158,11,.2); }

.finance-card.net          { background: #fff; border-color: #fff; }
.finance-card.net > span,
.finance-card.net > small  { color: #666; }
.finance-card.net > strong { color: #000; }

/* ═══════════════════════ PRIORITY DOTS ═══════════════════════ */
.priority {
  width: 8px;
  height: 32px;
  border-radius: 8px;
  background: var(--text-subtle);
  flex-shrink: 0;
}

.priority.alta  { background: var(--red); }
.priority.media { background: var(--amber); }
.priority.baixa { background: var(--green); }

/* ═══════════════════════ LIST ROWS ═══════════════════════ */
.list { display: grid; gap: 2px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background .15s;
  text-decoration: none;
  color: inherit;
}

.list-row:hover             { background: var(--surface-2); }
.list-row strong            { display: block; font-size: 13px; font-weight: 500; }
.list-row small             { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.list-row time,
.list-row > span:last-child { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ═══════════════════════ PANELS ═══════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

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

.panel-header h2      { margin: 0; font-size: 14px; font-weight: 600; }
.panel-header a,
.panel-header span    { font-size: 12px; color: var(--text-muted); }
.panel-header a:hover { color: var(--text); }

.table-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* ═══════════════════════ FORM PANEL ═══════════════════════ */
.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  display: grid;
  gap: 18px;
}

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

.form-section {
  display: grid;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.form-section h2 { margin: 0; font-size: 14px; font-weight: 600; }
.form-section p  { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }
.form-actions    { display: flex; gap: 10px; }

/* ═══════════════════════ PAGE HEADER ═══════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-header h1  { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; }
.page-header p   { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.header-actions  { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow         { display: none; }

/* ═══════════════════════ FILTERS ═══════════════════════ */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters input,
.filters select { width: auto; flex: 1; min-width: 160px; max-width: 280px; }
.filters button { flex-shrink: 0; }

/* ═══════════════════════ GRIDS ═══════════════════════ */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

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

/* ═══════════════════════ DETAILS DL ═══════════════════════ */
.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.details div { padding: 12px; background: var(--surface-2); border-radius: 8px; }
.details dt  { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.details dd  { margin: 0; font-size: 13px; overflow-wrap: anywhere; }

.description          { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.description h3       { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.description p        { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* ═══════════════════════ PAYMENTS / CONTRACTS ═══════════════════════ */
.payment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.manual-payment {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 16px;
}

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

.payment-row        { padding: 12px 14px; background: var(--surface-2); border-radius: 8px; }
.payment-row strong { font-size: 13px; font-weight: 500; }
.payment-row small  { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: block; }
.payment-row p      { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }

/* ═══════════════════════ NOTES ═══════════════════════ */
.note-form  { display: grid; gap: 10px; margin-bottom: 16px; }
.notes-list { display: grid; gap: 8px; }

.note      { padding: 14px; background: var(--surface-2); border-radius: 8px; }
.note time { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 6px; }
.note p    { margin: 0; font-size: 13px; line-height: 1.5; }

/* ═══════════════════════ DANGER ZONE ═══════════════════════ */
.danger-zone              { margin-top: 16px; }
.danger-zone button       { background: transparent; border: none; color: var(--red); font-size: 13px; font-weight: 500; cursor: pointer; padding: 0; opacity: 0.6; transition: opacity .15s; }
.danger-zone button:hover { opacity: 1; }

/* ═══════════════════════ EMPTY STATE ═══════════════════════ */
.empty { font-size: 13px; color: var(--text-muted); margin: 0; padding: 8px 0; }

/* ═══════════════════════ LOGIN ═══════════════════════ */
.login-panel {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  display: grid;
  gap: 24px;
}

.login-panel h1 { margin: 0; font-size: 20px; font-weight: 700; }
.form-stack     { display: grid; gap: 14px; }

/* ═══════════════════════ RESPONSIVE ═══════════════════════ */
@media (max-width: 1120px) {
  .metrics-grid         { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finance-grid         { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finance-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .topnav                    { padding: 0 16px; }
  .app-shell                 { padding: 72px 18px 32px; }
  .content-grid,
  .detail-grid               { grid-template-columns: 1fr; }
  .page-header               { flex-direction: column; }
  .filters input,
  .filters select            { max-width: 100%; }
  .form-grid,
  .form-grid.compact-grid,
  .details                   { grid-template-columns: 1fr; }
  .metrics-grid              { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-grid,
  .finance-grid.compact      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .metrics-grid         { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-grid,
  .finance-grid.compact { grid-template-columns: 1fr; }
  .brand-name           { display: none; }
}
