* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #060913;
  --card: rgba(10, 15, 30, 0.72);
  --border: rgba(255, 255, 255, 0.06);
  --text: #f3f4f6;
  --muted: #8c9bb4;
  --primary: #00d2ff;
  --primary-dim: rgba(0, 210, 255, 0.12);
  --green: #22c55e;
  --red: #ff3366;
  --purple: #a78bfa;
}

body {
  font-family: Outfit, Segoe UI, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 50% 0%, #111a2e 0%, #060913 100%);
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -80px;
  left: 10%;
  background: rgba(0, 210, 255, 0.08);
}

.orb-2 {
  width: 360px;
  height: 360px;
  top: 20%;
  right: 5%;
  background: rgba(99, 102, 241, 0.06);
}

.card {
  width: min(440px, 92vw);
  margin: 8vh auto;
  padding: 32px;
  border-radius: 22px;
  background: var(--card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  color: #fff;
  background: linear-gradient(135deg, #00d2ff, #6366f1);
  box-shadow: 0 0 30px rgba(0, 210, 255, 0.25);
}

.logo.sm {
  width: 44px;
  height: 44px;
  margin: 0;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand p,
.sub,
.stat-body small {
  color: var(--muted);
  font-size: 0.88rem;
}

form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  outline: none;
  border-color: rgba(0, 210, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.1);
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 700;
  font-family: inherit;
  transition: all 0.2s;
}

form label {
  display: block;
  margin-bottom: 14px;
}

form button {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  color: #060913;
  background: linear-gradient(135deg, #00d2ff, #38bdf8);
  box-shadow: 0 4px 20px rgba(0, 210, 255, 0.25);
}

form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(0, 210, 255, 0.35);
}

.login-card form button {
  width: 100%;
}

.logout-form button,
.btn-outline {
  width: 100%;
  padding: 11px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: none;
  transform: none;
  margin-top: 0;
}

.logout-form button:hover,
.btn-outline:hover {
  color: #fff;
  border-color: rgba(255, 51, 102, 0.3);
  background: rgba(255, 51, 102, 0.06);
  box-shadow: none;
  transform: none;
}

.error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 51, 102, 0.1);
  border: 1px solid rgba(255, 51, 102, 0.2);
  color: #ff8fab;
  font-size: 0.88rem;
}

.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  flex-shrink: 0;
  min-height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: rgba(6, 9, 19, 0.92);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-inline {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
}

.brand-inline strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-inline span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.2s;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.15), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(0, 210, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 210, 255, 0.08);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.live-dot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0 10px;
}

.pulse,
.pulse-sm {
  display: inline-block;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

.pulse {
  width: 8px;
  height: 8px;
}

.pulse-sm {
  width: 6px;
  height: 6px;
  margin-right: 4px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.content {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 28px 32px 40px;
}

.page-inner {
  width: 100%;
  max-width: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 4px;
}

.topbar h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock {
  font-family: Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #86efac;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-off {
  background: rgba(255, 51, 102, 0.1);
  border-color: rgba(255, 51, 102, 0.25);
  color: #ff8fab;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

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

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

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat-card {
  display: flex;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.accent-blue .stat-icon { color: #60a5fa; background: rgba(96, 165, 250, 0.1); border-color: rgba(96, 165, 250, 0.2); }
.accent-cyan .stat-icon { color: #00d2ff; background: rgba(0, 210, 255, 0.1); border-color: rgba(0, 210, 255, 0.2); }
.accent-purple .stat-icon { color: var(--purple); background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.2); }
.accent-green .stat-icon { color: #86efac; background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.2); }

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-body span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat-body strong {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  margin: 8px 0 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #6366f1, #00d2ff);
  transition: width 0.6s ease;
}

.panel {
  padding: 22px 24px;
  border-radius: 18px;
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-head h2 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head h2 i {
  color: var(--primary);
  font-size: 0.9rem;
}

.chart-panel {
  overflow: hidden;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 4px 4px;
}

.chart-panel canvas {
  width: 100% !important;
  display: block;
}

.cdn-mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cdn-mini-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.cdn-mini-item:hover {
  border-color: rgba(0, 210, 255, 0.15);
}

.cdn-mini-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cdn-mini-left i {
  color: var(--primary);
  font-size: 1.1rem;
}

.cdn-mini-left strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cdn-mini-left small {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.78rem;
}

.cdn-mini-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.inline-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}

.inline-link:hover {
  text-shadow: 0 0 12px rgba(0, 210, 255, 0.3);
}

.btn-primary {
  padding: 11px 18px;
  color: #060913;
  font-weight: 700;
  font-size: 0.88rem;
  background: linear-gradient(135deg, #00d2ff, #38bdf8);
  box-shadow: 0 4px 20px rgba(0, 210, 255, 0.2);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(0, 210, 255, 0.3);
}

.table-panel {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

.cdn-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.cdn-table th,
.cdn-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cdn-table .col-no { width: 52px; text-align: center; }
.cdn-table .col-domain { width: 26%; }
.cdn-table .col-target { width: 16%; }
.cdn-table .col-cache { width: 14%; }
.cdn-table .col-speed { width: 12%; }
.cdn-table .col-actions { width: 340px; }

.server-ip-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #67e8f9;
  background: rgba(0, 210, 255, 0.08);
  border: 1px solid rgba(0, 210, 255, 0.2);
  vertical-align: middle;
}

.server-ip-badge i {
  font-size: 0.65rem;
}

.modal-icon-edit {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}

input[readonly] {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-edit {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.3);
}

.btn-edit:hover {
  background: rgba(251, 191, 36, 0.1);
}

.cdn-table td.col-actions {
  padding-right: 16px;
}

.cache-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.cdn-table th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.cdn-table tbody tr {
  transition: background 0.15s;
}

.cdn-table tbody tr:hover {
  background: rgba(0, 210, 255, 0.04);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 32px !important;
}

.error-text { color: #ff8fab !important; }

.mono {
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.muted { color: var(--muted); font-size: 0.78rem; }

.link-domain {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.link-domain:hover { text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-green { background: rgba(34, 197, 94, 0.12); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.2); font-size: 0.78rem; padding: 6px 12px; }
.tag-gray { background: rgba(255, 255, 255, 0.04); color: var(--muted); border: 1px solid var(--border); }
.tag-blue { background: rgba(0, 210, 255, 0.1); color: #67e8f9; border: 1px solid rgba(0, 210, 255, 0.2); }

.actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.btn-sm {
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  transition: all 0.15s;
  line-height: 1;
  white-space: nowrap;
}

.btn-cache {
  color: #67e8f9;
  border-color: rgba(0, 210, 255, 0.25);
}

.btn-cache:hover {
  background: rgba(0, 210, 255, 0.1);
}

.btn-danger {
  color: #ff8fab;
  border-color: rgba(255, 51, 102, 0.25);
}

.btn-danger:hover {
  background: rgba(255, 51, 102, 0.1);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.85);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-card {
  width: min(460px, 96vw);
  padding: 28px;
  border-radius: 20px;
  background: #0a0f1e;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(0, 210, 255, 0.1);
  color: var(--primary);
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.modal-card label {
  display: block;
  margin-bottom: 14px;
}

.modal-card label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.check-row input { width: auto; margin: 0; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .btn-outline,
.modal-actions .btn-primary {
  flex: 1;
}

.modal-card-wide {
  width: min(520px, 96vw);
}

.modal-body {
  margin-bottom: 18px;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.55;
}

.modal-body p {
  margin: 0;
}

.cfg-box {
  margin-top: 14px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  text-align: left;
}

.cfg-box label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cfg-pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #060913;
  border: 1px solid rgba(0, 210, 255, 0.15);
  color: #86efac;
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  cursor: text;
}

.cfg-note {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.cfg-note i {
  color: var(--primary);
  margin-top: 2px;
}

.modal-icon-warn {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}

.modal-icon-danger {
  background: rgba(255, 51, 102, 0.1);
  color: #ff8fab;
  border-color: rgba(255, 51, 102, 0.25);
}

.modal-icon-success {
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.25);
}

.modal-icon-loading {
  background: rgba(0, 210, 255, 0.1);
  color: var(--primary);
  border-color: rgba(0, 210, 255, 0.25);
}

.btn-cfg {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

.btn-cfg:hover {
  background: rgba(34, 197, 94, 0.1);
}

.modal-actions.hidden {
  display: none;
}

#cdn-modal-ok.btn-danger {
  background: linear-gradient(135deg, #ff3366, #ef4444);
  color: #fff;
}

#cdn-modal-ok.btn-danger:hover {
  box-shadow: 0 4px 20px rgba(255, 51, 102, 0.25);
}

.toast {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 12px;
  background: #0a0f1e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
  font-weight: 600;
  font-size: 0.88rem;
  z-index: 60;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.toast-error {
  border-color: rgba(255, 51, 102, 0.3);
  color: #ff8fab;
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .content { padding: 20px 16px 32px; }
  .topbar { flex-direction: column; }
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .cdn-mini-item { grid-template-columns: 1fr; }
  .cdn-table .col-actions { width: 180px; }
}
