* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0f1419;
  color: #e7ecf3;
  line-height: 1.45;
}
.hidden { display: none !important; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #243044;
  max-width: 1200px;
  margin: 0 auto;
}
.app-header h1 { margin: 0; font-size: 1.25rem; }

.login-card {
  max-width: 400px;
  margin: 80px auto;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 20px;
}
.tab-btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #171d27;
  color: #94a3b8;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.tab-btn:hover { color: #e7ecf3; border-color: #475569; }
.tab-btn.active {
  background: #1e3a5f;
  border-color: #3b82f6;
  color: #fff;
}

.tab-panel {
  max-width: 1200px;
  margin: 12px auto 24px;
}
.card {
  background: #171d27;
  border: 1px solid #243044;
  border-radius: 12px;
  padding: 20px;
}
h1, h2, h3 { margin-top: 0; }
h2 { font-size: 1.15rem; margin-bottom: 8px; }

input, textarea, button, select {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #334155;
  padding: 10px 12px;
  background: #0f1419;
  color: #e7ecf3;
}
select { cursor: pointer; }
button {
  background: #3b82f6;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button.secondary { background: #334155; }
button.danger { background: #dc2626; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select { width: 100%; }
.field-action { justify-content: flex-end; }
.field-action button { width: 100%; margin-top: auto; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid #243044;
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  border-bottom: 1px solid #243044;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
th {
  background: #121820;
  color: #94a3b8;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: none; }
.empty-cell {
  text-align: center;
  color: #64748b;
  padding: 24px !important;
}

.error { color: #f87171; }
.hint { color: #94a3b8; font-size: 13px; margin: 0 0 16px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-content {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  margin: 0;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-close { margin-top: 12px; }
textarea { width: 100%; margin: 8px 0 12px; }

.link-btn { margin-right: 4px; margin-bottom: 4px; display: inline-block; font-size: 13px; }
a.link-btn { color: #93c5fd; text-decoration: none; }
a.link-btn:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.disabled-row { opacity: 0.5; }

.inbound-row { align-items: center; }
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #cbd5e1;
  margin: 8px 0;
}
.check-label input { width: auto; margin: 0; }
.port-input { width: 88px !important; flex: 0 0 auto; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #14532d;
  color: #86efac;
}
.badge.off { background: #334155; color: #94a3b8; }

.traffic-bar {
  height: 5px;
  background: #243044;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
  max-width: 140px;
}
.traffic-bar > span {
  display: block;
  height: 100%;
  background: #22c55e;
}
.traffic-bar.warn > span { background: #f59e0b; }
.traffic-bar.danger > span { background: #ef4444; }

.actions-cell { min-width: 200px; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  align-items: center;
}
.actions-cell select,
.actions-cell input[type=number] {
  width: 90px;
  padding: 6px 8px;
  font-size: 12px;
}

.btn-download {
  display: inline-block;
  margin: 12px 8px 12px 0;
  padding: 12px 20px;
  background: #22c55e;
  color: #0f1419;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
}
.btn-node-setup {
  background: #22c55e !important;
  color: #0f1419 !important;
  font-weight: 600;
}

@media (max-width: 768px) {
  .admin-tabs { padding: 0 12px; }
  .tab-panel { margin: 8px 12px 20px; padding: 16px; }
  .tab-btn { flex: 1; padding: 10px 8px; font-size: 13px; }
}
