/* ====== Техно Шоп CRM ====== */
:root {
  --bg: #07090f;
  --bg-2: #0b0f17;
  --card: #10151e;
  --card-2: #151b26;
  --line: #1e2633;
  --line-2: #2a3444;
  --text: #e9eef6;
  --muted: #7f8a9c;
  --accent: #00d4ff;
  --accent-2: #7c5cff;
  --grad: linear-gradient(135deg, #00d4ff 0%, #7c5cff 100%);
  --ok: #22d39a;
  --warn: #ffb547;
  --danger: #ff4d6a;
  --radius: 14px;
  --side: 248px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(124, 92, 255, .12), transparent 60%),
    radial-gradient(700px 400px at 20% -20%, rgba(0, 212, 255, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.5 "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--accent); }
h1 { font: 700 26px/1.2 "Unbounded", "Manrope", sans-serif; letter-spacing: -.01em; margin: 0 0 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 16px; font-weight: 700; margin: 20px 0 12px; letter-spacing: .01em; }
h2:first-child { margin-top: 0; }
::selection { background: rgba(0, 212, 255, .3); }

/* ---------- Каркас ---------- */
body.app { padding-left: var(--side); }
main { max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }

.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 20;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; background: rgba(11, 15, 23, .92); backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 0 24px rgba(0, 212, 255, .35);
}
.logo-mark svg { width: 20px; height: 20px; fill: #07090f; }
.logo-text { font: 700 15px/1.1 "Unbounded", sans-serif; letter-spacing: .02em; }
.logo-text small {
  display: block; margin-top: 3px; font: 600 10px/1 "Manrope", sans-serif; letter-spacing: .28em; color: var(--accent);
}
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; position: relative;
}
.side nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.side nav a.active { color: var(--text); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.side nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.side nav a.active .ico { color: var(--accent); }
.ico { width: 20px; height: 20px; flex: none; }
.count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 20px; text-align: center;
  font-size: 12px; background: var(--accent); color: #07090f;
}
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-user .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side-user a { color: var(--muted); display: grid; }
.side-user a:hover { color: var(--danger); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: var(--card-2); border: 1px solid var(--line-2); color: var(--accent);
}

/* ---------- Блоки ---------- */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
}
.muted { color: var(--muted); font-size: 13px; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 48px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.flash, .error { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.flash { background: rgba(34, 211, 154, .1); color: var(--ok); border: 1px solid rgba(34, 211, 154, .25); }
.error { background: rgba(255, 77, 106, .1); color: var(--danger); border: 1px solid rgba(255, 77, 106, .25); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  position: relative; overflow: hidden; padding: 18px 20px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%); border: 1px solid var(--line);
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: .7;
}
.stat b { display: block; font: 700 26px/1.2 "Unbounded", sans-serif; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat.accent b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a {
  --c: var(--accent);
  padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.tabs a i { font-style: normal; margin-left: 6px; opacity: .7; }
.tabs a:hover { color: var(--text); border-color: var(--line-2); text-decoration: none; }
.tabs a.active {
  color: var(--text); border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--card));
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 25%, transparent);
}

.search { display: flex; gap: 10px; margin-bottom: 18px; }
.search input[name=q] { flex: 1; }

/* ---------- Формы ---------- */
input, select, textarea {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #566174; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 212, 255, .15);
}
input[readonly] { color: var(--muted); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
label input, label select, label textarea, label .copy { margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.links { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); border-color: transparent; color: #07090f; box-shadow: 0 6px 22px rgba(0, 212, 255, .25); }
.btn.primary:hover { box-shadow: 0 8px 28px rgba(0, 212, 255, .4); }
.btn.danger { color: var(--danger); background: transparent; border-color: rgba(255, 77, 106, .3); }
.btn.danger:hover { background: rgba(255, 77, 106, .08); border-color: var(--danger); }
.actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.copy { display: flex; gap: 8px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; background: var(--bg-2); }
.list tbody tr { cursor: pointer; transition: background .12s; }
.list tbody tr:hover { background: var(--card-2); }
.list tbody tr:last-child td { border-bottom: 0; }
.list td:first-child a { font-weight: 700; }

.badge {
  --c: #999;
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.src { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.src.avito { color: #00aaff; border-color: rgba(0, 170, 255, .3); }
.src.tilda { color: #ff8562; border-color: rgba(255, 133, 98, .3); }

/* ---------- Заявка ---------- */
.head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.history { list-style: none; padding: 0; margin: 14px 0 0; }
.history li { padding: 12px 0; border-top: 1px solid var(--line); word-wrap: break-word; }
.history li.from-client { border-left: 2px solid #00aaff; padding-left: 12px; }
.history li.from-us { border-left: 2px solid var(--accent-2); padding-left: 12px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.avito-reply { border-color: rgba(0, 170, 255, .35); }
.avito-reply h2 { color: #00aaff; }

/* ---------- Интеграции ---------- */
.integrations { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.integration form { margin-bottom: 12px; }
.int-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.int-head h2 { margin: 0; }
.int-head .pill { margin-left: auto; }
.int-logo { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font: 800 20px "Unbounded", sans-serif; }
.int-logo.tilda { background: #ff8562; color: #fff; }
.int-logo.tg { background: #2aabee; color: #fff; font-size: 18px; }
.int-logo.avito { background: #fff; grid-template-columns: 1fr 1fr; gap: 3px; padding: 11px; }
.int-logo.avito i { border-radius: 50%; }
.int-logo.avito i:nth-child(1) { background: #00aaff; }
.int-logo.avito i:nth-child(2) { background: #97cf26; }
.int-logo.avito i:nth-child(3) { background: #ff6163; }
.int-logo.avito i:nth-child(4) { background: #a169f7; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line-2); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: rgba(34, 211, 154, .35); background: rgba(34, 211, 154, .08); }
.pill.warn { color: var(--warn); border-color: rgba(255, 181, 71, .35); background: rgba(255, 181, 71, .08); }
.steps { margin: 16px 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--text); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

/* ---------- Вход ---------- */
body.guest { display: grid; place-items: center; }
.login { width: min(400px, calc(100vw - 32px)); margin: 40px auto; padding: 32px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 212, 255, .08); }
.login .logo { justify-content: center; padding: 0 0 24px; }
.login .btn { width: 100%; margin-top: 6px; }

/* ---------- Мобильные ---------- */
@media (max-width: 900px) {
  body.app { padding-left: 0; padding-bottom: 70px; }
  main { padding: 18px 16px 40px; }
  .side {
    inset: auto 0 0 0; width: auto; height: 64px; flex-direction: row; align-items: center;
    padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line);
  }
  .side .logo, .side-user .name, .side-user .avatar { display: none; }
  .side nav { flex-direction: row; justify-content: space-around; }
  .side nav a { flex-direction: column; gap: 3px; padding: 6px 8px; font-size: 11px; }
  .side nav a.active::before { display: none; }
  .side nav a .count { position: absolute; top: 0; right: 4px; margin: 0; min-width: 18px; padding: 0 5px; font-size: 10px; }
  .side-user { border: 0; padding: 0 8px; }
  .grid, .row { grid-template-columns: 1fr; gap: 0; }
  .integrations { grid-template-columns: 1fr; }
  h1 { font-size: 21px; }
  .list th:nth-child(2), .list td:nth-child(2), .list th:nth-child(6), .list td:nth-child(6) { display: none; }
}

/* ---------- Звуковое уведомление о новых заявках ---------- */
.sound-unlock {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--accent);
  background: var(--card-2); color: var(--text); font: 700 14px "Manrope", sans-serif; cursor: pointer;
  box-shadow: 0 0 0 0 rgba(0, 212, 255, .5); animation: pulse 2s infinite;
}
.sound-unlock[hidden], .new-alert[hidden] { display: none; }
.alerts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none;
}
.new-alert {
  position: relative; pointer-events: auto;
  display: flex; flex-direction: column; gap: 2px; min-width: 320px; max-width: calc(100vw - 32px);
  padding: 12px 20px 12px 46px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, #ff3b5c, #ff7a45);
  box-shadow: 0 12px 40px rgba(255, 59, 92, .45);
  animation: alert-shake 5s infinite;
}
.new-alert::before { content: "🔔"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; }
.new-alert:hover { text-decoration: none; filter: brightness(1.05); }
.new-alert > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.new-alert b { font-size: 15px; }
.new-alert span { font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 212, 255, .5); }
  70% { box-shadow: 0 0 0 14px rgba(0, 212, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
}
@keyframes alert-shake {
  0%, 12%, 100% { transform: rotate(0); }
  2%, 6%, 10% { transform: rotate(-2deg); }
  4%, 8% { transform: rotate(2deg); }
}
@media (max-width: 900px) {
  .sound-unlock { bottom: 80px; right: 12px; left: 12px; }
  .alerts { top: 10px; }
  .new-alert { min-width: 0; width: calc(100vw - 24px); }
}

/* ---------- Чат Авито ---------- */
.avito-chat { border-color: rgba(0, 170, 255, .35); padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; }
.chat-head .muted { margin-left: auto; font-size: 12px; }
.int-logo.sm { width: 28px; height: 28px; padding: 7px; gap: 2px; border-radius: 8px; }
.chat-box {
  height: 420px; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
  background: radial-gradient(400px 200px at 100% 0, rgba(0, 170, 255, .06), transparent), var(--bg);
}
.chat-day { align-self: center; font-size: 11px; color: var(--muted); background: var(--card-2); padding: 2px 10px; border-radius: 10px; margin: 8px 0; }
.chat-empty, .chat-error { margin: auto; color: var(--muted); text-align: center; font-size: 14px; }
.chat-error { color: var(--danger); }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.sys { align-self: center; max-width: 90%; }
.bubble { padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg.in .bubble { background: var(--card-2); border: 1px solid var(--line-2); border-bottom-left-radius: 4px; }
.msg.out .bubble { background: linear-gradient(135deg, #0a84ff, #00aaff); color: #fff; border-bottom-right-radius: 4px; }
.msg.sys .bubble { background: transparent; color: var(--muted); font-size: 12px; text-align: center; }
.bubble img { display: block; max-width: 220px; border-radius: 10px; }
.msg .time { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.msg .read { color: var(--accent); }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form textarea { resize: none; margin: 0; }
@media (max-width: 900px) { .chat-box { height: 60vh; } }
details.card summary { cursor: pointer; font-weight: 700; }
.log { white-space: pre-wrap; font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--muted); margin: 12px 0 0; max-height: 300px; overflow: auto; }

.msg-alert { background: linear-gradient(135deg, #0a84ff, #00aaff); box-shadow: 0 12px 40px rgba(0, 170, 255, .45); }
.msg-alert::before { content: "💬"; }
.unread {
  display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(0, 170, 255, .15); color: #00aaff; border: 1px solid rgba(0, 170, 255, .35); white-space: nowrap;
}

/* ---------- Аватары ---------- */
.ava {
  position: relative; flex: none; display: inline-grid; place-items: center; overflow: hidden; border-radius: 50%;
  background: linear-gradient(135deg, #1b2433, #232e40); border: 2px solid var(--line-2); color: var(--accent);
  font-weight: 800; vertical-align: middle;
}
.ava i { font-style: normal; }
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ava-sm { width: 36px; height: 36px; font-size: 15px; }
.ava-md { width: 48px; height: 48px; font-size: 19px; }
.ava-lg { width: 64px; height: 64px; font-size: 26px; }
.ava-xl { width: 128px; height: 128px; font-size: 48px; border-width: 3px; border-color: #00aaff; box-shadow: 0 0 0 4px rgba(0, 170, 255, .15), 0 10px 30px rgba(0, 0, 0, .4); }
a:hover .ava-xl { box-shadow: 0 0 0 6px rgba(0, 170, 255, .3), 0 10px 30px rgba(0, 0, 0, .4); }
.who { display: flex; align-items: center; gap: 10px; }
.buyer {
  display: flex; align-items: center; gap: 20px; margin-bottom: 18px; padding: 16px;
  border-radius: var(--radius); background: rgba(0, 170, 255, .06); border: 1px solid rgba(0, 170, 255, .25);
}
.buyer > a:hover { text-decoration: none; }
.buyer-name { font: 700 20px/1.2 "Unbounded", sans-serif; margin-bottom: 2px; word-break: break-word; }
.avito-btn { margin-top: 10px; color: #00aaff; border-color: rgba(0, 170, 255, .4); }
.avito-btn:hover { border-color: #00aaff; background: rgba(0, 170, 255, .08); }
h1 .avito-btn { margin-top: 0; font-size: 14px; font-family: "Manrope", sans-serif; }
.chat-head .ava { width: 44px; height: 44px; }
.chat-head h2 { font-size: 15px; }
.chat-head a.muted { font-size: 12px; color: #00aaff; }
.new-alert.has-ava { flex-direction: row; align-items: center; gap: 12px; padding-left: 12px; }
.new-alert.has-ava::before { display: none; }
.alert-ava { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, .8); flex: none; }
@media (max-width: 900px) {
  .buyer { gap: 14px; }
  .ava-xl { width: 96px; height: 96px; font-size: 38px; }
  .buyer-name { font-size: 17px; }
}
