:root{
  --bg:#ffffff; --text:#0f172a; --muted:#64748b; --border:#e2e8f0;
  --card:#ffffff; --shadow:0 6px 20px rgba(0,0,0,.06);
  --accent:#2563eb; --accent-ghost:#eef2ff; --accent-contrast:#ffffff;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--text);
  font:14px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  overflow-y: scroll; /* щоб не стрибав лейаут при появі скролу */
}

/* Layout */
.layout{
  display:flex; flex-direction:column; min-height:100vh;
  margin-left:260px; transition:margin .2s ease;
}
.sidebar{
  position:fixed; inset:0 auto 0 0; width:260px;
  border-right:1px solid var(--border); background:#fafafa;
  padding:16px; overflow:auto; transition:transform .2s ease;
}
.sidebar .brand{display:flex;align-items:center;gap:10px;font-weight:700;margin-bottom:12px}
.brand__dot{width:10px;height:10px;border-radius:50%;background:var(--accent)}
.nav{display:flex;flex-direction:column;gap:6px;margin-top:8px}
.nav__item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;color:var(--text);border:1px solid transparent}
.nav__item:hover{background:#f8fafc;border-color:var(--border)}
.nav__item.is-active{background:var(--accent-ghost);border-color:#c7d2fe}
.nav__icon{width:18px;text-align:center}

.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; gap:12px;
  padding:10px 16px; background:#fff; border-bottom:1px solid var(--border)
}
.topbar__spacer{flex:1}
.topbar__meta{display:flex;align-items:center;gap:10px}

/* Контейнер для стабільної ширини */
.content{
  padding:18px;
  max-width: 90%;   /* ✅ фіксуємо контейнер */
  margin: 0 auto;
}
.footer{border-top:1px solid var(--border);padding:14px 18px;color:var(--muted);background:#fff;margin-top:auto}

/* Responsive sidebar */
@media (max-width: 960px){
  .layout{margin-left:0}
  .sidebar{transform:translateX(-100%)}
  body.sidebar-open .sidebar{transform:translateX(0)}
}

/* Typography & helpers */
.h1{font-size:24px;margin:0 0 12px 0}
.h2{font-size:18px;margin:0}
.muted{color:var(--muted)}
.pill{display:inline-block;padding:2px 8px;border:1px solid var(--border);border-radius:999px;background:#fff;color:#0f172a;font-size:12px}

/* Cards */
.grid{display:grid;gap:16px}
.grid--2{grid-template-columns:1fr 1fr}
@media (max-width: 960px){.grid--2{grid-template-columns:1fr}}
.card{background:var(--card);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow);padding:14px}
.card--full{grid-column:1/-1}
.card__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.card__actions{display:flex;gap:8px}

/* Таблиці — стабільні комірки */
.table{width:100%;border-collapse:collapse;table-layout:fixed} /* ✅ фіксуємо */
.table th,.table td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle;word-break:break-word}
.table th{color:#334155;font-weight:600}

/* Уніфіковані контроли по всьому сайту */
input[type="text"], input[type="password"], input[type="number"],
select, textarea{
  width:100%; border:1px solid var(--border); border-radius:10px;
  background:#fff; color:var(--text); line-height:1.4;
  padding:10px 12px; outline:none; transition:border-color .15s, box-shadow .15s;
}
input[type="text"], input[type="password"], input[type="number"], select{
  height:38px; /* ✅ однакова висота */
}
textarea{min-height:120px; resize:vertical}
input::placeholder, textarea::placeholder{color:#9aa4b2}
input:focus, select:focus, textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(37,99,235,.15);
}

/* Buttons */
.btn{
  display:inline-flex;align-items:center;gap:8px;
  padding:8px 12px;
    border-radius:10px;
    border:1px solid var(--border);
  background:#fff;color:var(--text);
    cursor:pointer;
    min-height:38px; /* ✅ */
}
.btn:hover{background:#f8fafc}
.btn--ghost{background:#fff}
.btn--primary{background:var(--accent);border-color:var(--accent);color:var(--accent-contrast)}
.btn--primary:hover{filter:brightness(0.97)}
a, a:visited, a:hover, a:active, a:focus {
  text-decoration: none;
  color: inherit;
}


/* ---- Reusable toggle switch -------------------------------------------- */
.switch{display:flex;align-items:center;gap:10px;flex-direction:row} /* override .row */
.switch input[type="checkbox"]{
  appearance:none;
  width:40px; height:24px;
  border-radius:9px; border:1px solid var(--border);
  background:#e5e7eb; position:relative; outline:none; cursor:pointer;
  transition:background .15s, border-color .15s;
}
.switch input[type="checkbox"]::after{
  content:""; position:absolute; top:2.5px; left:3px;
  width:18px; height:18px; border-radius:35%; background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,.15); transition:left .15s;
}
.switch input[type="checkbox"]:checked{background:var(--accent); border-color:var(--accent)}
.switch input[type="checkbox"]:checked::after{left:19px}
.switch span{user-select:none}

.switch--sm input[type="checkbox"]{width:34px; height:20px; flex-basis:34px}
.switch--sm input[type="checkbox"]::after{width:16px; height:16px; top:2px; left:2px}
.switch--sm input[type="checkbox"]:checked::after{left:16px}

.checkbox input[type="checkbox"]{accent-color: var(--accent); width:16px; height:16px}


.open_link {
  display: inline-block;
  padding: 6px 16px;
  background:#fff;color:var(--text);cursor:pointer; min-height:38px; /* ✅ */
 border-radius:10px;
    border:1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.open_link:hover {
background:#f8fafc
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.hidden { display: none; }

/* Карточка модалки: колонки + обмеження висоти */
.modal__card {
  --modal-header-h: 48px;         /* за потреби підкоригуй */
  --modal-filters-h: 48px;        /* за потреби підкоригуй */

  display: flex;
  flex-direction: column;
  max-width: 85%;
  max-height: 90vh;
  overflow: hidden;               /* скролитиметься лише тіло */
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* Закріплена шапка */
.modal__header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #fff;               /* важливо: фон, щоб не просвічувалось */
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.modal__title { font-weight: 600; }

/* (Опційно) закріплені фільтри */
.modal__filters {
  position: sticky;
  top: var(--modal-header-h);
  z-index: 2;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

/* Тіло: єдине місце, що скролиться */
.modal__body {
  flex: 1 1 auto;
  padding: 12px 14px;
  overflow: auto;                 /* і вертикальний, і горизонтальний скрол за потреби */
}

/* Внутрішня таблиця */
.modal__body table.table--inner {
  width: 100%;
  table-layout: auto;
  min-width: 700px;               /* щоб не стискалось */
}
.modal__body .table--inner td,
.modal__body .table--inner th {
  white-space: nowrap;
  vertical-align: top;
}
.modal__body .truncate {
  max-width: 300px;               /* URL не ламає ширину */
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

/* (Опційно) зафіксовані нижні кнопки всередині модалки */
#keywords-modal .chips-controls {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 6px rgba(0,0,0,.06);
  padding: 8px 12px;
}


/* Spacing utilities (використовуються в шаблонах) */
.mt-8{margin-top:8px}
.mt-12{margin-top:12px}
.mb-6{margin-bottom:6px}
.mb-12{margin-bottom:12px}

.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0,0,0,0);white-space:nowrap;border:0
}


.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  margin-left: 6px;
  font: 600 12px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #fff;
  background: #6b7280;
  border-radius: 50%;
  cursor: help;
  position: relative;
}

/* тултіп */
.help::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
   top: calc(100% + 8px);
  width: 400px;
  padding: 8px 10px;
  font: 400 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #e5e7eb;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  white-space: normal;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 20;
}

/* маленький трикутник */
.help::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #111827;
  opacity: 0;
  transition: opacity .15s ease;
}

.help:hover::after,
.help:hover::before,
.help:focus-visible::after,
.help:focus-visible::before {
  opacity: 1;
}

/* для клавіатури */
.help:focus-visible {
  outline: 2px solid #60a5fa;    /* синій фокус */
  outline-offset: 2px;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* плавний скрол на мобілках */
}
.table-scroll > table {
  min-width: 900px; /* під себе: щоб колонки не стискались до каші */
}

/* опційно: приховати нижню тінь таблиці під скролбаром */
.table-scroll::-webkit-scrollbar { height: 10px; }
.table-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1; border-radius: 6px;
}
.table-scroll::-webkit-scrollbar-track { background: #f1f5f9; }

/* --- selectable rows (weekly domains) --- */
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f8fafc; }

/* активний обраний домен */
.table tr.is-active {
  background: #eef2ff;                 /* легкий фіолетовий фон */
  outline: 2px solid var(--accent);     /* синя рамка */
  outline-offset: -2px;
}

/* ===== Date input ======================================================= */
/* Обгортка — дає нормальну зону кліку по іконці та зручне вирівнювання */
.input-date{ position:relative; display:inline-flex; }

/* Базовий вигляд поля дати (узгоджено з іншими інпутами у темі) */
input[type="date"]{
  max-width: 180px;                    /* під себе; можна збільшити */
  height: 38px;
  padding: 8px 38px 8px 12px;      /* місце під іконку справа */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  line-height: 1.4;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

