@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Public+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root{
  --paper:#F2F4F3;
  --surface:#FFFFFF;
  --surface-alt:#F7F9F8;
  --ink:#16191B;
  --ink-soft:#454E52;
  --muted:#7A8489;
  --line:#DEE3E1;
  --accent:#1C6E7F;
  --accent-strong:#144F5C;
  --accent-soft:#DEEFF0;
  --good:#2F9E58;
  --good-soft:#E4F4EA;
  --warn:#C77D18;
  --warn-soft:#FBEEDD;
  --bad:#C0392B;
  --bad-soft:#FBE5E2;
  --radius:12px;
  --shadow:0 1px 2px rgba(20,30,32,.04), 0 8px 24px -12px rgba(20,30,32,.10);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#14171A; --surface:#1C2124; --surface-alt:#20262A;
    --ink:#EEF1F1; --ink-soft:#C2CACD; --muted:#889196; --line:#2B3236;
    --accent:#4FB4C4; --accent-strong:#7ACBD8; --accent-soft:#1E3236;
    --good:#5CC584; --good-soft:#1A3324; --warn:#E3A64C; --warn-soft:#332510;
    --bad:#E0685A; --bad-soft:#3A1F1B;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"]{
  --paper:#14171A; --surface:#1C2124; --surface-alt:#20262A;
  --ink:#EEF1F1; --ink-soft:#C2CACD; --muted:#889196; --line:#2B3236;
  --accent:#4FB4C4; --accent-strong:#7ACBD8; --accent-soft:#1E3236;
  --good:#5CC584; --good-soft:#1A3324; --warn:#E3A64C; --warn-soft:#332510;
  --bad:#E0685A; --bad-soft:#3A1F1B;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--paper); color:var(--ink);
  font-family:'Public Sans', system-ui, -apple-system, sans-serif;
  font-size:15px; line-height:1.5;
}
h1,h2,h3{ font-family:'Sora', system-ui, sans-serif; color:var(--ink); margin:0; }
.mono{ font-family:'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric:tabular-nums; }
a{ color:var(--accent); text-decoration:none; }
input,textarea,select,button{ font-family:inherit; font-size:inherit; color:inherit; }

/* ---------- shell ---------- */
.shell{ display:flex; min-height:100vh; }
.sidebar{
  width:248px; flex:none; background:var(--surface); border-right:1px solid var(--line);
  display:flex; flex-direction:column; padding:20px 14px;
}
.brand{ display:flex; align-items:center; gap:9px; padding:6px 8px 22px; }
.brand-mark{
  width:28px; height:28px; border-radius:8px; background:var(--accent); color:#fff;
  display:flex; align-items:center; justify-content:center; font-family:'Sora'; font-weight:800; font-size:14px; flex:none;
}
.brand-name{ font-family:'Sora'; font-weight:700; font-size:16.5px; letter-spacing:-.01em; }
.back-link{
  display:flex; align-items:center; gap:6px; font-size:13px; font-weight:600; color:var(--muted);
  padding:6px 8px 16px;
}
.back-link:hover{ color:var(--ink); }

.nav-group-label{
  font-family:'IBM Plex Mono'; font-size:10.5px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--muted); padding:14px 10px 6px;
}
.nav-item{
  display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:8px;
  color:var(--ink-soft); font-weight:500; font-size:14px;
}
.nav-item:hover{ background:var(--surface-alt); color:var(--ink); }
.nav-item svg{ flex:none; opacity:.8; }
.nav-item.active{ background:var(--accent-soft); color:var(--accent-strong); font-weight:600; }
.nav-item.active svg{ opacity:1; }

.sidebar-spacer{ flex:1; }
.account-row{ display:flex; align-items:center; gap:10px; padding:10px; border-top:1px solid var(--line); }
.avatar{
  width:30px; height:30px; border-radius:50%; background:linear-gradient(135deg,var(--accent),var(--accent-strong));
  color:#fff; display:flex; align-items:center; justify-content:center; font-family:'Sora'; font-weight:700; font-size:12.5px; flex:none;
}
.account-name{ font-size:13px; font-weight:600; color:var(--ink); }
.account-role{ font-size:11.5px; color:var(--muted); }
.account-row form{ margin-left:auto; }
.icon-btn{ background:none; border:none; color:var(--muted); cursor:pointer; padding:4px; display:flex; }
.icon-btn:hover{ color:var(--ink); }

main{ flex:1; min-width:0; padding:36px 44px 64px; max-width:1180px; }
.topbar{ display:flex; justify-content:flex-end; gap:10px; margin-bottom:20px; }

.btn{
  display:inline-flex; align-items:center; gap:7px; font-family:'Public Sans'; font-weight:600; font-size:13.5px;
  padding:9px 16px; border-radius:999px; border:1px solid transparent; cursor:pointer; background:none;
}
.btn-primary{ background:var(--accent); color:#fff; box-shadow:var(--shadow); }
.btn-primary:hover{ background:var(--accent-strong); }
.btn-ghost{ background:var(--surface); color:var(--ink); border-color:var(--line); }
.btn-ghost:hover{ border-color:var(--muted); }
.btn-danger{ background:var(--bad-soft); color:var(--bad); }
.btn-sm{ padding:6px 12px; font-size:12.5px; }

.page-head{ margin-bottom:34px; }
h1.title{ font-size:32px; font-weight:800; letter-spacing:-.015em; margin-bottom:8px; }
.subtitle{ color:var(--muted); font-size:15px; max-width:60ch; }

.eyebrow-row{ display:flex; align-items:baseline; justify-content:space-between; margin:0 0 14px; }
.eyebrow{ font-family:'IBM Plex Mono'; font-size:11.5px; letter-spacing:.09em; text-transform:uppercase; color:var(--muted); font-weight:500; }
.eyebrow b{ color:var(--ink-soft); }

/* health banner */
.health-banner{ display:flex; align-items:center; gap:11px; background:var(--good-soft); border:1px solid color-mix(in srgb, var(--good) 30%, transparent); border-radius:var(--radius); padding:13px 18px; margin-bottom:36px; }
.health-banner.has-issues{ background:var(--warn-soft); border-color:color-mix(in srgb, var(--warn) 35%, transparent); }
.health-icon{ color:var(--good); flex:none; display:flex; }
.has-issues .health-icon{ color:var(--warn); }
.health-text{ font-size:13.5px; color:var(--ink-soft); }
.health-text b{ color:var(--ink); font-weight:600; }

/* bot cards (dashboard) */
.bot-grid{ display:grid; grid-template-columns:1.3fr 1fr; gap:16px; align-items:stretch; }
.bot-card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:22px 24px; box-shadow:var(--shadow); display:flex; flex-direction:column; gap:14px; }
.bot-card-head{ display:flex; align-items:center; gap:13px; }
.bot-mark{ width:42px; height:42px; border-radius:10px; flex:none; background:var(--surface-alt); border:1px solid var(--line); display:flex; align-items:center; justify-content:center; font-family:'Sora'; font-weight:700; font-size:16px; color:var(--accent-strong); }
.bot-name{ font-family:'Sora'; font-weight:700; font-size:16.5px; }
.bot-client{ font-size:13px; color:var(--muted); margin-top:1px; }
.status-pill{ display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:600; color:var(--good); background:var(--good-soft); padding:4px 10px 4px 8px; border-radius:999px; width:fit-content; }
.status-pill.bad{ color:var(--bad); background:var(--bad-soft); }
.status-dot{ width:6px; height:6px; border-radius:50%; background:currentColor; }
.bot-stats{ display:flex; gap:22px; padding-top:12px; border-top:1px solid var(--line); flex-wrap:wrap; }
.bot-stat b{ display:block; font-family:'IBM Plex Mono'; font-size:17px; font-weight:600; }
.bot-stat span{ font-size:12px; color:var(--muted); }
.bot-card-foot{ display:flex; justify-content:space-between; align-items:center; margin-top:auto; padding-top:2px; }
.sync-note{ font-size:12px; color:var(--muted); }
.open-link{ font-size:13px; font-weight:600; color:var(--accent); display:flex; align-items:center; gap:5px; }

.add-card{ background:var(--accent-soft); border:1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius:var(--radius); padding:24px; display:flex; flex-direction:column; gap:12px; justify-content:center; }
.add-icon{ width:34px; height:34px; border-radius:9px; background:var(--surface); display:flex; align-items:center; justify-content:center; color:var(--accent-strong); box-shadow:var(--shadow); }
.add-card h3{ font-size:16px; font-weight:700; }
.add-card p{ font-size:13.5px; color:var(--ink-soft); margin:0; max-width:34ch; }

/* bot workspace header card */
.workspace-header{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:20px 24px; margin-bottom:28px; }
.workspace-header-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.workspace-header-actions{ display:flex; gap:8px; flex:none; }
.workspace-stats{ display:flex; gap:26px; flex-wrap:wrap; padding-top:14px; margin-top:14px; border-top:1px solid var(--line); }
.workspace-stat{ font-size:13px; color:var(--muted); }
.workspace-stat b{ font-family:'IBM Plex Mono'; color:var(--ink); font-weight:600; font-size:14px; }

/* tables */
.table-wrap{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; overflow-x:auto; box-shadow:var(--shadow); }
table{ width:100%; border-collapse:collapse; font-size:13.5px; }
th{ text-align:left; font-family:'IBM Plex Mono'; font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); font-weight:500; padding:12px 16px; border-bottom:1px solid var(--line); background:var(--surface-alt); white-space:nowrap; }
td{ padding:12px 16px; border-bottom:1px solid var(--line); vertical-align:middle; }
tr:last-child td{ border-bottom:none; }
.empty-state{ padding:40px 24px; text-align:center; color:var(--muted); font-size:14px; }

.badge{ display:inline-flex; align-items:center; gap:5px; font-family:'IBM Plex Mono'; font-size:11px; padding:3px 9px; border-radius:999px; font-weight:500; }
.badge.good{ background:var(--good-soft); color:var(--good); }
.badge.muted{ background:var(--surface-alt); color:var(--muted); border:1px solid var(--line); }
.badge.warn{ background:var(--warn-soft); color:var(--warn); }

/* forms */
.field{ margin-bottom:16px; }
.field label{ display:block; font-size:13px; font-weight:600; color:var(--ink-soft); margin-bottom:6px; }
.field input[type=text], .field input[type=number], .field input[type=password], .field textarea, .field select{
  width:100%; padding:9px 12px; border:1px solid var(--line); border-radius:8px; background:var(--surface); color:var(--ink);
}
.field textarea{ resize:vertical; min-height:90px; font-family:'Public Sans'; }
.field .hint{ font-size:12px; color:var(--muted); margin-top:4px; }
.form-card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:26px; max-width:520px; box-shadow:var(--shadow); }

/* login */
.login-shell{ min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--paper); }
.login-card{ width:340px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:30px 28px; }
.login-card .brand{ padding:0 0 22px; }

/* logs */
.log-toolbar{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
.log-view{ background:#0F1315; color:#C9D4D2; border-radius:var(--radius); padding:16px 18px; font-family:'IBM Plex Mono'; font-size:12px; line-height:1.6; overflow-x:auto; white-space:pre; max-height:60vh; overflow-y:auto; }
:root[data-theme="dark"] .log-view, :root:not([data-theme="light"]) .log-view{ background:#0A0D0E; }

.placeholder-card{ background:var(--surface-alt); border:1px dashed var(--line); border-radius:var(--radius); padding:48px 24px; text-align:center; color:var(--muted); }

/* рассылка */
.broadcast-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start; }
.broadcast-grid .form-card{ max-width:none; }
.bc-preview-wrap{ background:var(--surface-alt); border:1px solid var(--line); border-radius:var(--radius); padding:20px; }
.bc-preview-label{ font-size:12px; color:var(--muted); margin-bottom:14px; }
.bc-bubble-row{ display:flex; gap:9px; align-items:flex-start; }
.bc-bubble-avatar{ width:32px; height:32px; border-radius:9px; flex:none; background:var(--surface); border:1px solid var(--line); display:flex; align-items:center; justify-content:center; font-family:'Sora'; font-weight:700; font-size:13px; color:var(--accent-strong); }
.bc-bubble{ background:var(--surface); border-radius:0 12px 12px 12px; padding:11px 14px; box-shadow:var(--shadow); max-width:320px; }
.bc-bubble-name{ font-size:12px; font-weight:600; color:var(--accent-strong); margin-bottom:4px; }
.bc-bubble-text{ font-size:14px; line-height:1.5; white-space:pre-wrap; word-break:break-word; }
.bc-empty{ color:var(--muted); font-style:italic; }
.bc-attach-image{ display:block; max-width:100%; border-radius:8px; margin-bottom:8px; }
.bc-attach-file{ display:flex; align-items:center; gap:6px; background:var(--surface-alt); border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-size:13px; margin-bottom:8px; }
.bc-attach-size{ font-family:'IBM Plex Mono'; font-size:11px; color:var(--muted); margin:2px 0 8px; }
.bc-attach-file .bc-attach-size{ margin:0 0 0 auto; }
.bc-history-text{ max-width:360px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (max-width:900px){ .broadcast-grid{ grid-template-columns:1fr; } }

@media (max-width: 860px){
  .sidebar{ display:none; }
  main{ padding:24px 18px 48px; }
  .bot-grid{ grid-template-columns:1fr; }
}
