/* DNS Panel - minimal operations UI */

:root {
  --bg: #050505;
  --surface: #0b0b0b;
  --surface-2: #111111;
  --surface-3: #171717;
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #f4f4f4;
  --text-soft: #cfcfcf;
  --text-muted: #8b8b8b;
  --white: #ffffff;
  --black: #000000;
  --success: #73d18a;
  --success-bg: rgba(115, 209, 138, 0.12);
  --warning: #e5c76b;
  --warning-bg: rgba(229, 199, 107, 0.12);
  --danger: #ff7a7a;
  --danger-bg: rgba(255, 122, 122, 0.12);
  --info: #8ec5ff;
  --info-bg: rgba(142, 197, 255, 0.12);
  --radius: 6px;
  --radius-sm: 4px;
  --font: Arial, Helvetica, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --transition: 160ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: #3d3d3d;
  border-radius: 4px;
}

.app-layout {
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 68px;
  padding: 0 34px;
  background: rgba(5, 5, 5, 0.94);
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 170px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  color: var(--white);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-sub {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sidebar-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.nav-section {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.nav-section-title {
  display: none;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 68px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--white);
  border-bottom-color: var(--white);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 800;
}

.user-name {
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 700;
}

.user-role {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.logout-action {
  margin: 0;
}

.main-content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 38px 34px 64px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.page-header h1 {
  margin: 0;
  color: var(--white);
  font-size: 1.95rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

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

.card,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card {
  overflow: hidden;
}

.stat-card {
  min-height: 118px;
  padding: 20px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  margin-top: 12px;
  color: var(--white);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  word-break: break-word;
}

.status-value {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
}

.status-meta {
  margin-top: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.stat-card.success {
  border-color: rgba(115, 209, 138, 0.42);
}

.stat-card.success .stat-value {
  color: var(--success);
}

.stat-card.warning {
  border-color: rgba(229, 199, 107, 0.45);
}

.stat-card.warning .stat-value {
  color: var(--warning);
}

.stat-card.danger {
  border-color: rgba(255, 122, 122, 0.42);
}

.stat-card.danger .stat-value {
  color: var(--danger);
}

.stat-card.info {
  border-color: var(--line);
}

.card + .card,
.stats-grid + .card {
  margin-top: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.card-header h2 {
  margin: 0;
  color: var(--white);
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-body {
  padding: 20px;
}

.card-body.no-pad {
  padding: 0;
}

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

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

thead th {
  padding: 13px 16px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  color: var(--text-soft);
  font-size: 0.88rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.zone-name,
.zone-name a {
  color: var(--white);
  font-weight: 800;
  text-decoration: none;
}

.zone-name a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.monospace {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.badge,
.zone-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--surface-3);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.badge-success,
.zone-type.master {
  color: var(--success);
  background: var(--success-bg);
  border-color: rgba(115, 209, 138, 0.32);
}

.badge-warning,
.zone-type.slave {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(229, 199, 107, 0.3);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(255, 122, 122, 0.32);
}

.badge-info {
  color: var(--info);
  background: var(--info-bg);
  border-color: rgba(142, 197, 255, 0.28);
}

.badge-neutral {
  color: var(--text-muted);
  background: var(--surface-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 16px;
  border: 1px solid var(--white);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn:hover {
  background: transparent;
  color: var(--white);
}

.btn-primary {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}

.btn-secondary {
  background: transparent;
  color: var(--white);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  border-color: var(--white);
}

.btn-danger {
  color: var(--danger);
  background: transparent;
  border-color: rgba(255, 122, 122, 0.42);
}

.btn-danger:hover {
  color: var(--black);
  background: var(--danger);
  border-color: var(--danger);
}

.btn-success {
  color: var(--success);
  background: transparent;
  border-color: rgba(115, 209, 138, 0.42);
}

.btn-success:hover {
  color: var(--black);
  background: var(--success);
  border-color: var(--success);
}

.btn-warning {
  color: var(--warning);
  background: transparent;
  border-color: rgba(229, 199, 107, 0.42);
}

.btn-warning:hover {
  color: var(--black);
  background: var(--warning);
  border-color: var(--warning);
}

.btn-sm {
  min-height: 32px;
  padding: 7px 12px;
  font-size: 0.68rem;
}

.btn-icon {
  min-width: 32px;
  padding: 7px 10px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--white);
  background: var(--black);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--white);
}

.form-input::placeholder {
  color: #666666;
}

.form-input:disabled {
  color: var(--text-muted);
  background: var(--surface-2);
}

.form-textarea {
  min-height: 220px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--white);
}

.form-hint {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.flash-messages {
  position: fixed;
  top: 82px;
  right: 24px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
}

.flash {
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--white);
  font-size: 0.86rem;
  cursor: pointer;
}

.flash-success {
  color: var(--success);
  border-color: rgba(115, 209, 138, 0.32);
}

.flash-error {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.32);
}

.flash-warning {
  color: var(--warning);
  border-color: rgba(229, 199, 107, 0.32);
}

.flash-info {
  color: var(--info);
  border-color: rgba(142, 197, 255, 0.32);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 42px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-logo {
  margin-bottom: 30px;
}

.login-logo h1 {
  margin: 0;
  color: var(--white);
  font-size: 1.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-logo p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-card .btn-primary {
  width: 100%;
}

.log-viewer {
  max-height: 620px;
  overflow: auto;
  padding: 16px;
  color: #d7d7d7;
  background: var(--black);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-link {
  padding: 8px 12px;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tab-link:hover,
.tab-link.active {
  color: var(--white);
  border-color: var(--white);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(520px, 100%);
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.modal h3 {
  margin: 0 0 18px;
  color: var(--white);
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.network-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.network-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

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

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 1rem;
}

.empty-state p {
  margin: 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pulse-dot.active {
  background: var(--success);
}

.pulse-dot.inactive {
  background: var(--danger);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 50;
  padding: 6px 9px;
  color: var(--white);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%);
  transition: opacity var(--transition), visibility var(--transition);
}

[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

.confirm-text {
  color: var(--text-soft);
}

.confirm-zone-name {
  color: var(--danger);
  font-family: var(--font-mono);
  font-weight: 800;
}

@media (max-width: 920px) {
  .sidebar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px;
  }

  .sidebar-brand,
  .sidebar-footer {
    width: 100%;
  }

  .sidebar-nav {
    width: 100%;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-section {
    flex-wrap: wrap;
    gap: 10px;
  }

  .nav-link {
    min-height: 34px;
    border-bottom: 1px solid transparent;
  }

  .sidebar-footer {
    justify-content: space-between;
  }

  .main-content {
    padding: 28px 20px 48px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 14px;
  }

  .sidebar-footer {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .btn-group,
  .modal-actions {
    justify-content: stretch;
  }

  .btn-group .btn,
  .btn-group form,
  .modal-actions .btn {
    flex: 1 1 auto;
  }

  tbody td,
  thead th {
    padding: 12px;
  }

  .login-card {
    padding: 30px 24px;
  }
}
