:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #687385;
  --line: #dfe4eb;
  --accent: #177e89;
  --accent-strong: #12656e;
  --danger: #b42318;
  --ok: #177245;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}

a {
  color: inherit;
}

input {
  max-width: 100%;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

button {
  max-width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  font: 700 14px/1 system-ui, sans-serif;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #e8f2f3;
  color: var(--accent-strong);
}

button.danger {
  background: #fde8e6;
  color: var(--danger);
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.layout {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  min-width: 0;
  background: #202a36;
  color: #fff;
  padding: 24px;
}

.content {
  min-width: 0;
  max-width: 100%;
  padding: 28px;
}

.topbar,
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #aeb9c8;
  margin-top: 18px;
}

.muted {
  color: var(--muted);
}

.panel,
.table-wrap {
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 18px;
}

.access-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.access-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  background: #fbfcfd;
}

.access-item span {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 999px;
  background: #334052;
  color: #dce5ef;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.back-link {
  display: inline-flex;
  color: #dce5ef;
  margin-bottom: 18px;
  text-decoration: none;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: #dce5ef;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover {
  background: #334052;
}

.notice {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.notice.success {
  background: #e7f6ee;
  color: var(--ok);
}

.notice.error {
  background: #fde8e6;
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
}

.stats-panel {
  margin-bottom: 16px;
}

.stats-table {
  min-width: 0;
}

.stats-table a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.progress {
  display: inline-flex;
  width: 110px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: #dbe3ea;
  overflow: hidden;
  vertical-align: middle;
}

.progress span {
  display: block;
  background: var(--accent);
}

.add-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check input {
  width: 18px;
  min-height: 18px;
}

table {
  max-width: 100%;
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 18px;
  }

  .content {
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-top: 18px;
  }

  .add-form {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    padding: 12px;
  }

  .responsive-table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table th,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #edf1f5;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td[data-label="Действия"] {
    display: block;
  }

  .responsive-table td[data-label="Действия"]::before {
    display: block;
    margin-bottom: 8px;
  }

  .responsive-table .empty {
    display: block;
  }

  .responsive-table .empty::before {
    content: "";
  }

  .action-buttons {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .action-buttons form,
  .action-buttons button {
    width: 100%;
  }

  .progress {
    width: 82px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: 100%;
    padding: 16px;
  }

  .sidebar,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .responsive-table td {
    display: block;
  }

  .responsive-table td::before {
    display: block;
    margin-bottom: 6px;
  }

  .check {
    white-space: normal;
  }
}
