:root {
  --bg: #f4f6fa; --panel: #ffffff; --ink: #1c2333; --muted: #6b7488;
  --brand: #3454d1; --brand-dark: #27409e; --accent: #12b886; --danger: #e03131; --warn: #f08c00;
  --border: #e3e7ef; --radius: 10px; --shadow: 0 1px 3px rgba(20,30,60,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 8px 14px; background: var(--brand); color: #fff; }
button:hover { background: var(--brand-dark); }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button.ghost:hover { background: #eef1fb; }
button.small { padding: 4px 10px; font-size: 12.5px; }
button.danger { background: var(--danger); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }

/* layout */
#app { display: flex; min-height: 100vh; }
aside { width: 210px; background: #101733; color: #cdd5ee; padding: 18px 12px; flex-shrink: 0; }
aside .logo { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 22px; padding-left: 8px; }
aside .logo span { color: #7b96ff; }
aside nav a { display: block; color: #cdd5ee; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
aside nav a:hover { background: #1c2649; color: #fff; }
aside nav a.active { background: var(--brand); color: #fff; }
aside .whoami { margin-top: 26px; font-size: 12px; color: #8d97ba; padding-left: 8px; }
main { flex: 1; padding: 24px 30px; max-width: 1280px; }
h1 { font-size: 21px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 20px 0 10px; }

/* components */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .num { font-size: 22px; font-weight: 700; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { background: #f8f9fc; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tr:hover td { background: #f8faff; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: #eef1fb; color: var(--brand); }
.badge.lead { background: #fff3e2; color: #d9760c; }
.badge.customer, .badge.won, .badge.paid, .badge.done, .badge.solved { background: #e3f7ef; color: #0f8a63; }
.badge.lost, .badge.overdue, .badge.urgent, .badge.high { background: #fdeaea; color: var(--danger); }
.badge.prospect, .badge.sent, .badge.open { background: #e7effd; color: var(--brand); }

/* kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.kcol { background: #eceff6; border-radius: var(--radius); padding: 10px; min-width: 215px; width: 215px; flex-shrink: 0; }
.kcol h3 { font-size: 12.5px; text-transform: uppercase; color: var(--muted); margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.kcol.dragover { outline: 2px dashed var(--brand); }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard .val { color: var(--accent); font-weight: 700; font-size: 13px; }
.kcard .who { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 9px 0 9px 20px; border-left: 2px solid var(--border); margin-left: 8px; position: relative; }
.timeline li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); position: absolute; left: -5.5px; top: 14px; }
.timeline .t-when { color: var(--muted); font-size: 11.5px; }
.timeline .t-title { font-weight: 600; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(12,18,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 480px; max-width: 94vw; max-height: 88vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #101733, #27409e); width: 100%; }
.auth-card { background: #fff; padding: 34px; border-radius: 14px; width: 380px; }
.auth-card .logo { font-size: 24px; font-weight: 800; margin-bottom: 18px; }
.auth-card .logo span { color: var(--brand); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { background: none; color: var(--muted); border-radius: 8px 8px 0 0; padding: 8px 14px; }
.tabs button.active { color: var(--brand); font-weight: 700; box-shadow: inset 0 -2px 0 var(--brand); }
.muted { color: var(--muted); font-size: 12.5px; }
.ai-result { background: #f2f6ff; border: 1px solid #d5e2ff; border-radius: 8px; padding: 12px; white-space: pre-wrap; margin-top: 10px; font-size: 13px; }
.flex { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } aside { width: 64px; } aside .logo, aside .whoami, aside nav a .txt { display: none; } }
.toast { position: fixed; bottom: 20px; right: 20px; background: #101733; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 99; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
