/* Crossblade Management System — theme.
   Swap the hex codes below to match your exact brand. Everything is driven by CSS variables. */
:root {
  --bg: #0b0f17;
  --surface: #131927;
  --surface-2: #1c2336;
  --border: #2a3147;
  --text: #e8ecf3;
  --muted: #8b93a7;
  --accent: #ff5b3a;
  --accent-2: #ffa362;
  --success: #2ecc71;
  --warn: #ffb020;
  --danger: #ff4757;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #0b0f17; font-weight: 800;
}
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-tag { font-size: 11px; color: var(--muted); }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--text);
  font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--accent); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 14px 8px 6px; }

.main { padding: 24px 28px 40px; max-width: 1280px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.user-pill { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.user-pill .who { color: var(--text); font-weight: 600; }

/* Cards */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 15px; letter-spacing: .2px; color: var(--text); }
.card .desc { color: var(--muted); font-size: 13px; }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.kpi .value { font-size: 28px; font-weight: 800; }
.kpi .accent { color: var(--accent); }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.tbl th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
table.tbl tr:hover td { background: var(--surface-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 13px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text);
  transition: background .12s, transform .05s;
}
.btn:hover { background: #232b41; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #1a0a04; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Badges */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.new { color: var(--accent); border-color: rgba(255,91,58,.3); }
.badge.contacted { color: #4dabf7; border-color: rgba(77,171,247,.3); }
.badge.qualified { color: #ffd166; border-color: rgba(255,209,102,.3); }
.badge.converted { color: var(--success); border-color: rgba(46,204,113,.3); }
.badge.lost { color: var(--danger); border-color: rgba(255,71,87,.3); }
.badge.role-admin { color: var(--accent); }
.badge.role-ops_head { color: #4dabf7; }

/* Lead detail two-col */
.detail { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .detail { grid-template-columns: 1fr; } }

/* Login */
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1200px 800px at 70% 10%, rgba(255,91,58,.18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 14px 0 4px; font-size: 22px; }
.login-card p.sub { color: var(--muted); margin: 0 0 18px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.flash.success { background: rgba(46,204,113,.12); color: var(--success); border: 1px solid rgba(46,204,113,.3); }
.flash.error { background: rgba(255,71,87,.12); color: var(--danger); border: 1px solid rgba(255,71,87,.3); }

/* Misc */
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.note-item { padding: 12px; background: var(--surface-2); border-radius: 8px; margin-bottom: 10px; }
.note-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.attach { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.attach .icon { width: 28px; height: 28px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; }

.search { position: relative; max-width: 320px; flex: 1; }
.search input { padding-left: 34px; }
.search::before { content: "🔎"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: .5; font-size: 13px; }

hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* AI assistant — floating bottom-right button + slide-over panel */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0a04; border: none; border-radius: 99px; padding: 12px 18px;
  font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(255,91,58,.35), 0 2px 6px rgba(0,0,0,.4);
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .12s;
}
.ai-fab:hover { transform: translateY(-1px); }
.ai-fab .ai-spark { font-size: 16px; }

.ai-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 420px; max-width: 96vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0,0,0,.4);
  z-index: 60; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s ease-out;
}
.ai-panel.open { transform: translateX(0); }
.ai-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.ai-header h3 { margin: 0; font-size: 15px; }
.ai-header .ai-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0f17; display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.ai-close { margin-left: auto; background: transparent; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.ai-close:hover { color: var(--text); }

.ai-quick { padding: 10px 14px; display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ai-quick button {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 99px; padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.ai-quick button:hover { border-color: var(--accent); color: var(--accent); }

.ai-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { padding: 10px 12px; border-radius: 10px; max-width: 92%; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.ai-msg.user { align-self: flex-end; background: var(--accent); color: #1a0a04; border-bottom-right-radius: 2px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.ai-msg.bot.error { border-color: rgba(255,71,87,.5); color: var(--danger); }
.ai-msg .who { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; opacity: .7; margin-bottom: 4px; }
.ai-typing { color: var(--muted); font-style: italic; font-size: 12px; padding: 0 16px 6px; }

.ai-input { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-input textarea {
  flex: 1; min-height: 42px; max-height: 120px; resize: none;
  font-size: 13px; padding: 9px 11px;
}
.ai-input button { padding: 8px 14px; }

.ai-disabled { padding: 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.ai-disabled strong { color: var(--text); }
.ai-empty { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }

@media (max-width: 700px) {
  .ai-panel { width: 100%; }
  .ai-fab { right: 14px; bottom: 14px; padding: 10px 14px; }
}
