/* =============================================
   IMPERION CRM — Design System Premium
   Navy #0f1f3d | Gold #c9a84c | Branco
   Tipografia: Cormorant Garamond + DM Sans
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --navy:        #0f1f3d;
  --navy-mid:    #162848;
  --navy-light:  #1e3560;
  --navy-border: rgba(255,255,255,0.09);
  --gold:        #c9a84c;
  --gold-light:  #e2c97a;
  --gold-dim:    #a07830;
  --gold-bg:     rgba(201,168,76,0.08);
  --white:       #ffffff;
  --off-white:   #f5f3ef;
  --surface:     #fafaf8;
  --surface-2:   #f0ede8;
  --text-main:   #1a1a2e;
  --text-sec:    #4a4a6a;
  --text-muted:  #8888aa;
  --border:      #e5e1db;
  --border-dark: #ccc8c0;
  --success:     #1a7a4a;
  --success-bg:  #e8f7ef;
  --warning:     #8a6000;
  --warning-bg:  #fff8e0;
  --danger:      #a32020;
  --danger-bg:   #fdeaea;
  --info:        #1a4fa0;
  --info-bg:     #e8f0fc;
  --sidebar-w:   230px;
  --header-h:    58px;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.05);
  --shadow:      0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.14);
  --transition:  all 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text-main); background: var(--off-white); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  background-image: linear-gradient(160deg, #0f1f3d 0%, #0a1628 100%);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  transition: left 0.25s ease;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--navy-border);
  position: relative;
}
.brand-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 600;
  letter-spacing: 0.14em; color: var(--white);
}
.brand-name span { color: var(--gold); }
.brand-sub {
  font-size: 8.5px; letter-spacing: 0.2em;
  color: rgba(201,168,76,0.6);
  text-transform: uppercase; margin-top: 3px;
}

.nav-section {
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 18px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; font-size: 13px; font-weight: 400;
  color: rgba(255,255,255,0.6);
  cursor: pointer; border-left: 2px solid transparent;
  text-decoration: none; transition: var(--transition);
  border-radius: 0;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(201,168,76,0.15) 0%, transparent 100%);
  color: var(--gold-light); border-left-color: var(--gold);
  font-weight: 500;
}
.nav-item i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto; padding: 16px 20px;
  border-top: 1px solid var(--navy-border);
  font-size: 12px; color: rgba(255,255,255,0.4);
}
.sidebar-footer .user-name { color: rgba(255,255,255,0.75); font-weight: 500; font-size: 13px; }
.sidebar-footer .user-role { color: var(--gold); font-size: 11px; margin-top: 2px; opacity: 0.7; }

/* ===== MAIN ===== */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,0.04);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title {
  font-size: 16px; font-weight: 600;
  color: var(--text-main); letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content-area { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-dark);
  background: var(--white); color: var(--text-main);
  transition: var(--transition); white-space: nowrap;
  line-height: 1;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-gold {
  background: linear-gradient(135deg, #d4a84c 0%, #c9a84c 100%);
  border-color: #b8922a; color: var(--navy); font-weight: 600;
  box-shadow: 0 2px 8px rgba(201,168,76,0.3);
}
.btn-gold:hover { background: linear-gradient(135deg, #e0b85e 0%, #d4a84c 100%); box-shadow: 0 4px 14px rgba(201,168,76,0.4); }

.btn-navy {
  background: var(--navy); border-color: var(--navy-mid);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(15,31,61,0.25);
}
.btn-navy:hover { background: var(--navy-mid); box-shadow: 0 4px 14px rgba(15,31,61,0.3); }

.btn-danger { background: var(--danger-bg); border-color: #f5c6c6; color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 7px; }
.btn-menu { display: none !important; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  background: var(--white);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: var(--transition); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  right: 0; height: 3px; background: var(--border);
}
.stat-card.stat-gold::before { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 28px; font-weight: 600; color: var(--text-main); line-height: 1; font-family: 'Cormorant Garamond', serif; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.stat-gold .stat-value { color: var(--gold-dim); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 16px; text-align: left;
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  background: var(--surface); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: var(--surface); }
.td-muted { color: var(--text-muted); font-size: 12px; }
.td-mono { font-family: 'DM Mono', monospace; font-size: 12px; }
.td-bold { font-weight: 600; }
.td-r { text-align: right; }
.td-c { text-align: center; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--surface-2);  color: var(--text-sec); }
.badge-gold    { background: #fdf6e4; color: var(--gold-dim); border: 1px solid #f0d8a0; }
.badge-navy    { background: #e8ecf4; color: var(--navy-light); }

/* ===== FORMS ===== */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: repeat(4,1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-full { grid-column: 1/-1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-sec); letter-spacing: 0.01em; }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1.5px solid var(--border-dark);
  border-radius: var(--radius); font-size: 13px;
  color: var(--text-main); background: var(--white);
  transition: var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.14);
}
.field textarea { resize: vertical; min-height: 80px; }
.field .hint { font-size: 11px; color: var(--text-muted); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,12,25,0.6);
  z-index: 1000; display: flex;
  align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--white); border-radius: var(--radius-xl);
  width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface); position: sticky; bottom: 0;
}
.btn-close-modal { background: none; border: none; font-size: 22px; color: var(--text-muted); line-height: 1; padding: 2px; transition: var(--transition); }
.btn-close-modal:hover { color: var(--text-main); }

/* ===== ALERTS ===== */
.alert { padding: 11px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 9px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b8e8d0; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #f5c6c6; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #c0d4f4; }

/* ===== SEARCH BAR ===== */
.search-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input {
  flex: 1; max-width: 360px; min-width: 200px;
  padding: 9px 12px 9px 38px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius); font-size: 13px; outline: none;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238888aa' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") 11px center no-repeat;
  transition: var(--transition);
}
.search-bar input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,0.12); }

/* ===== TABS ===== */
.tab-bar { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; overflow-x: auto; }
.tab-item { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); white-space: nowrap; }
.tab-item:hover { color: var(--text-main); }
.tab-item.active { color: var(--gold-dim); border-bottom-color: var(--gold); font-weight: 600; }

/* ===== CRM KANBAN ===== */
.kanban-board { display: grid; grid-template-columns: repeat(5,1fr); gap: 14px; }
.kanban-col { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 14px; }
.kanban-col-header { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-sec); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.kanban-count { background: var(--border); padding: 2px 8px; border-radius: 100px; font-size: 11px; color: var(--text-muted); }
.kanban-card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: pointer; transition: var(--transition); }
.kanban-card:hover { border-color: var(--gold); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.kanban-card-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; }
.avatar-xs { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, var(--info-bg), var(--info)); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }

/* ===== RENTABILIDADE ===== */
.rent-box { background: linear-gradient(135deg, #f8f7f4 0%, #f2efe9 100%); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; margin-top: 16px; }
.rent-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 14px; }
.rent-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.rent-row:last-child { border-bottom: none; padding-bottom: 0; }
.rent-row.total { font-weight: 700; font-size: 14px; color: var(--text-main); border-top: 2px solid var(--border-dark); margin-top: 4px; padding-top: 11px; }
.rent-row.green { color: var(--success); }
.rent-pct { font-size: 11px; background: var(--success-bg); color: var(--success); padding: 2px 8px; border-radius: 100px; font-weight: 700; margin-left: 8px; }
.rent-pct.low { background: var(--danger-bg); color: var(--danger); }

/* ===== ITEMS TABLE ===== */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.items-table th { background: var(--navy); color: rgba(255,255,255,0.85); font-size: 10.5px; font-weight: 600; padding: 9px 10px; text-align: left; letter-spacing: 0.04em; }
.items-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.items-table tfoot td { background: var(--surface); font-weight: 700; border-top: 2px solid var(--border-dark); }
.items-table input[type=text], .items-table input[type=number] {
  width: 100%; padding: 6px 8px; border: 1.5px solid var(--border-dark); border-radius: 5px; font-size: 12px; transition: var(--transition);
}
.items-table input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 2px rgba(201,168,76,0.1); }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0a1628 0%, #0f1f3d 50%, #162848 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(201,168,76,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(201,168,76,0.05) 0%, transparent 50%);
}
.login-card {
  background: var(--white); border-radius: 20px;
  padding: 44px 40px; width: 400px; position: relative; z-index: 1;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .name { font-family: 'Cormorant Garamond', serif; font-size: 36px; font-weight: 600; letter-spacing: 0.12em; color: var(--navy); }
.login-brand .name span { color: var(--gold); }
.login-brand .sub { font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-muted); margin-top: 5px; }
.login-brand .gold-line { width: 40px; height: 2px; background: linear-gradient(90deg, var(--gold), transparent); margin: 10px auto 0; border-radius: 2px; }

/* ===== UTILS ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-right { text-align: right; }
.text-gold { color: var(--gold-dim); font-weight: 700; }
.text-navy { color: var(--navy); font-weight: 700; }
.fw-600 { font-weight: 600; }
.hidden { display: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.gold-line { width: 40px; height: 2px; background: var(--gold); margin: 6px 0 16px; border-radius: 2px; }
.tc { text-align: center; }

/* ===== PDF ===== */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content-area { padding: 0 !important; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 999; }
.sidebar-overlay.open { display: block; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed !important;
    left: -250px !important;
    top: 0; bottom: 0; width: 230px !important;
    z-index: 1000; transition: left 0.25s ease;
  }
  .sidebar.open { left: 0 !important; }
  .btn-menu { display: flex !important; }
  .app-layout { display: block; }
  .main-area { width: 100%; height: 100vh; display: flex; flex-direction: column; }
  .topbar { padding: 0 14px; height: 52px; }
  .topbar-left { gap: 10px; }
  .page-title { font-size: 14px; }
  .topbar-right > span { display: none; }
  .content-area { padding: 14px; flex: 1; overflow-y: auto; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  div[style*="grid-template-columns:1fr 1fr"], div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 280px"], div[style*="grid-template-columns:1fr 300px"],
  div[style*="grid-template-columns:1fr 340px"] { display: block !important; }
  .card { margin-bottom: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 10px; }
  tbody td { padding: 9px 10px; }
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr !important; }
  .col-span-2, .col-span-3, .col-full { grid-column: 1 !important; }
  .modal-overlay { padding: 0; align-items: flex-end; backdrop-filter: blur(2px); }
  .modal-box { max-width: 100% !important; border-radius: 20px 20px 0 0; max-height: 92vh; width: 100%; }
  .kanban-board { display: flex !important; overflow-x: auto; gap: 12px; padding-bottom: 12px; }
  .kanban-col { min-width: 240px; flex-shrink: 0; }
  .btn { font-size: 12px; }
  .search-bar input { max-width: 100%; width: 100%; }
  .login-card { width: calc(100vw - 32px); padding: 32px 24px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
