/* VALLO CRM Inteligente — identidade visual
   Grafite #2A2C2E, Laranja #F26522, tons claros. Fonte Inter (com fallback
   de sistema para não depender de rede em ambientes restritos). */

:root {
  --graphite: #2A2C2E;
  --graphite-light: #3d4043;
  --orange: #F26522;
  --orange-dark: #d6551a;
  --bg: #F5F6F7;
  --surface: #FFFFFF;
  --border: #E3E5E8;
  --text: #23262b;
  --text-muted: #6b7280;
  --success: #1f9d55;
  --warning: #d9a300;
  --danger: #d64545;
  --info: #2f6fed;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --sidebar-w: 236px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 600; color: var(--graphite); }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
#app-shell { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--graphite);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  transition: transform .2s ease;
}
#sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
#sidebar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); flex-shrink:0; }
#sidebar .brand span { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
#sidebar nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
#sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 6px; color: rgba(255,255,255,.78);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
}
#sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#sidebar nav a.active { background: var(--orange); color: #fff; }
#sidebar nav a .icon { width: 18px; text-align: center; opacity: .9; }
#sidebar .side-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: rgba(255,255,255,.5); }

#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#topbar {
  height: 58px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
#topbar .page-title { font-weight: 600; font-size: 16px; color: var(--graphite); }
#topbar .user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; }
#topbar .user-menu .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--orange);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
#menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--graphite); }

#content { padding: 20px; flex: 1; }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--graphite); }
.kpi .value.orange { color: var(--orange); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; background: var(--graphite); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--orange); }
.btn.secondary { background: #fff; color: var(--graphite); border-color: var(--border); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--graphite); border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
.input:focus, select.input:focus, textarea.input:focus { outline: 2px solid rgba(242,101,34,.25); border-color: var(--orange); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--graphite-light); }
.field-row { display: flex; gap: 12px; }
.field-row > label.field { flex: 1; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; padding: 9px 10px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover { background: #FAFAFB; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.open { background: #e8f0fe; color: var(--info); }
.badge.won { background: #e6f7ec; color: var(--success); }
.badge.lost { background: #fdeaea; color: var(--danger); }
.badge.gray { background: #eef0f1; color: var(--text-muted); }

.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--graphite); color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; max-width: 340px; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,20,22,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 16px; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px; box-shadow: var(--shadow); }
.modal.wide { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--orange); border-bottom-color: var(--orange); }

.filters-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters-bar .input, .filters-bar select { width: auto; min-width: 140px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 12.5px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.15); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; gap: 8px; color: var(--text-muted); padding: 20px; }

/* ---------- Kanban ---------- */
#board-wrap { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.board-col { background: #EDEEF0; border-radius: var(--radius); width: 280px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.board-col-header { padding: 10px 12px; border-bottom: 2px solid; font-size: 12.5px; }
.board-col-header .name { font-weight: 700; color: var(--graphite); }
.board-col-header .totals { display: flex; justify-content: space-between; margin-top: 4px; color: var(--text-muted); font-size: 11.5px; }
.board-col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.opp-card {
  background: #fff; border-radius: 6px; padding: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.08);
  cursor: grab; border-left: 3px solid var(--orange); font-size: 12.5px;
}
.opp-card:active { cursor: grabbing; }
.opp-card.sortable-ghost { opacity: .4; }
.opp-card .title { font-weight: 700; color: var(--graphite); margin-bottom: 2px; }
.opp-card .company { color: var(--text-muted); margin-bottom: 6px; }
.opp-card .meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }
.opp-card .value { font-weight: 700; color: var(--graphite); }
.opp-card .overdue { color: var(--danger); font-weight: 700; }
.opp-card .prio-alta, .opp-card .prio-urgente { border-left-color: var(--danger); }

/* ---------- Login ---------- */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--graphite); }
#login-screen .box { background: #fff; padding: 34px 32px; border-radius: 10px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
#login-screen .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
#login-screen .logo .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--orange); }
#login-screen .logo span { font-weight: 800; font-size: 19px; color: var(--graphite); }
#login-screen .error-msg { color: var(--danger); font-size: 12.5px; margin-top: 8px; min-height: 16px; }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  #menu-toggle { display: block; }
  .board-col { width: 250px; }
}

.sr-only { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
