/* HTE CRM — главный стиль (Inter + чёрно-серая палитра + жёлтый акцент SDLG) */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e5e5e3;
  --text: #0a0a0a;
  --muted: #888;
  --muted-2: #555;
  --accent: #FFC72C;        /* SDLG yellow */
  --accent-dark: #d9a700;
  --danger: #dc2626;
  --success: #16a34a;
  --info: #3b82f6;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 12px; }
.err { background: #fee; border: 1px solid #fcc; color: #c00; padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 13px; }
.ok  { background: #efe; border: 1px solid #cfc; color: #060; padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 13px; }

/* AUTH */
.auth-bg { background: linear-gradient(135deg, #0a0a0a 0%, #2a2a2a 100%); display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--surface); border-radius: 18px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.auth-card .logo { font-weight: 600; letter-spacing: -0.02em; margin-bottom: 24px; font-size: 14px; }
.auth-card .logo .dot { color: var(--accent); }
.auth-card h1 { font-size: 24px; letter-spacing: -0.02em; margin-bottom: 20px; }
.auth-card label { display: block; font-size: 12px; color: var(--muted-2); margin: 14px 0 6px; }
.auth-card input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,199,44,.3); }
.auth-card button { width: 100%; background: var(--text); color: #fff; border: none; padding: 12px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 20px; }
.auth-card button:hover { background: #333; }
.auth-card .muted { margin-top: 24px; text-align: center; }

/* APP LAYOUT */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #0a0a0a; color: #ddd; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 6px 22px 22px; font-weight: 600; letter-spacing: -0.02em; font-size: 16px; }
.sidebar .brand .dot { color: var(--accent); }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 22px; color: #aaa; font-size: 14px; }
.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,199,44,.12); color: var(--accent); border-left: 3px solid var(--accent); padding-left: 19px; }
.sidebar .badge { margin-left: auto; background: var(--accent); color: #000; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.sidebar .group-title { font-size: 11px; color: #555; padding: 14px 22px 6px; letter-spacing: 0.1em; }

.main { padding: 24px 32px; max-width: 1400px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { font-size: 24px; letter-spacing: -0.02em; }
.topbar .user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.topbar .user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 600; color: #000; font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-h h2 { font-size: 16px; letter-spacing: -0.01em; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--text); color: #fff; border: none; padding: 10px 18px; border-radius: 100px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; }
.btn:hover { background: #333; text-decoration: none; }
.btn.outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.outline:hover { background: var(--bg); }
.btn.accent { background: var(--accent); color: #000; }
.btn.accent:hover { background: var(--accent-dark); }
.btn.sm { padding: 6px 12px; font-size: 12px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted-2); padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
table.t td { padding: 12px; border-bottom: 1px solid var(--border); }
table.t tr:hover td { background: var(--bg); cursor: pointer; }

/* STATS */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .label { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.stat .delta { font-size: 12px; color: var(--success); margin-top: 4px; }
.stat .delta.down { color: var(--danger); }

/* PIPELINE */
.pipeline { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.pipe-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 300px; }
.pipe-col h3 { font-size: 12px; color: var(--muted-2); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 12px; display: flex; justify-content: space-between; }
.pipe-col h3 .count { background: var(--bg); padding: 1px 8px; border-radius: 10px; font-weight: 600; color: var(--text); }
.deal-card { background: var(--bg); padding: 12px; border-radius: 8px; margin-bottom: 8px; cursor: pointer; border: 1px solid transparent; }
.deal-card:hover { border-color: var(--border); }
.deal-card .title { font-weight: 500; font-size: 13px; }
.deal-card .meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }
.deal-card .amount { font-weight: 600; color: var(--text); }

/* INBOX */
.inbox { display: grid; grid-template-columns: 320px 1fr 320px; gap: 0; height: calc(100vh - 80px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.inbox-list { border-right: 1px solid var(--border); overflow-y: auto; }
.inbox-list .chat { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox-list .chat:hover { background: var(--bg); }
.inbox-list .chat.active { background: rgba(255,199,44,.08); border-left: 3px solid var(--accent); padding-left: 13px; }
.inbox-list .chat .row { display: flex; justify-content: space-between; align-items: center; }
.inbox-list .chat .name { font-weight: 500; font-size: 13px; }
.inbox-list .chat .time { font-size: 11px; color: var(--muted); }
.inbox-list .chat .preview { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-list .chat .ch-tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: 6px; vertical-align: middle; }
.ch-telegram { background: #229ED9; color: #fff; }
.ch-viber    { background: #7360F2; color: #fff; }
.ch-email    { background: #ea4335; color: #fff; }
.ch-web      { background: #888; color: #fff; }
.ch-999md    { background: #ff7400; color: #fff; }

.inbox-thread { display: flex; flex-direction: column; }
.thread-h { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.thread-msgs { flex: 1; overflow-y: auto; padding: 16px 20px; }
.thread-msg { margin-bottom: 12px; max-width: 70%; }
.thread-msg.in  { margin-right: auto; }
.thread-msg.out { margin-left: auto; text-align: right; }
.thread-msg .bubble { display: inline-block; padding: 9px 14px; border-radius: 14px; font-size: 13px; }
.thread-msg.in  .bubble { background: var(--bg); border-bottom-left-radius: 4px; text-align: left; }
.thread-msg.out .bubble { background: var(--text); color: #fff; border-bottom-right-radius: 4px; text-align: left; }
.thread-msg.ai  .bubble { background: rgba(255,199,44,.15); border: 1px solid var(--accent); border-bottom-right-radius: 4px; color: var(--text); }
.thread-msg .meta { font-size: 10px; color: var(--muted); margin-top: 3px; }
.thread-input { border-top: 1px solid var(--border); padding: 12px 20px; display: flex; gap: 8px; }
.thread-input textarea { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 10px; resize: none; height: 60px; font-family: inherit; font-size: 13px; }

.inbox-side { border-left: 1px solid var(--border); overflow-y: auto; padding: 16px; }
.inbox-side h3 { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.inbox-side .ai-block { background: rgba(255,199,44,.08); border: 1px solid var(--accent); border-radius: 8px; padding: 12px; font-size: 12px; margin-bottom: 16px; }
.inbox-side .ai-block .label { font-size: 10px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; font-weight: 600; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list, .inbox-side { display: none; }
}
