:root {
  --bg: #0D0C0A;
  --surface: #151310;
  --surface-2: #1E1B16;
  --surface-3: #28241D;
  --gold: #C8AD82;
  --gold-bright: #E5CFA7;
  --gold-dim: rgba(200, 173, 130, 0.14);
  --border: rgba(200, 173, 130, 0.2);
  --border-soft: rgba(255, 255, 255, 0.07);
  --text: #F4EFE6;
  --muted: #9B9387;
  --hot: #F2994A;
  --hot-bg: rgba(242, 153, 74, 0.15);
  --warm: #F2C94C;
  --warm-bg: rgba(242, 201, 76, 0.14);
  --cold: #7BB7E8;
  --cold-bg: rgba(123, 183, 232, 0.14);
  --ok: #6FCF97;
  --ok-bg: rgba(111, 207, 151, 0.14);
  --danger: #EB5757;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold-bright), #8C6D3F);
  color: #0D0C0A;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 0.05em;
}

.brand-name { font-size: 15px; font-weight: 600; letter-spacing: 0.16em; color: var(--gold-bright); }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--gold-dim);
  border-color: var(--border);
  color: var(--gold-bright);
  font-weight: 500;
}

.nav-icon { width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--hot-bg);
  color: var(--hot);
  border: 1px solid rgba(242, 153, 74, 0.35);
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 8px;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.round-mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.round-mini-label { font-size: 10px; letter-spacing: 0.16em; color: var(--gold); font-weight: 600; }
.round-mini-val { font-size: 15px; font-weight: 600; margin: 4px 0 8px; color: var(--text); }
.round-mini-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

.progress-track { height: 6px; background: #0D0C0A; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); transition: width 0.3s ease; }

.links-mini { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.links-mini a { color: var(--muted); text-decoration: none; }
.links-mini a:hover { color: var(--gold-bright); }

/* MAIN */
.main {
  flex: 1;
  min-width: 0;
  padding: 20px 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.search-wrap { flex: 1; min-width: 240px; }

input, select, textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  outline: none;
}

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

.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar select { width: auto; min-width: 135px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #0D0C0A;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--gold-bright);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--gold-dim); }

.btn-danger {
  background: rgba(235, 87, 87, 0.15);
  color: var(--danger);
  border-color: rgba(235, 87, 87, 0.35);
}
.btn-danger:hover { background: rgba(235, 87, 87, 0.25); }

.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* KPI STRIP */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.kpi-card.highlight {
  background: linear-gradient(135deg, rgba(200, 173, 130, 0.15), var(--surface));
  border-color: var(--gold);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--gold); }
.kpi-value { font-size: 28px; font-weight: 300; color: var(--text); margin: 4px 0; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* VIEWS */
.view { display: none; flex-direction: column; gap: 16px; }
.view.active { display: flex; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.view-header h1 { font-size: 22px; font-weight: 400; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* KANBAN */
.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}

.kanban-col {
  width: 264px;
  min-width: 264px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 285px);
}

.kanban-col.drag-over {
  border-color: var(--gold);
  background: rgba(200, 173, 130, 0.06);
}

.col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.col-title { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-bright); }
.col-count { font-size: 11px; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }

.col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 110px;
}

.lead-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lead-card:hover { border-color: var(--gold-bright); transform: translateY(-1px); }
.lead-card.dragging { opacity: 0.45; }

.lead-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lead-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.lead-company { font-size: 12px; color: var(--muted); }
.lead-money { font-size: 15px; font-weight: 600; color: var(--gold-bright); }
.lead-next { font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border-soft); padding-top: 6px; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--gold-bright);
  background: var(--gold-dim);
  font-weight: 500;
}
.badge.hot { color: var(--hot); background: var(--hot-bg); border-color: rgba(242, 153, 74, 0.35); }
.badge.warm { color: var(--warm); background: var(--warm-bg); border-color: rgba(242, 201, 76, 0.35); }
.badge.cold { color: var(--cold); background: var(--cold-bg); border-color: rgba(123, 183, 232, 0.35); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(111, 207, 151, 0.35); }

/* TABLES */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 11px 13px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: rgba(200, 173, 130, 0.06); }
.data-table.compact td, .data-table.compact th { padding: 8px 11px; }

/* CARDS & GRIDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.section-title { font-size: 16px; font-weight: 500; color: var(--gold-bright); margin-bottom: 10px; }
.section-subtitle { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); margin-bottom: 8px; font-weight: 600; }

.calc-grid, .tools-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 18px;
}

.calc-input { font-size: 24px; font-weight: 600; color: var(--gold-bright); padding: 12px 14px; margin: 6px 0 12px; }
.quick-amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--gold-bright); background: var(--gold-dim); color: var(--gold-bright); }

.calc-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.calc-stat { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px; }
.calc-stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.calc-stat .val { font-size: 19px; color: var(--gold-bright); font-weight: 600; margin-top: 2px; }
.disclaimer { font-size: 11px; color: var(--muted); margin-top: 12px; }

/* CALL SHEET PAPER */
.callsheet-paper {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.cs-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.cs-title { font-size: 22px; color: var(--gold-bright); font-weight: 400; }
.cs-lead-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* DRAWER */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(620px, 95vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--gold);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-code { font-size: 11px; letter-spacing: 0.16em; color: var(--gold); }
.drawer-header h2 { font-size: 20px; font-weight: 500; }
.icon-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
}

.drawer-body { padding: 18px 22px 28px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }

.wa-panel {
  background: linear-gradient(135deg, rgba(111, 207, 151, 0.09), var(--surface-2));
  border: 1px solid rgba(111, 207, 151, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
}
.wa-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-row { margin-top: 12px; }
.field-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.micro-math { font-size: 11px; color: var(--gold); margin-top: 4px; }

.toggles-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 4px; }
.toggle-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.toggle-check input { width: auto; accent-color: var(--gold); }

.drawer-actions { display: flex; gap: 10px; margin-top: 16px; }

.divider { border: none; border-top: 1px solid var(--border-soft); margin: 14px 0; }

.activity-add { display: grid; grid-template-columns: 145px 1fr auto; gap: 8px; margin-bottom: 12px; }
.activity-list, .backup-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.activity-list li, .backup-list li {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
}
.act-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--gold); margin-bottom: 3px; }

.toast {
  position: fixed;
  bottom: 22px;
  right: 26px;
  background: var(--gold-bright);
  color: #0D0C0A;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 99;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* LOGIN SCREEN */
.login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 80% 15%, rgba(200, 173, 130, 0.12), transparent 45%), var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.login-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 10px;
  min-height: 18px;
}

.user-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 1024px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .calc-grid, .tools-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .brand-header { margin-bottom: 10px; padding-bottom: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav-item { width: auto; white-space: nowrap; padding: 8px 11px; font-size: 12.5px; }
  .sidebar-footer { display: none; }
  .main { padding: 14px 14px 28px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 21px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .callsheet-paper { padding: 16px; }
  .activity-add { grid-template-columns: 1fr; }
}

@media print {
  .no-print, .drawer, .drawer-backdrop, .toast { display: none !important; }
  body { background: #ffffff; color: #111111; }
  .main { padding: 0; }
  .callsheet-paper { background: #ffffff; border: none; padding: 12px; color: #111; }
  .cs-lead-box { background: #f8f6f2; border: 1px solid #ccc; color: #111; }
  .cs-title { color: #111; }
  .muted { color: #555; }
}
