:root {
  --bg: #f6f8fc;
  --sidebar-bg: #ffffff;
  --panel-bg: #ffffff;
  --panel-alt: #f8fafc;
  --ink: #1d2b44;
  --muted: #8a99b2;
  --line: #e6edf6;
  --blue: #4a7df3;
  --blue-soft: #edf3ff;
  --green-soft: #eaf8ef;
  --green-ink: #2d8f5b;
  --red-soft: #fff0ef;
  --red-ink: #dc5e52;
  --amber-soft: #fff8e9;
  --amber-ink: #d49311;
  --shadow: 0 20px 50px rgba(44, 65, 107, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top left, rgba(74, 125, 243, 0.08), transparent 22%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

.login-panel {
  width: min(1080px, 100%);
}

.brand-block {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 28px;
  font-weight: 700;
  flex: 0 0 auto;
}

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

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 0.95;
  margin-bottom: 12px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

.hero-copy,
.muted {
  color: var(--muted);
}

.hero-copy {
  max-width: 58ch;
  line-height: 1.6;
  font-size: 15px;
}

.login-grid,
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.stack {
  display: grid;
  gap: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

button {
  border: none;
  background: var(--blue);
  color: #fff;
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger-button {
  color: var(--red-ink);
  border-color: #f2cbc6;
  background: #fff;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 42px 26px 32px;
}

.sidebar-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 42px;
}

.sidebar-title {
  font-size: 17px;
  font-weight: 700;
}

.sidebar-nav {
  display: grid;
  gap: 32px;
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.nav-link,
.logout-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  width: 100%;
  border-radius: 14px;
  padding: 0 14px;
  color: #6f81a1;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}

.nav-link.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.nav-link-static {
  color: #6f81a1;
  background: transparent;
  pointer-events: none;
  min-height: 34px;
  padding: 0 0 0 14px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-ip-list {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.sidebar-project-block {
  display: grid;
  gap: 8px;
}

.sidebar-project-toggle {
  width: 100%;
  text-align: left;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #6f81a1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  gap: 2px;
}

.sidebar-project-toggle small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.sidebar-project-toggle.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #d9e6ff;
}

.sidebar-project-ips {
  display: grid;
  gap: 8px;
  padding-left: 12px;
}

.sidebar-ip-item {
  width: 100%;
  text-align: left;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #6f81a1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  display: grid;
  gap: 2px;
  margin-right: -6px;
}

.sidebar-ip-item.active {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #d9e6ff;
}

.sidebar-ip-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.sidebar-empty {
  font-size: 12px;
  padding: 0 14px;
}

.logout-link {
  color: var(--red-ink);
  padding-left: 16px;
}

.content {
  padding: 42px 42px 60px;
}

.page-head {
  margin-bottom: 26px;
}

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

.stat {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.panel-stack {
  display: grid;
  gap: 22px;
  margin-bottom: 26px;
}

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

.overview-item {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: var(--panel-alt);
  display: grid;
  gap: 6px;
}

.overview-item strong {
  font-size: 22px;
}

.overview-search {
  display: grid;
  gap: 14px;
}

.overview-search-results {
  display: grid;
  gap: 10px;
}

.overview-result-item {
  width: 100%;
  text-align: left;
  background: var(--panel-alt);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.overview-result-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.overview-result-head strong {
  font-size: 15px;
}

.overview-result-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  margin-bottom: 18px;
}

.keys-list {
  display: grid;
  gap: 12px;
}

.domain-pick-panel {
  border: 1px solid var(--line);
  background: var(--panel-alt);
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
}

.domain-pick-all,
.domain-pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.domain-pick-list {
  display: grid;
  gap: 10px;
}

.domain-pick-item {
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}

.domain-pick-name {
  flex: 1 1 auto;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.domain-pick-meta {
  color: var(--muted);
  font-size: 12px;
}

.unassigned-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.unassigned-chip {
  background: var(--panel-alt);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.unassigned-chip strong {
  font-size: 24px;
  line-height: 1;
}

.unassigned-chip span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.unassigned-chip.active {
  background: var(--blue-soft);
  border-color: #d9e6ff;
  color: var(--blue);
}

.unassigned-chip.active span {
  color: #6f81a1;
}

.unassigned-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.unassigned-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-alt);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}

.settings-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.settings-tab {
  background: #fff;
  color: #6f81a1;
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 14px;
}

.settings-tab.active {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #d9e6ff;
}

.settings-ip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--panel-alt);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 43, 68, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.check-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ip-list {
  display: grid;
  gap: 12px;
}

.ip-item {
  background: var(--panel-alt);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 14px;
  font-size: 14px;
}

.ip-item.active {
  background: var(--blue-soft);
  border-color: #cfe0ff;
}

.ip-card-main {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: none;
  border-radius: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.ip-card-main strong {
  font-size: 18px;
}

.ip-inline-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.ip-inline-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 9px 10px;
  display: grid;
  gap: 3px;
  min-height: 58px;
}

.ip-inline-chip span {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.ip-inline-chip small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.ip-inline-actions {
  display: flex;
  justify-content: flex-start;
}

.soft-card {
  background: var(--panel-alt);
  box-shadow: none;
}

.full-width-card {
  grid-column: 1 / -1;
}

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

.key-string {
  display: block;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px dashed #cdd9eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
  color: #45618e;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  width: min(100%, 860px);
}

.filters-compact {
  grid-template-columns: minmax(320px, 2fr) minmax(220px, 1.2fr) minmax(180px, 0.8fr);
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

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

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

.checkbox-col {
  width: 44px;
  min-width: 44px;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: inherit;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.sort-button span {
  color: var(--blue);
  font-size: 10px;
}

.header-menu {
  position: relative;
  display: inline-block;
}

.header-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 5;
}

.popover-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.popover-item:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.domain-cell {
  min-width: 220px;
  font-weight: 600;
  line-height: 1.45;
  font-size: 14px;
}

.ip-cell {
  min-width: 160px;
  line-height: 1.45;
  font-size: 14px;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 204px;
}

.row-delete-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 14px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  background: #fff;
  color: var(--red-ink);
  border: 1px solid #f2cbc6;
}

.row-move-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 14px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  background: #fff;
  color: var(--blue);
  border: 1px solid #d9e6ff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge.checking {
  gap: 8px;
  background: #eef2ff;
  color: var(--blue);
}

.badge-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(74, 125, 243, 0.2);
  border-top-color: var(--blue);
  animation: badge-spin 0.8s linear infinite;
}

@keyframes badge-spin {
  to {
    transform: rotate(360deg);
  }
}

.badge.active,
.status-active {
  background: var(--green-soft);
  color: var(--green-ink);
}

.badge.blocked,
.status-blocked {
  background: var(--red-soft);
  color: var(--red-ink);
}

.badge.dead,
.status-dead {
  background: #f3f4f6;
  color: #6b7280;
}

.badge.pending_add,
.status-pending_add {
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.badge.unknown,
.status-unknown {
  background: var(--blue-soft);
  color: var(--blue);
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

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

  .login-grid,
  .panel-grid,
  .toolbar,
  .filters,
  .overview-list,
  .filters-compact,
  .ip-inline-summary {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (max-width: 760px) {
  .content,
  .sidebar,
  .login-shell {
    padding: 20px;
  }

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

  h1 {
    font-size: 40px;
  }
}
