:root {
  --bg: #f6f7f9;
  --card: #fff;
  --line: #e7e9ee;
  --text: #151821;
  --muted: #737985;
  --accent: #6d4df6;
  --accent-dark: #5634e9;
  --accent-soft: #eeeaff;
  --green: #1aaa61;
  --green-soft: #e9f9ef;
  --red: #eb5757;
  --blue: #148ac2;
  --shadow: 0 18px 48px rgba(35, 31, 60, .10);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 11px; padding: 0 10px 25px; font-size: 20px; font-weight: 800; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; display: inline-grid; place-items: center; color: white; background: linear-gradient(135deg, #7e61ff, #4e2be0); font-weight: 800; box-shadow: 0 8px 18px rgba(109,77,246,.28); }
.brand-mark.small { width: 35px; height: 35px; border-radius: 10px; font-size: 13px; }
.project-picker { border: 1px solid var(--line); background: #fafafd; padding: 10px 12px; border-radius: 12px; margin-bottom: 22px; }
.project-picker span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .08em; }
.project-picker select { width: 100%; border: 0; outline: 0; background: transparent; font-weight: 650; color: var(--text); }
.project-select-row { display: grid; grid-template-columns: minmax(0,1fr) 29px; align-items: center; gap: 6px; }
.project-select-row button { width: 29px; height: 29px; border: 0; border-radius: 8px; color: white; background: var(--accent); font-size: 20px; line-height: 1; }
.project-select-row button:hover { background: var(--accent-dark); }
nav { display: grid; gap: 6px; }
nav button { border: 0; border-radius: 11px; background: transparent; color: #373b46; padding: 12px 14px; display: flex; gap: 12px; align-items: center; text-align: left; }
nav button span { width: 22px; font-size: 19px; color: #555b66; }
nav button:hover { background: #f6f5fb; }
nav button.active { color: var(--accent-dark); background: var(--accent-soft); font-weight: 700; }
nav button.active span { color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 4px; }
.plain-button { border: 0; background: transparent; text-align: left; padding: 10px 12px; color: #3d424b; }
.plain-button:hover { color: var(--accent); }
.muted { color: var(--muted); }
main { min-width: 0; }
.topbar { min-height: 105px; padding: 22px 34px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 8; backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: 25px; }
.eyebrow { color: var(--accent); margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.date-pill { padding: 10px 12px; color: #555b66; font-size: 13px; background: #f7f7f9; border: 1px solid var(--line); border-radius: 10px; }
.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font-weight: 700; transition: .15s; }
.button.primary { color: white; background: var(--accent); box-shadow: 0 8px 18px rgba(109,77,246,.18); }
.button.primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.button.secondary { color: #4a4f59; border-color: var(--line); background: white; }
.button.danger { color: #c94242; background: #fff0f0; }
.button.wide { width: 100%; }
.button.small { padding: 7px 10px; font-size: 12px; }
.content { padding: 28px 34px 50px; max-width: 1500px; margin: 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 17px 18px; min-height: 116px; position: relative; overflow: hidden; }
.metric::after { content: ""; width: 80px; height: 80px; position: absolute; border-radius: 50%; right: -15px; bottom: -34px; background: var(--accent-soft); }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { margin-top: 8px; font-size: 30px; font-weight: 780; letter-spacing: -.03em; }
.metric .delta { margin-top: 7px; color: var(--green); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-head h2, .card h2 { margin: 0; font-size: 17px; }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.chart-bars { display: grid; gap: 16px; padding-top: 5px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 55px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; border-radius: 999px; background: #eef0f3; overflow: hidden; }
.bar-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--accent); }
.presence { display: flex; height: 34px; border-radius: 9px; overflow: hidden; margin: 30px 0 18px; background: #d9dde4; }
.presence div:nth-child(1) { background: var(--green); }
.presence div:nth-child(2) { background: var(--blue); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--dot); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: #6c717d; font-weight: 650; background: #fafafb; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #eff0f3; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: #faf9ff; cursor: pointer; }
.brand-cell { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand-dot { width: 11px; height: 11px; border-radius: 4px; background: var(--brand); }
.tag { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 7px; background: #f0f1f4; color: #565b64; font-size: 11px; font-weight: 700; }
.tag.green { background: var(--green-soft); color: #13854b; border: 1px solid #b9e9cb; }
.tag.purple { background: var(--accent-soft); color: var(--accent-dark); }
.models { display: flex; align-items: center; gap: 4px; }
.model-icon { min-width: 24px; height: 24px; padding: 0 5px; border-radius: 7px; display: inline-grid; place-items: center; font-weight: 800; font-size: 10px; background: #eef0f4; color: #393f48; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.toolbar-left, .toolbar-right { display: flex; gap: 9px; align-items: center; }
.search, .field { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; background: white; }
.search:focus, .field:focus { border-color: #a692ff; box-shadow: 0 0 0 3px var(--accent-soft); }
.tabs { display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: white; gap: 3px; }
.tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; }
.tabs button.active { background: #efedf7; font-weight: 700; }
.provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.account-section { padding: 18px; }
.account-card { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid #d9e3ff; border-radius: 14px; background: linear-gradient(135deg,#f7f9ff,#fff); }
.account-logo { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; background: conic-gradient(from -45deg,#4285f4 0 25%,#34a853 0 50%,#fbbc05 0 75%,#ea4335 0); }
.account-card h3 { margin: 0 0 5px; }
.account-card p { margin: 0; color: var(--muted); font-size: 12px; }
.account-card .account-state { margin-top: 7px; }
.connection-summary { margin-top: 24px; }
.provider { border: 1px solid var(--line); border-radius: 15px; background: white; padding: 17px; display: grid; grid-template-columns: 44px 1fr auto; gap: 13px; align-items: start; }
.provider-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: white; font-size: 16px; font-weight: 800; background: var(--provider-color,#343944); }
.account-logo.yandex { background:#fc3f1d; color:#fff; }
.provider h3 { margin: 1px 0 5px; font-size: 15px; }
.provider p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.provider-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.check-row { display: flex !important; grid-template-columns: none !important; flex-direction: row; align-items: center; gap: 9px; margin: 0 !important; cursor: pointer; }
.check-row input { width: 17px !important; height: 17px; accent-color: var(--accent); margin: 0; }
.provider-check { margin-top: 12px !important; color: #414650; font-size: 12px; font-weight: 700; }
.status { font-size: 11px; font-weight: 800; color: #8a8f98; }
.status.connected { color: var(--green); }
.status.browser_open { color: #d28a19; }
.notice { border: 1px solid #ddcffd; background: #f5f1ff; color: #503e84; border-radius: 13px; padding: 13px 15px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; }
.history-item { display: grid; grid-template-columns: 1fr 170px 160px 120px; gap: 15px; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.progress { height: 7px; background: #eceef2; border-radius: 999px; overflow: hidden; margin-top: 7px; }
.progress div { height: 100%; background: var(--accent); }
.empty { text-align: center; padding: 55px 20px; color: var(--muted); }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at 25% 15%, #efeaff, transparent 35%), #f7f7fb; }
.login-card { width: min(390px, 100%); border: 1px solid var(--line); background: rgba(255,255,255,.95); border-radius: 22px; box-shadow: var(--shadow); padding: 34px; }
.login-card .brand-mark { margin-bottom: 12px; }
.login-card h1 { margin: 4px 0; }
.login-card > p { color: var(--muted); margin: 0 0 25px; }
.login-card label, .form-grid label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 12px; font-weight: 700; color: #595e67; }
.login-card input, .form-grid input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.login-card small { display: block; text-align: center; margin-top: 18px; color: #9498a1; }
.form-error { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 8px; }
.modal-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(16,18,27,.58); display: grid; place-items: center; padding: 24px; }
.modal-card { position: relative; background: white; width: min(820px, 100%); max-height: 88vh; overflow: auto; border-radius: 18px; box-shadow: var(--shadow); padding: 24px; }
.modal-close { position: absolute; right: 14px; top: 11px; width: 34px; height: 34px; border: 0; background: #f2f3f5; border-radius: 10px; font-size: 22px; }
.modal-card h2 { margin: 0 42px 18px 0; }
.answer { white-space: pre-wrap; line-height: 1.65; background: #fafafb; border: 1px solid var(--line); border-radius: 12px; padding: 16px; font-size: 14px; max-height: 430px; overflow: auto; }
.response-block { border-top: 1px solid var(--line); padding: 15px 0; }
.response-block:first-of-type { border-top: 0; }
.response-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.response-answer { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; color: #252832; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .wide-field { grid-column: 1/-1; }
.channel-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafafb; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.prompt-form { display: grid; gap: 10px; }
.prompt-form > label { font-size: 13px; font-weight: 700; color: #595e67; }
.prompt-form textarea { width: 100%; min-height: 190px; resize: vertical; font: inherit; line-height: 1.45; }
.action-column { width: 54px; text-align: center; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: #f3f4f6; color: #626874; font-size: 22px; line-height: 1; cursor: pointer; }
.icon-button:hover { background: #e6e8ec; }
.danger-icon:hover { background: #fee9e8; color: #c7372f; }
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #626874; background: #f3f4f6; font-size: 22px; line-height: 1; cursor: pointer; user-select: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { color: var(--accent-dark); background: var(--accent-soft); }
.row-menu-panel { position: absolute; z-index: 12; top: calc(100% + 5px); right: 0; min-width: 176px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 14px 36px rgba(28,30,42,.16); }
.row-menu-panel button { display: block; width: 100%; border: 0; border-radius: 7px; padding: 9px 10px; color: #343842; background: transparent; text-align: left; font-size: 12px; }
.row-menu-panel button:hover { background: #f4f2ff; }
.row-menu-panel button.menu-danger { color: #c7372f; }
.row-menu-panel button.menu-danger:hover { background: #fff0f0; }
.settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.settings-section > h3, .settings-section-head h3 { margin: 0; font-size: 16px; }
.settings-section > p, .settings-section-head p { margin: 4px 0 0; font-size: 12px; }
.settings-section-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 11px; }
.browser-settings h4 { margin: 20px 0 10px; font-size: 13px; }
.compact-notice { margin: 12px 0; padding: 10px 12px; }
.settings-toggle { padding: 11px 0; align-items: flex-start; }
.settings-toggle span { display: grid; gap: 3px; }
.settings-toggle small { color: var(--muted); line-height: 1.4; }
.proxy-fields { margin-top: 8px; transition: opacity .15s ease; }
.settings-disabled { opacity: .48; }
.privacy-grid { display: grid; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; }
.proxy-test-result { min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.proxy-test-result.success { color: #147a48; font-weight: 700; }
.proxy-test-result.error { color: #b43b3b; font-weight: 700; }
.settings-list { border: 1px solid var(--line); border-radius: 12px; background: #fafafb; }
.settings-row { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px; min-height: 58px; padding: 10px 11px 10px 14px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row b { display: block; overflow-wrap: anywhere; font-size: 13px; }
.settings-row .muted { margin-top: 4px; font-size: 11px; line-height: 1.35; }
.settings-row-main { min-width: 0; }
.settings-row.is-paused { background: #f3f4f6; }
.settings-row.is-paused b { color: #737985; }
.settings-empty { padding: 18px; color: var(--muted); text-align: center; font-size: 12px; }
.modal-intro { margin: -10px 0 18px; font-size: 13px; }
.toast { position: fixed; right: 25px; bottom: 25px; background: #242733; color: white; padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow); z-index: 50; max-width: 420px; font-size: 13px; }
.toast.success { background: #147a48; }
.toast.error { background: #b43b3b; }
.skeleton { background: linear-gradient(90deg,#eee,#f8f8f8,#eee); background-size: 200% 100%; animation: shimmer 1.3s infinite; height: 18px; border-radius: 7px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .sidebar { padding: 20px 10px; }
  .logo > span:last-child, .project-picker, nav button:not(.active) span + *, .sidebar-bottom { display:none; }
  nav button { justify-content:center; padding: 13px 8px; font-size: 0; }
  nav button span { font-size: 20px; width:auto; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
  .grid-2 { grid-template-columns:1fr; }
  .provider-grid { grid-template-columns:1fr; }
}
@media (max-width: 650px) {
  .app-shell { display:block; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; top: auto; bottom: 0; height: 66px; border: 0; border-top:1px solid var(--line); padding: 8px; }
  .logo,.project-picker,.sidebar-bottom { display:none; }
  nav { display:flex; justify-content:space-around; }
  nav button { flex:1; }
  nav { gap: 2px; }
  nav button { min-width: 0; padding-left: 4px; padding-right: 4px; }
  .topbar { padding: 16px; min-height:90px; }
  .top-actions .date-pill,.top-actions #refresh { display:none; }
  .topbar h1 { font-size:21px; }
  .content { padding:16px 14px 90px; }
  .metric-grid { grid-template-columns:1fr 1fr; gap:9px; }
  .metric { min-height:100px; padding:14px; }
  .metric .value { font-size:24px; }
  .provider { grid-template-columns:40px 1fr; }
  .provider-actions { grid-column:1/-1; flex-direction:row; justify-content:flex-end; }
  .account-card { grid-template-columns:44px 1fr; }
  .account-card .provider-actions { grid-column:1/-1; }
  .history-item { grid-template-columns:1fr; }
}
