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

:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --border: #E2DDD6;
  --sidebar-bg: #0A0A0A;
  --sidebar-hover: #1A1A1A;
  --sidebar-active: #221F00;
  --sidebar-text: #8A8070;
  --sidebar-text-active: #C9A228;
  --accent: #C9A228;
  --accent-hover: #B8911A;
  --accent-light: #FBF6E7;
  --text: #1A1712;
  --text-muted: #6B6457;
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --gold: #C9A228;
  --gold-dark: #8A6D10;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 4px 16px rgba(0,0,0,.10);
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 20px;
  border-bottom: 1px solid rgba(201,162,40,.15);
  gap: 0;
  cursor: pointer;
  transition: opacity .15s;
}

#logo-area {
  min-height: 84px;
  align-items: center;
}
.sidebar-logo:hover { opacity: .85; }

.logo-img {
  max-width: 170px;
  max-height: 84px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.logo-img-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.logo-icon {
  width: 52px; height: 52px;
  background: transparent;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: var(--gold);
  letter-spacing: 1px; flex-shrink: 0;
  font-family: Georgia, serif;
}

.logo-text { display: flex; flex-direction: column; align-items: center; margin-top: 8px; }
.logo-name { color: #E8E4DC; font-weight: 600; font-size: 12px; line-height: 1.4; text-align: center; letter-spacing: 1.5px; text-transform: uppercase; }
.logo-sub { color: var(--gold); font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase; font-weight: 700; margin-top: 1px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #E8E4DC; }
.nav-item.active { background: var(--sidebar-active); color: var(--gold); border-left: 2px solid var(--gold); padding-left: 10px; }

.sidebar-footer {
  padding: 14px 20px;
  color: rgba(138,128,112,.5);
  font-size: 10px;
  border-top: 1px solid rgba(201,162,40,.1);
  text-align: center;
  letter-spacing: .5px;
}

/* ===== MAIN ===== */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--gold); color: #0A0A0A; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: #0A0A0A; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #FCA5A5; }
.btn-danger:hover { background: #FEE2E2; }
.btn-success { background: var(--success-light); color: var(--success); border: 1px solid #6EE7B7; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue { background: #FBF6E7; color: var(--gold); }
.stat-icon.green { background: #FBF6E7; color: var(--gold); }
.stat-icon.yellow { background: #FBF6E7; color: var(--gold); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

/* ===== TABLE ===== */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.table-title { font-weight: 600; font-size: 15px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.search-box svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text); width: 200px;
}
.search-box input::placeholder { color: var(--text-muted); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 11px 18px;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg); }
tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

.td-actions { display: flex; gap: 6px; }
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .35; display: block; }
.empty-state p { font-size: 14px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-blue { background: #FBF6E7; color: var(--gold-dark); border: 1px solid #E8D48A; }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #F1F5F9; color: #64748B; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px;
}
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text);
  background: var(--surface);
  outline: none; transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,40,.12); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ===== MODAL ===== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
#modal-overlay.hidden { display: none; }
#modal {
  background: var(--surface);
  border-radius: 12px;
  width: 580px; max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
#modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
#modal-title { font-size: 16px; font-weight: 700; }
#modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--bg);
  border-radius: 50%; cursor: pointer; font-size: 18px;
  color: var(--text-muted); transition: background .15s;
}
#modal-close:hover { background: var(--border); }
#modal-body { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 16px; border-top: 1px solid var(--border); margin-top: 20px;
}

/* ===== TOAST ===== */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1A2332; color: #fff;
  padding: 12px 20px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 2000; transition: opacity .25s;
}
#toast.hidden { display: none; }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ===== DASHBOARD ===== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.recent-list { display: flex; flex-direction: column; gap: 1px; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.recent-item:last-child { border-bottom: none; }
.recent-item-name { font-weight: 500; }
.recent-item-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ===== DOCUMENTO VIEWER ===== */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.doc-card:hover { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,40,.12); }
.doc-card-icon {
  width: 40px; height: 40px;
  background: #FBF6E7;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  color: var(--gold);
}
.doc-card-icon svg { width: 20px; height: 20px; }
.doc-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.doc-card-desc { font-size: 12.5px; color: var(--text-muted); }

/* ===== DOCUMENT PRINT ===== */
.doc-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 700px;
  margin: 0 auto;
  font-family: 'Times New Roman', Times, serif;
  line-height: 1.8;
}
.doc-preview h2 { text-align: center; font-size: 16px; margin-bottom: 24px; }
.doc-preview p { margin-bottom: 12px; text-align: justify; }

/* ===== KANBAN (Prospecção) ===== */
.kanban-board {
  display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px;
}
.kanban-col {
  min-width: 240px; max-width: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
}
.kanban-col-header {
  padding: 12px 14px;
  font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.kanban-col-count {
  background: var(--border);
  border-radius: 20px;
  padding: 1px 8px; font-size: 11px;
  color: var(--text-muted);
}
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px; padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow .15s;
}
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kanban-card-sub { font-size: 12px; color: var(--text-muted); }
.kanban-add {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.kanban-add-btn {
  width: 100%; padding: 7px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px;
  cursor: pointer; transition: all .15s;
}
.kanban-add-btn:hover { background: var(--surface); color: var(--accent); border-color: var(--accent); }

/* ===== FINANCEIRO ===== */
.fin-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* ===== AVATAR ===== */
.avatar {
  width: 32px; height: 32px;
  background: #FBF6E7;
  border: 1px solid #E8D48A;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--gold-dark);
  flex-shrink: 0;
}

/* ===== LINK CLIENTE ===== */
.link-cliente {
  font-weight: 600;
  color: var(--gold-dark);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: border-color .15s;
}
.link-cliente:hover { border-bottom-color: var(--gold); color: var(--gold); }

/* ===== MISC ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

@media print {
  @page { margin: 2.2cm 2.5cm; }
  #sidebar, .page-header, .table-toolbar .btn { display: none; }
  #main { padding: 0; }
  .doc-preview { border: none; padding: 0; max-width: 100%; }
}
