/* AI Business Box — фирменная палитра (фиолетовый акцент) + базовый слой оформления.
   Шкала отступов: 4 / 8 / 12 / 16 / 24 / 32 / 48. */
:root {
  --purple: #6C4CE0;
  --purple-dark: #5636C0;
  --purple-light: #F1EDFC;
  --purple-border: #DAD1F5;
  --ink: #17171C;
  --text: #33333D;
  --muted: #70707D;
  --bg: #F5F4F9;
  --card-bg: #F4F3F8;
  --border: #E5E3ED;
  --hover: #F6F5FB;
  --white: #FFFFFF;
  --success: #1F9254;
  --success-bg: #EAF7EF;
  --danger: #D23C3C;
  --danger-bg: #FCEDED;
  --blue: #2563EB;
  --blue-bg: #E8F0FE;
  --yellow: #9A6B00;
  --yellow-bg: #FBF0D9;
  --shadow: 0 1px 3px rgba(23,23,28,0.06);
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- раскладка */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
  z-index: 10;
}

.content {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  padding: 32px;
  max-width: 1280px;
}

/* --- бренд в сайдбаре --- */
.sidebar-brand { display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 16px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: var(--white); font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--muted); }

/* --- меню --- */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--hover); color: var(--purple-dark); }
.nav-item.active { background: var(--purple-light); color: var(--purple-dark); }
.nav-ico { display: inline-flex; color: var(--muted); }
.nav-item.active .nav-ico, .nav-item:hover .nav-ico { color: var(--purple-dark); }
/* «Ещё» — редко нужные разделы, только у администратора */
.nav-more { display: flex; flex-direction: column; gap: 2px; }
.nav-more > summary { list-style: none; cursor: pointer; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > a.nav-item { padding-left: 26px; }

/* ---------------------------------------------------------------- типографика */
h1 { color: var(--ink); font-size: 23px; font-weight: 700; margin: 0 0 20px; }
h2 { color: var(--ink); font-size: 18px; font-weight: 700; margin: 32px 0 12px; }
h3 { color: var(--ink); font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
h2:first-of-type { margin-top: 0; }
p { margin: 0 0 12px; }
small { font-size: 12px; }
.muted, small { color: var(--muted); }
a { color: var(--purple-dark); }

/* ---------------------------------------------------------------- карточки */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

/* плитки счётчиков */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile {
  background: var(--white); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------- таблицы */
table {
  border-collapse: collapse; width: 100%;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
th, td { border-bottom: 1px solid var(--border); padding: 12px 14px; text-align: left; font-size: 14px; }
th { background: var(--card-bg); color: var(--ink); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: var(--hover); }
td a { color: var(--purple-dark); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- бейджи статусов */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--card-bg); color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-grey   { background: #ECECF1; color: #5A5A66; }
.badge-blue   { background: var(--blue-bg); color: var(--blue); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-red    { background: var(--danger-bg); color: var(--danger); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-purple { background: var(--purple-light); color: var(--purple-dark); }

.error { color: var(--danger); }
.ok { color: var(--success); }

/* ---------------------------------------------------------------- формы / кнопки */
form.inline { display: inline; }

.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

label { font-size: 14px; }

select, input[type=text], input[type=date], input[type=password], input[type=file] {
  font-family: inherit; font-size: 14px; padding: 8px 10px; height: 38px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); color: var(--text);
}
textarea {
  width: 100%; min-height: 140px; font-family: inherit; font-size: 14px;
  padding: 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); color: var(--text);
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-light);
}

button, .btn-link {
  cursor: pointer; padding: 8px 16px; height: 38px; border-radius: 8px; border: none;
  background: var(--purple); color: var(--white);
  font-weight: 600; font-size: 14px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
button:hover, .btn-link:hover { background: var(--purple-dark); }

a.secondary, button.secondary {
  background: var(--white); color: var(--purple-dark); border: 1px solid var(--purple-border);
}
a.secondary:hover, button.secondary:hover { background: var(--purple-light); }

a.btn-text, button.btn-text {
  background: none; color: var(--purple-dark); border: none; padding: 8px 10px;
}
a.btn-text:hover, button.btn-text:hover { background: var(--purple-light); }

a.danger, button.danger {
  background: var(--white); color: var(--danger); border: 1px solid var(--danger);
}
a.danger:hover, button.danger:hover { background: var(--danger-bg); }

.filters { margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- пустые состояния */
.empty { color: var(--muted); padding: 28px 16px; text-align: center; font-size: 14px; }
.empty a { font-weight: 600; }

/* ---------------------------------------------------------------- карточки сообщений */
.msg-card { border: 1px solid var(--border); background: var(--white); border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.msg-card.approved { border-color: var(--success); }
.msg-card.sent { border-color: var(--purple); }

/* --- переписка --- */
.conv-out { text-align: right; margin: 8px 0; }
.conv-in { text-align: left; margin: 8px 0; }
.conv-bubble { display: inline-block; padding: 10px 14px; border-radius: 12px; background: var(--purple-light); color: var(--ink); max-width: 70%; }
.conv-in .conv-bubble { background: var(--card-bg); }

/* --- страница ошибки --- */
.error-box { text-align: center; padding: 60px 20px; }
.error-code { font-size: 56px; font-weight: 800; color: var(--purple); }
.error-detail { color: var(--muted); font-size: 16px; margin: 10px 0 24px; }

/* --- пагинация --- */
.pagination { display: flex; gap: 12px; align-items: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.pagination a { color: var(--purple-dark); font-weight: 600; text-decoration: none; }
.pagination a:hover { text-decoration: underline; }
.page-size { margin-left: auto; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.page-size select { font-size: 13px; padding: 2px 6px; }

/* --- бейдж режима работы (в сайдбаре под названием) --- */
.mode-badge { display: inline-block; margin-top: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; white-space: nowrap; }
.mode-badge-dry { color: var(--muted); }
.mode-badge-live { color: #fff; background: #c1121f; padding: 2px 7px; border-radius: 999px; }

/* --- крупный баннер рабочего режима (на каждой странице поверх контента) --- */
.live-banner {
  background: #c1121f; color: #fff; font-weight: 800; font-size: 16px;
  letter-spacing: 0.3px; text-align: center; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 18px; box-shadow: 0 2px 8px rgba(193, 18, 31, 0.35);
  position: sticky; top: 0; z-index: 50;
}

/* --- адаптив: узкие окна --- */
@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { margin: 0; border: none; padding: 0; }
  .content { margin-left: 0; padding: 20px; }
  .nav-item span:not(.nav-ico) { display: none; }
}
