:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #dce6f2;
  --line-strong: #c8d6e8;
  --text: #0f172a;
  --muted: #5f6f86;
  --primary: #0f3d91;
  --primary-2: #1787a8;
  --success-bg: #eef9f0;
  --success-text: #17653a;
  --danger-bg: #fff0f0;
  --danger-text: #9a1c1c;
  --warning-bg: #fff9eb;
  --warning-text: #8c6212;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  --radius: 18px;
  --sidebar-w: 320px;
  --topbar-h: 74px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 100%);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
}

.logo-box,
.client-box,
.tenant-box,
.topbar,
.card,
.pending-bar,
.help-article,
.help-card,
.tutorial-nav,
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.logo-box {
  border-radius: 22px;
  padding: 10px 14px;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.logo-box img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  flex: 0 0 64px;
}

.logo-text-wrap {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.logo-text-main {
  display: inline-grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "next"
    "dns";
  row-gap: 0;
  font-size: 22px;
  line-height: 1.02;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  word-break: normal;
  white-space: normal;
  text-align: center;
}

.logo-text-main .logo-next {
  grid-area: next;
  justify-self: start;
}

.logo-text-main .logo-dns {
  grid-area: dns;
  justify-self: center;
}

.client-box,
.tenant-box {
  border-radius: var(--radius);
  padding: 16px;
}

.tenant-box {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.client-name {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.35;
}

.client-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.tenant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex: 0 0 auto;
}

.icon-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--primary);
  width: 30px;
  height: 30px;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.icon-btn.small {
  width: 26px;
  height: 26px;
  font-size: 15px;
}

.tenant-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.tenant-item {
  border: 1px solid var(--line);
  background: #fbfdff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 10px 12px;
}

.tenant-item.active {
  border-color: rgba(15,61,145,.38);
  background: linear-gradient(90deg,#f5f9ff,#ffffff);
}

.tenant-ip {
  font-weight: 600;
  font-size: 14px;
}

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px 20px 0;
  background: linear-gradient(180deg, rgba(245,247,251,.96), rgba(245,247,251,.88) 72%, rgba(245,247,251,0));
}

.topbar {
  height: var(--topbar-h);
  border-radius: 22px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.menu-link {
  padding: 11px 16px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid transparent;
}

.menu-link.active {
  background: #eff5ff;
  border-color: #d6e6ff;
  color: var(--primary);
}

.content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-grid-dashboard {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0,1fr));
}

.span-2 {
  grid-column: 1 / -1;
}

.card {
  border-radius: 20px;
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
}

.card-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.list-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-row,
.stream-row {
  display: grid;
  align-items: center;
  gap: 10px;
  border: 1px solid #edf2f7;
  background: #fbfdff;
  border-radius: 12px;
}

.rank-row {
  grid-template-columns: 1fr auto;
  padding: 8px 10px;
}

.rank-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-value {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  padding: 5px 9px;
  min-height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.chip.active {
  background: #eef5ff;
  border-color: #cfe0ff;
  color: var(--primary);
}

.stream-card .list-rows {
  max-height: 276px;
  overflow: auto;
}

.stream-row {
  grid-template-columns: 74px 1fr auto;
  padding: 8px 10px;
}

.stream-row .time {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.stream-row .domain {
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-row .category {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

.stream-row.allowed .category {
  background: var(--success-bg);
  color: var(--success-text);
}

.stream-row.blocked .category {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.chart-wrap {
  height: 290px;
}

.card-note {
  color: var(--muted);
  font-size: 12px;
}

.pending-bar {
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-grid-access {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0,1fr));
}

.category-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
}

.category-name {
  font-weight: 700;
  font-size: 14px;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #d7e2f1;
  border-radius: 999px;
  transition: .2s;
  cursor: pointer;
}

.slider:before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(15,23,42,.18);
  transition: .2s;
}

.switch input:checked + .slider {
  background: linear-gradient(90deg,var(--primary),var(--primary-2));
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

.help-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.help-card {
  border-radius: 20px;
  padding: 18px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eff5ff, #f8fbff);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 28px;
}

.help-card h3,
.help-article h3 {
  margin: 0;
  font-size: 18px;
}

.help-card p,
.help-article p,
.help-article li {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.help-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}

.tutorial-nav {
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-link {
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid transparent;
}

.tutorial-link.active {
  background: #eff5ff;
  color: var(--primary);
  border-color: #d6e6ff;
}

.help-article {
  border-radius: 20px;
  padding: 18px;
}

.hero-image {
  height: 210px;
  border-radius: 18px;
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(15,61,145,.12), rgba(23,135,168,.08)),
    radial-gradient(circle at top right, rgba(212,166,61,.18), transparent 38%),
    #f6faff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: 54px;
  font-weight: 800;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 18px;
}

.footer {
  margin-top: auto;
  padding: 8px 20px 22px;
}

.footer-inner {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding-top: 14px;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  border: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  border-radius: 22px;
  width: min(460px, 100%);
  padding: 18px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-text {
  margin: 0 0 14px;
  color: var(--muted);
}

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdff;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1180px) {
  .page-grid-dashboard,
  .help-grid,
  .help-layout {
    grid-template-columns: 1fr;
  }

  .page-grid-access {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    overflow: visible;
  }

  .tenant-box {
    flex: initial;
    min-height: auto;
    overflow: visible;
  }

  .tenant-list {
    max-height: 320px;
    flex: initial;
  }

  .topbar-wrap {
    padding-top: 0;
  }

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

@media (max-width: 640px) {
  .logo-box {
    padding: 10px 12px;
    gap: 10px;
  }

  .logo-box img {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .logo-text-main {
    font-size: 17px;
    grid-template-columns: 1fr;
  }

  .page-grid-access {
    grid-template-columns: 1fr;
  }

  .topbar {
    height: auto;
    padding: 14px;
    align-items: flex-start;
  }

  .menu {
    width: 100%;
  }

  .stream-row {
    grid-template-columns: 62px 1fr;
  }

  .stream-row .category {
    grid-column: 1 / -1;
    justify-self: start;
  }
}