/* Raycore CRM — упрощённый интерфейс в стиле демо на сайте */
:root {
  --bg: #f4f7fc;
  --card: #ffffff;
  --soft: #f9f9fb;
  --border: #e4e4e7;
  --border-strong: #d1d1d6;
  --line: #f0f1f4;
  --text: #111118;
  --muted: #5a5a6a;
  --faint: #9090a0;
  --accent: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .08);
  --success: #15803d;
  --warning: #b45309;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: Inter, system-ui, sans-serif; font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Вход ── */
.login { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 20px; }
.login-card { width: 100%; max-width: 360px; padding: 32px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { margin-bottom: 4px; font-size: 18px; }
.login-card p { margin-bottom: 20px; color: var(--faint); }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; padding: 10px; }

/* ── Каркас ── */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100%; }
.side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; height: 100vh; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--card); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 14px; }
.brand span { font-size: 11px; color: var(--faint); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.nav:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: #eef0f4; font-size: 11px; font-weight: 600; text-align: center; color: var(--muted); }
.badge.warn { background: rgba(220, 38, 38, .1); color: var(--danger); }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-foot b { display: block; font-size: 13px; }
.side-foot span { font-size: 11px; color: var(--faint); }
.side-foot .links { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; }
.side-foot button { padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.side-foot button:hover { color: var(--accent); }
.main { min-width: 0; padding: 22px 28px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.top h1 { font-size: 22px; letter-spacing: -.3px; }
.top-act { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ── Кнопки и поля ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { border-color: var(--border); background: var(--card); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.danger { border-color: rgba(220, 38, 38, .25); background: var(--card); color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.input, .field input, .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); outline: none; }
.field textarea { min-height: 76px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { width: 240px; max-width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ── Фильтры ── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.chip { padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 12px; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toolbar .spacer { flex: 1; }

/* ── Карточки, KPI ── */
.card { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.card h3 { margin-bottom: 12px; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--card); color: inherit; }
a.kpi:hover { text-decoration: none; box-shadow: 0 6px 16px rgba(0, 0, 0, .05); }
.kpi.warn { border-left-color: var(--warning); }
.kpi.danger { border-left-color: var(--danger); }
.kpi.good { border-left-color: var(--success); }
.kpi-l { font-size: 11px; color: var(--faint); }
.kpi-v { font-size: 22px; font-weight: 700; letter-spacing: -.4px; line-height: 1.2; }
.kpi.danger .kpi-v { color: var(--danger); }
.kpi-s { font-size: 11px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; margin-bottom: 12px; }
.bar { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.bar:last-child { border-bottom: 0; }
.bar-t { height: 8px; overflow: hidden; border-radius: 4px; background: #eef0f4; }
.bar-t i { display: block; height: 100%; border-radius: 4px; }
.bar-n { text-align: right; color: var(--text); }
.bar-n b { font-weight: 700; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row.click { cursor: pointer; }
.list-row.click:hover .t { color: var(--accent); }
.list-row .t { font-weight: 500; }
.sub { display: block; font-size: 11px; color: var(--faint); }
.date { white-space: nowrap; font-size: 12px; color: var(--muted); }
.date.late { font-weight: 600; color: var(--danger); }
.date.today { font-weight: 600; color: var(--warning); }
.feed { list-style: none; }
.feed li { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--faint); }
.empty { padding: 20px; text-align: center; color: var(--faint); }

/* ── Пайплайн ── */
.board-label { margin: 4px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.col { display: flex; flex-direction: column; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--soft); transition: border-color .15s, background .15s; }
.col.over { border-color: var(--accent); background: var(--accent-soft); }
.col-h { display: flex; align-items: center; gap: 6px; padding: 2px 2px 0; font-size: 12px; font-weight: 600; }
.col-h i { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; }
.col-h span { flex: 1; min-width: 0; }
.col-h span.badge { flex: none; }
.col-sum { margin: 2px 0 8px 16px; font-size: 11px; color: var(--faint); }
.cards { display: flex; flex-direction: column; gap: 6px; min-height: 56px; }
.pcard { display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.pcard:hover, .pcard:focus-visible { border-color: #c7d2fe; box-shadow: 0 6px 14px rgba(0, 0, 0, .06); transform: translateY(-1px); outline: none; }
.pcard.dragging { opacity: .45; }
.pcard b { font-size: 12px; }
.pcard > span { font-size: 12px; color: var(--muted); }
.pcard-f { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; }
.pcard-f em { font-size: 12px; font-weight: 600; font-style: normal; color: var(--accent); }
.ava { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: #e0e7ff; color: #3730a3; font-size: 9px; font-weight: 700; font-style: normal; }
.col-empty { padding: 10px; text-align: center; font-size: 12px; color: var(--faint); }

/* ── Таблицы ── */
.table-wrap { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--soft); font-size: 11px; font-weight: 600; text-align: left; color: var(--faint); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr:hover td { background: #f7f9ff; }
td.num, th.num { text-align: right; white-space: nowrap; }
.name { font-weight: 600; color: var(--accent); }

/* ── Статусы ── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid transparent; border-radius: 5px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-blue { background: rgba(37, 99, 235, .1); color: #1d4ed8; }
.p-teal { background: rgba(13, 148, 136, .1); color: #0f766e; }
.p-violet { background: rgba(124, 58, 237, .1); color: #6d28d9; }
.p-amber { background: rgba(202, 138, 4, .12); color: #a16207; }
.p-orange { background: rgba(234, 88, 12, .1); color: #c2410c; }
.p-indigo { background: rgba(79, 70, 229, .1); color: #4338ca; }
.p-cyan { background: rgba(8, 145, 178, .1); color: #0e7490; }
.p-green { background: rgba(22, 163, 74, .1); color: #15803d; }
.p-red { background: rgba(220, 38, 38, .1); color: #b91c1c; }
.p-gray { background: #eef0f4; color: var(--muted); }

/* ── Карточка справа (drawer) и модалка ── */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .28); animation: fade .2s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; display: flex; flex-direction: column; width: min(480px, 100%); border-left: 1px solid var(--border); background: var(--card); box-shadow: -12px 0 40px rgba(15, 23, 42, .14); animation: slide .25s cubic-bezier(.16, 1, .3, 1); }
.drawer-h, .modal-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-h h2, .modal-h h2 { font-size: 16px; }
.drawer-h .sub { margin-top: 2px; }
.x { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.x:hover { background: var(--soft); color: var(--text); }
.drawer-b { flex: 1; overflow-y: auto; padding: 16px 18px 28px; }
.drawer-b h4 { margin: 20px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.mini { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.mini.click { cursor: pointer; }
.mini.click:hover { border-color: #c7d2fe; }
.modal { position: fixed; top: 50%; left: 50%; z-index: 41; display: flex; flex-direction: column; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 40px); border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: 0 24px 60px rgba(15, 23, 42, .2); transform: translate(-50%, -50%); animation: pop .2s ease; }
.modal-b { overflow-y: auto; padding: 16px 18px; }
.modal-f { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-f .right { display: flex; gap: 8px; margin-left: auto; }
.confirm-text { font-size: 14px; }

/* ── Уведомления ── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: calc(100% - 32px); pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; max-width: 380px; padding: 10px 14px; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: 0 10px 24px rgba(15, 23, 42, .25); animation: rise .2s ease; }
.toast i { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.toast.err i { background: #f87171; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ── Адаптив ── */
.sm-only { display: none; }
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
/* планшет и уже: сайдбар становится верхним меню, чтобы таблицам хватало ширины */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; flex-direction: row; flex-wrap: wrap; height: auto; padding: 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { width: 100%; padding-bottom: 8px; }
  .nav { padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; }
  .side-foot { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 8px; padding-top: 8px; }
  .side-foot .links { margin-top: 0; }
}
@media (max-width: 760px) {
  .main { padding: 16px 12px 32px; }
  th, td { padding: 8px 9px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-only { display: block; }
  .board { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .top-act { width: 100%; }
  .sm-hide { display: none; }
  .feed li { grid-template-columns: 1fr; gap: 0; }
  .bar { grid-template-columns: 90px 1fr 56px; }
}

.field[hidden] { display: none; }
