/* ============ Дизайн-токены ============ */
:root {
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e6e9f0;
  --text:          #1a2233;
  --text-soft:     #5b657a;
  --text-muted:    #98a1b3;
  --primary:       #4f46e5;
  --primary-600:   #4338ca;
  --primary-soft:  #eef0ff;
  --accent:        #0ea5a4;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --shadow-sm:     0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md:     0 4px 16px rgba(16,24,40,.08);
  --shadow-lg:     0 18px 50px rgba(16,24,40,.16);
  --radius:        14px;
  --radius-sm:     10px;
  --sidebar-w:     264px;
}

[data-theme="dark"] {
  --bg:            #0c0f17;
  --surface:       #141823;
  --surface-2:     #1a1f2e;
  --border:        #262c3b;
  --text:          #e7ebf3;
  --text-soft:     #a6afc2;
  --text-muted:    #6b7589;
  --primary:       #6366f1;
  --primary-600:   #818cf8;
  --primary-soft:  #1e2236;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.4);
  --shadow-md:     0 6px 22px rgba(0,0,0,.45);
  --shadow-lg:     0 20px 60px rgba(0,0,0,.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ Бренд ============ */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand__mark { color: var(--primary); font-size: 20px; }
.brand--light .brand__mark, [data-theme] .brand--light .brand__mark { color: #a9b2ff; }
.brand__accent { color: var(--primary); }
.brand--light .brand__accent { color: #a9b2ff; }

/* ============ Кнопки / поля ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--surface-2); transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--sm { padding: 8px 13px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-600); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-2); }

.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-size: 13px; font-weight: 500; color: var(--text-soft); margin-bottom: 6px; }
.field__input {
  width: 100%; padding: 12px 14px; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: .15s ease;
}
.field__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field__password { position: relative; }
.field__toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; font-size: 16px; opacity: .55; padding: 6px;
}
.field__toggle:hover { opacity: 1; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ============ Экран логина ============ */
.login-screen { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-aside {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(1100px 600px at 0% 0%, #5b54f0 0%, #3b2fc4 42%, #211b78 100%);
  display: flex; align-items: center;
}
.login-aside::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(420px 420px at 88% 18%, rgba(255,255,255,.14), transparent 60%),
    radial-gradient(360px 360px at 75% 95%, rgba(14,165,164,.30), transparent 60%);
}
.login-aside__inner { position: relative; z-index: 1; padding: 56px; max-width: 520px; }
.login-aside__title { font-size: 30px; line-height: 1.2; margin: 40px 0 16px; letter-spacing: -.02em; }
.login-aside__text { color: rgba(255,255,255,.82); font-size: 15px; margin-bottom: 26px; }
.login-aside__list { list-style: none; display: grid; gap: 12px; margin-bottom: 40px; }
.login-aside__list li { position: relative; padding-left: 28px; color: rgba(255,255,255,.9); }
.login-aside__list li::before {
  content: '✓'; position: absolute; left: 0; top: -1px; width: 18px; height: 18px;
  display: grid; place-items: center; font-size: 11px; border-radius: 50%;
  background: rgba(255,255,255,.18);
}
.login-aside__stats { display: flex; gap: 34px; border-top: 1px solid rgba(255,255,255,.18); padding-top: 24px; }
.login-aside__stats strong { display: block; font-size: 24px; }
.login-aside__stats span { font-size: 12px; color: rgba(255,255,255,.7); }

.login-main { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card__brand { display: none; margin-bottom: 26px; }
.login-card__title { font-size: 24px; letter-spacing: -.02em; }
.login-card__subtitle { color: var(--text-soft); margin: 6px 0 28px; }
.login-card__row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 22px; }
.login-card__divider { text-align: center; position: relative; margin: 22px 0; color: var(--text-muted); font-size: 12px; }
.login-card__divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.login-card__divider span { position: relative; background: var(--bg); padding: 0 12px; }
.login-card__foot { text-align: center; margin-top: 24px; color: var(--text-soft); font-size: 13px; }

@media (max-width: 880px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-card__brand { display: flex; }
}

/* ============ Каркас приложения ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: #11152099; backdrop-filter: blur(8px);
  background: linear-gradient(180deg, #181d2b 0%, #141823 100%);
  color: #cfd6e6; display: flex; flex-direction: column;
  border-right: 1px solid #00000030; position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { padding: 20px 20px 14px; color: #fff; }
.nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.nav__group { margin-bottom: 18px; }
.nav__caption {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #707a90; padding: 8px 12px 6px; font-weight: 600;
}
.nav__item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: #b6bed1; font-weight: 500; cursor: pointer; transition: .14s ease; margin-bottom: 2px;
}
.nav__item:hover { background: #ffffff10; color: #fff; }
.nav__item.is-active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.nav__icon { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.nav__badge {
  margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: #ffffff18; color: #dfe4f0;
}
.nav__badge--accent { background: var(--accent); color: #fff; }
.is-active .nav__badge { background: #ffffff2e; color: #fff; }
.sidebar__foot { padding: 12px; border-top: 1px solid #ffffff12; }
.userchip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.userchip:hover { background: #ffffff10; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-weight: 700; font-size: 13px;
}
.userchip__info { display: flex; flex-direction: column; line-height: 1.25; }
.userchip__name { font-size: 13px; font-weight: 600; color: #fff; }
.userchip__role { font-size: 12px; color: #8d96ab; }

/* ============ Основная область ============ */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__menu { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search__icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search__input {
  width: 100%; padding: 10px 14px 10px 36px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px;
}
.search__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search__kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 6px;
}
.topbar__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.iconbtn {
  position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft); font-size: 16px; display: grid; place-items: center;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn__dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

.content { padding: 26px 24px 48px; overflow-y: auto; }

/* ============ Заголовок страницы ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head__title { font-size: 22px; letter-spacing: -.02em; }
.page-head__sub { color: var(--text-soft); margin-top: 4px; font-size: 13px; }

/* ============ Карточки статистики ============ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; background: var(--primary-soft); color: var(--primary); }
.stat__delta { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.stat__delta--up { color: var(--success); background: #16a34a18; }
.stat__delta--down { color: var(--danger); background: #dc262618; }
.stat__value { font-size: 27px; font-weight: 700; margin-top: 14px; letter-spacing: -.02em; }
.stat__label { color: var(--text-soft); font-size: 13px; margin-top: 2px; }

/* ============ Сетка / панели ============ */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel__title { font-size: 15px; font-weight: 600; }
.panel__body { padding: 6px 8px; }
.panel__body--pad { padding: 18px; }

/* ============ Таблица ============ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; }
.table td { padding: 12px; border-top: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }
.site-cell { display: flex; align-items: center; gap: 11px; }
.favicon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.site-cell__name { font-weight: 600; }
.site-cell__url { color: var(--text-muted); font-size: 12px; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.tag--ok { color: var(--success); background: #16a34a16; }
.tag--warn { color: var(--warning); background: #d9770616; }
.tag--bad { color: var(--danger); background: #dc262616; }
.tag--accent { color: var(--accent); background: #0ea5a416; }
.tag--neutral { color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* форма добавления домена в разделе «Сайты» */
.site-form { display: grid; grid-template-columns: 1fr 1.4fr 140px 140px; gap: 14px; align-items: end; }
.site-form__actions { grid-column: 1 / -1; display: flex; gap: 10px; }
@media (max-width: 720px) { .site-form { grid-template-columns: 1fr 1fr; } }

/* редактор семантики по гео */
.sem-editor__country { display: block; max-width: 320px; margin-bottom: 14px; }
.sem-form__actions { display: flex; gap: 12px; align-items: center; }

/* таблица-редактор ключей: компактные поля внутри ячеек */
.sem-kw-table { table-layout: fixed; }
.sem-kw-table th.sem-col-freq { width: 150px; }
.sem-kw-table th.sem-col-prio { width: 180px; }
.sem-kw-table td:last-child, .sem-kw-table th:last-child { width: 44px; text-align: center; }
.sem-kw-table td { padding: 6px 8px; vertical-align: middle; }
.sem-kw-table .field__input { padding: 8px 10px; }
.sem-row-del { padding: 6px 10px; }

.sem-list { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.geo-row { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.geo-row__head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.geo-row__name { font-weight: 600; }
.geo-row__count { color: var(--text-muted); font-size: 13px; }
.geo-row__act { margin-left: auto; display: flex; gap: 8px; }
.geo-row__kwtable { border-top: 1px solid var(--border); background: var(--surface); margin: 0; }
.geo-row__kwtable th { font-size: 12px; color: var(--text-muted); }
.geo-row__kwtable td:nth-child(2), .geo-row__kwtable th:nth-child(2) { width: 150px; }
.geo-row__kwtable td:nth-child(3), .geo-row__kwtable th:nth-child(3) { width: 170px; }

.bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; min-width: 90px; }
.bar__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.trend-up { color: var(--success); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }

/* список активности / задач */
.feed { display: grid; gap: 4px; padding: 6px; }
.feed__item { display: flex; gap: 12px; padding: 10px; border-radius: 10px; }
.feed__item:hover { background: var(--surface-2); }
.feed__ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.feed__txt { font-size: 13px; }
.feed__time { font-size: 12px; color: var(--text-muted); }

.task { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; }
.task:hover { background: var(--surface-2); }
.task input { width: 17px; height: 17px; accent-color: var(--primary); }
.task__title { font-weight: 500; font-size: 13px; }
.task__meta { font-size: 12px; color: var(--text-muted); }
.task__pri { margin-left: auto; }

/* плитки инструментов */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tool {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); transition: .16s ease; cursor: pointer;
}
.tool:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #c7ccff; }
.tool__ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.tool__title { font-size: 15px; font-weight: 600; }
.tool__desc { color: var(--text-soft); font-size: 13px; margin-top: 5px; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-soft); }
.empty__ic { font-size: 40px; opacity: .4; }
.empty__title { font-size: 16px; font-weight: 600; color: var(--text); margin: 12px 0 4px; }

/* ============ Адаптив ============ */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } .tools { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .topbar__menu { display: grid; }
  .search__kbd { display: none; }
}
@media (max-width: 560px) { .stats { grid-template-columns: 1fr; } .tools { grid-template-columns: 1fr; } .topbar__actions .btn { display: none; } }

/* ============ Зона загрузки файлов ============ */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 40px 20px; text-align: center; cursor: pointer; transition: .15s ease;
}
.dropzone:hover { border-color: var(--primary); background: var(--surface-2); }
.dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.005); }
.dropzone__ic { font-size: 34px; color: var(--primary); }
.dropzone__title { font-size: 16px; font-weight: 600; margin-top: 10px; }
.dropzone__hint { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.dropzone__progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 18px auto 0; max-width: 480px; }
.dropzone__bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s ease; }

/* ============ Ошибка логина ============ */
.login-card__error {
  background: #dc26261a; color: var(--danger); border: 1px solid #dc262633;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
#google-login { display: flex; align-items: center; justify-content: center; }
#google-login span { color: #4285F4; }
.iconbtn--logout { width: 32px; height: 32px; font-size: 15px; background: transparent; border-color: transparent; color: #8d96ab; margin-left: auto; }
.iconbtn--logout:hover { background: #ffffff14; color: #fff; }
