:root{
  --side: clamp(12px, 5vw, 200px);
  --pr: 10px; /* единый правый отступ контента */
}

body{
  margin-left:var(--side);
  margin-right:var(--side);
  margin-bottom:clamp(64px,12vh,200px);
  background:#2c2c2c;
  color:#dcdcdc;
  font-family:Arial,sans-serif;
}
h1{ color:#dcdcdc; }

/* общий контейнер */
.content-shell{ width:100%; box-sizing:border-box; }

/* ===== Шапка ===== */
.header-row{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:flex-start;
  padding-right: var(--pr);
  column-gap:16px;
  margin-bottom:14px;
}
.header-row h1{
  grid-column:2;
  margin:0;
  text-align:center;
  justify-self:center;
}

/* ===== Плашка Active sessions ===== */
.session-badge{
  grid-column:3;
  justify-self:end;
  position:relative;
  max-width:280px;
  color:#dcdcdc;
}
.badge-header{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  background:#1e1e1e;
  border:1px solid #48586e;
  border-radius:10px;
  padding:10px 12px;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.25);
  line-height:1.3;
  color:#dcdcdc;
}
.badge-title{ font-weight:700; text-transform:uppercase; letter-spacing:.3px; opacity:.95; }
.badge-spacer{ flex:1 1 auto; }
.badge-count{
  opacity:.9;
  display:flex;
  align-items:center;
  gap:6px;
}
.badge-count::before{
  content:"";
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  background:#4caf50;
}
.badge-header .chev{ transition: transform .15s ease; }
.badge-header[aria-expanded="true"] .chev{ transform: rotate(180deg); }

.badge-dropdown{
  position:absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 60vh;
  overflow:auto;
  background:#1e1e1e;
  border:1px solid #48586e;
  border-radius:10px;
  box-shadow:0 12px 24px rgba(0,0,0,.45);
  z-index: 3000;
  padding:10px;
}
.badge-list{ display:flex; flex-direction:column; gap:8px; }
.badge-item{
  padding:8px;
  border:1px solid #3a4552;
  border-radius:8px;
  background:#232323;
}
.badge-item .me{ color:#9ad0ff; font-size:12px; margin-left:4px; }

/* Иконки внутри карточек */
.badge-item i,
.badge-item .fi{
  margin-right:6px;
  font-size:14px;
  vertical-align:-1px;
}
.badge-item .fi{ width:1em; height:1em; border-radius:2px; }

.badge-item-row{
  display:grid;
  grid-template-columns: 88px 1fr; /* ширина колонки с меткой */
  align-items:center;
  column-gap:8px;
  line-height:1.35;
  margin:2px 0;
}
.badge-item-row .lbl{
  font-weight:700;
  color:#dcdcdc;
}
.badge-item-row .val{
  display:inline-flex;
  align-items:center;
  gap:6px;               /* расстояние между иконкой и текстом */
  min-width:0;           /* чтобы переносилось, если очень длинно */
  word-break:break-word;
}
.badge-item-row .val .fi{ width:1em; height:1em; border-radius:2px; }
.badge-item-row .val i{ font-size:14px; }

/* ===== Кнопки Back/Logout ===== */
.button-container-center{
  display:flex; justify-content:center; gap:10px; margin-bottom:20px; flex-wrap:wrap;
}
a.back-button, a.logout-button{
  display:inline-block; padding:10px 20px; min-width:110px; text-align:center; font-weight:600;
  color:#dcdcdc; background:#3b4a5a; border:1px solid #48586e; border-radius:8px; text-decoration:none;
  line-height:1.2; transition:background .15s ease, transform .05s ease;
}
a.back-button:hover, a.logout-button:hover{ background:#2a3848; }
a.back-button:active, a.logout-button:active{ transform:translateY(1px); }

/* ===== Поля/контейнер ===== */
input[type="text"], input[type="date"]{
  padding:10px; border-radius:5px; border:1px solid #48586e; background:#1e1e1e; color:#dcdcdc;
}
.error{ color:#ff8080; }

.table-responsive{
  width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch;
  box-sizing:border-box; padding-right: var(--pr);
}

/* ===== Фильтры ===== */
.filters-bar{
  display:grid; grid-template-columns:auto 1fr; align-items:center;
  column-gap:14px; row-gap:0; padding:10px 0 12px 0; box-sizing:border-box;
}
.filters-left{ display:flex; align-items:center; }
.filters-right{ display:flex; align-items:center; justify-content:flex-end; gap:10px; flex-wrap:nowrap; }
.ip-settings-button, .sort-toggle{
  cursor:pointer; border:1px solid #48586e; background:#3b4a5a; color:#dcdcdc;
  font-size:14px; padding:8px 12px; border-radius:8px; text-decoration:none; display:inline-block;
  width:190px; text-align:center; box-sizing:border-box;
}
.ip-settings-button:hover, .sort-toggle:hover{ background:#2a3848; }
.filters-right input[type="text"], .filters-right input[type="date"]{ width:auto; max-width:260px; }

/* ===== Таблица ===== */
table{ table-layout:auto; width:100%; border-collapse:collapse; margin:0 auto; border-radius:15px; overflow:hidden;
  box-shadow:0 0 10px rgba(0,0,0,.1); background:#1e1e1e; }
th,td{ border:1px solid #48586e; padding:8px; text-align:left; color:#dcdcdc; overflow-wrap:anywhere; word-break:break-word; }
th{ background:#3b4a5a; position:relative; cursor:pointer; }
th:first-child{ border-top-left-radius:15px; } th:last-child{ border-top-right-radius:15px; }
tr:last-child td:first-child{ border-bottom-left-radius:15px; } tr:last-child td:last-child{ border-bottom-right-radius:15px; }
td:nth-child(5), td:nth-child(6){ word-break:break-word; max-width:420px; }

/* ===== Модалка ===== */
.modal{ position:fixed; inset:0; background:rgba(0,0,0,.5); opacity:0; visibility:hidden; pointer-events:none; transition:opacity .2s ease; z-index:1000; }
.modal:target{ opacity:1; visibility:visible; pointer-events:auto; }
.modal-content{ background:#2c2c2c; color:#dcdcdc; border:1px solid #888; width:min(700px,92vw); margin:10vh auto; padding:20px; border-radius:8px; }
.modal-actions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin:10px 0; }
.modal-list{ margin-top:12px; max-height:45vh; overflow:auto; border:1px solid #48586e; border-radius:8px; padding:12px; }
.close{ float:right; text-decoration:none; font-size:28px; line-height:1; color:#aaa; }
.close:hover{ color:#fff; }

/* ===== Адаптив ===== */
@media (max-width:900px){
  .header-row{ grid-template-columns:1fr; padding-right:0; }
  .header-row h1{ grid-column:1; text-align:center; justify-self:stretch; }
  .session-badge{ grid-column:1; justify-self:stretch; max-width:100%; }
  .badge-dropdown{ right:auto; left:0; width:100%; }

  .filters-bar{ grid-template-columns:1fr; row-gap:10px; padding:6px 0 10px 0; }
  .filters-left, .filters-right{ justify-content:stretch; flex-wrap:wrap; }
  .ip-settings-button, .sort-toggle{ width:100%; }
  .filters-right input[type="text"], .filters-right input[type="date"]{ width:100%; max-width:none; }
}

/* Мобильные карточки */
@media (max-width:900px){
  .table-responsive colgroup{ display:none !important; }
  .table-responsive table{ display:block !important; width:100% !important; table-layout:auto !important; background:transparent; box-shadow:none; }
  .table-responsive thead{ display:none !important; }
  .table-responsive tbody{ display:block !important; }
  .table-responsive tbody tr{
    display:block !important; margin-bottom:12px; background:#1e1e1e;
    border:1px solid #48586e; border-radius:12px; overflow:hidden;
  }
  .table-responsive tbody td{
    display:block !important; border:none !important; border-top:1px solid #48586e !important;
    padding:10px 12px 10px 140px; position:relative; min-height:44px;
  }
  .table-responsive tbody td:first-child{ border-top:none !important; }
  .table-responsive tbody td::before{
    content:attr(data-label);
    position:absolute; left:12px; top:10px; width:120px; font-weight:bold; color:#dcdcdc; opacity:.9; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
}
