:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #d9e3f0;
  --head: #f8fafc;
  --blue: #1683ff;
  --blue-soft: #edf6ff;
  --green: #16c784;
  --red: #ef4444;
  --shadow: 0 16px 50px rgba(30, 41, 59, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.98);
}

input,
select {
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 131, 255, 0.12);
}

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

.is-hidden {
  display: none !important;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 30px;
  align-items: center;
  min-height: 460px;
  margin-top: 8vh;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: #374151;
  font-weight: 800;
}

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

.topbar h1 {
  margin-bottom: 4px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.ghost-button {
  background: #111827;
}

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

.summary-strip article,
.manager-panel,
.stats-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-strip article {
  padding: 14px 16px;
}

.summary-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-strip strong {
  color: var(--blue);
  font-size: 1.55rem;
}

.manager-panel,
.stats-panel {
  padding: 18px;
}

.filter-row {
  display: grid;
  grid-template-columns: 240px 260px 240px auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.filter-actions,
.toolbar-row,
.toolbar-left,
.toolbar-right,
.row-actions,
.modal-actions,
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-row {
  justify-content: space-between;
  margin-bottom: 8px;
}

.soft-button,
.circle-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #4b5563;
}

.soft-primary {
  border: 1px solid rgba(22, 131, 255, 0.28);
  background: var(--blue-soft);
  color: var(--blue);
}

.soft-danger {
  border: 1px solid rgba(239, 68, 68, 0.24);
  background: #fff1f2;
  color: var(--red);
}

.circle-button {
  width: 36px;
  padding: 0;
  border-radius: 999px;
  font-size: 1rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 1420px;
  border-collapse: collapse;
}

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

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  background: var(--head);
  color: #374151;
  font-size: 0.82rem;
  font-weight: 900;
}

td {
  color: #5b6472;
  font-size: 0.9rem;
}

td input[type="checkbox"],
th input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: #dcfce7;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-tag.off {
  background: #fee2e2;
  color: var(--red);
}

.row-actions button {
  min-height: 28px;
  padding: 0 4px;
  background: transparent;
  color: var(--blue);
  font-size: 0.82rem;
}

.pager-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
}

.pager-row select {
  width: 110px;
}

.stats-panel {
  margin-top: 14px;
}

.panel-head,
.section-head {
  justify-content: space-between;
}

.target-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.target-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

.target-stat strong {
  display: block;
  margin-bottom: 4px;
}

.target-stat small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-line {
  min-height: 22px;
  margin-bottom: 0;
  color: var(--green);
  font-weight: 800;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  position: relative;
  width: min(1020px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.28);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-head p {
  margin-bottom: 0;
}

.link-form {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

.form-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

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

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

.target-row {
  display: grid;
  grid-template-columns: 64px 130px minmax(240px, 1fr) minmax(160px, 0.42fr) 96px 64px;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.target-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.target-index {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  justify-content: flex-end;
  padding-bottom: 4px;
}

.modal-actions .status-line {
  margin-right: auto;
}

@media (max-width: 980px) {
  .filter-row,
  .summary-strip,
  .form-grid,
  .target-row {
    grid-template-columns: 1fr;
  }

  .toolbar-row,
  .topbar,
  .modal-head,
  .section-head,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    width: min(100% - 18px, 1680px);
  }

  .login-panel {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .summary-strip article {
    padding: 12px;
  }
}
